Reputation: 8506
input[type="checkbox"] {
display: none;
}
span:before {
font-family: "FontAwesome";
font-style: normal;
content: 'O';
margin-right: 3px;
font-size: 30px;
}
input[type="checkbox"]:checked ~ span:before {
content: 'Z';
}
<label>
<input type="checkbox"/>
<span>Text</span>
</label>
Upvotes: 2
Views: 1905
Reputation: 480
Just add
vertical-align:middle;
to
span:before { font-family: "FontAwesome"; font-style: normal; content: 'O'; margin-right: 3px; font-size: 30px; vertical-align:middle; }
Upvotes: 2
Reputation: 2107
Just add vertical-align:sub to span:before
Here is js fiddle link - Fiddle
span:before {
font-family: "FontAwesome";
font-style: normal;
content: 'O';
margin-right: 3px;
font-size: 30px;
vertical-align:sub;
}
Upvotes: 0
Reputation: 195
Setting the display
of the span to flex
and aligning the items center
would work.
input[type="checkbox"] {
display: none;
}
label span {
display: flex;
align-items: center;
}
span:before {
font-family: "FontAwesome";
font-style: normal;
content: 'O';
margin-right: 3px;
font-size: 30px;
}
input[type="checkbox"]:checked ~ span:before {
content: 'Z';
}
<label>
<input type="checkbox"/>
<span>Text</span>
</label>
Upvotes: 0
Reputation: 122037
You can use display: flex
and align-items: center
on span
element.
span {
display: flex;
align-items: center;
}
input[type="checkbox"] {
display: none;
}
span:before {
font-family: "FontAwesome";
font-style: normal;
content: 'O';
margin-right: 3px;
font-size: 30px;
}
input[type="checkbox"]:checked ~ span:before {
content: 'Z';
}
<label>
<input type="checkbox" />
<span>Text</span>
</label>
Upvotes: 4
Reputation: 1121
You can add the following into the span:before
element:
span:before {
vertical-align: middle;
position: relative;
}
Upvotes: 1