I'm writing my own CSS reset and I encountered a problem. Let's say I have the following HTML and I reset it using the given styles.
* {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
line-height: 1.2;
vertical-align: baseline;
}
body {
margin: 10px;
font-family: sans-serif;
}
<p>
<input type="checkbox" /> <span style="font-size: 2em;">Red</span>
</p>
This doesn't really work because of the different rendering of input elements, in this case, the checkbox. See the following examples.
Both checkboxes are 13x13 pixels, but Chrome's actual (visual) size is 12x12 pixels. It has a drop-shadow effect, which makes it 13x13 pixels. If I want it to align properly, I need to use vertical-align: -1px
on the checkbox.
but if I do that, it'll apply the style on other browsers too. So I need to apply vertical-align: -1px
only on Chrome. Is there a way to accomplish this? Maybe something like
input[type="checkbox"]:(if-chrome) {
vertical-align: -1px;
}
Update: I've managed to customize the checkbox on Chrome which is nice, but IE doesn't support appearance
, and even though Firefox applies -moz-appearance: none
, it changes checkbox border-style to inset and doesn't let you modify it. And later finding out that appearance
is non-standart (dropped css3 features) was a huge disappointment. I'll have to wait for CSS UI 4, I guess.
* {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
line-height: 1.2;
vertical-align: baseline;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 10px;
font-family: sans-serif;
box-sizing: border-box;
}
input[type="checkbox"] {
-webkit-appearance: none;
width: 13px;
height: 13px;
border: 1px solid DarkGray;
position: relative;
}
input[type="checkbox"]:checked:after {
content: "✔";
font-size: 11px;
font-weight: bold;
line-height: 1;
position: absolute;
left: 1px;
}
<p>
<input type="checkbox" /> <span style="font-size: 2em;">Red</span>
</p>