Reputation: 85
I tried to add margin-left
to the span in percentage, But the result is not as I want. It works only if I change the property display added to the label by bootstrap to block,
Can anyone explain this behavior to me, and offer a solution?
Thanks in advance.
label {
display: inline-block;
max-width: 100%;
margin-bottom: 5px;
font-weight: 700;
}
.field-description {
margin-left: 20%;
}
<label class="gender-item">
<input type="radio" id="male" class="field-checkbox" name="gender" value="">
<span class="field-description">male</span>
</label>
Upvotes: 0
Views: 79
Reputation: 7783
Percentage values relative to an inline-block that does not have an explicitly defined dimenion may cause weird problems, either refrain from using the percentage unit, or you could force the content to remain in one line with white-space: nowrap
;
label {
display: inline-block;
max-width: 100%;
margin-bottom: 5px;
font-weight: 700;
white-space: nowrap;
}
.field-description {
margin-left: 20%;
}
<label class="gender-item">
<input type="radio" id="male" class="field-checkbox" name="gender" value="">
<span class="field-description">male</span>
</label>
Upvotes: 3