I picked up a screech of CSS to build a form with visual queues for required fields.
The CSS has a couple of identical selectors that are apparently both important in that removing either effects the form. Is CSS merging these two some how ? Thanks for fielding the newbie question. Full listing below.
.required-field-block .required-icon { display: inline-block; vertical-align: middle; margin: -0.25em 0.25em 0em; background-color: #E8E8E8; snip for brevity .... } .required-field-block .required-icon { background-color: transparent; position: absolute; top: 0em; right: 0em; z-index: 10; margin: 0em; snip for brevity .... }
.required-field-block {
position: relative;
}
.required-field-block .required-icon {
display: inline-block;
vertical-align: middle;
margin: -0.25em 0.25em 0em;
background-color: #E8E8E8;
border-color: #E8E8E8;
padding: 0.5em 0.8em;
color: rgba(0, 0, 0, 0.65);
text-transform: uppercase;
font-weight: normal;
border-radius: 0.325em;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: background 0.1s linear;
-moz-transition: background 0.1s linear;
transition: background 0.1s linear;
font-size: 75%;
}
.required-field-block .required-icon {
background-color: transparent;
position: absolute;
top: 0em;
right: 0em;
z-index: 10;
margin: 0em;
width: 30px;
height: 30px;
padding: 0em;
text-align: center;
-webkit-transition: color 0.2s ease;
-moz-transition: color 0.2s ease;
transition: color 0.2s ease;
}
.required-field-block .required-icon:after {
position: absolute;
content: "";
right: 1px;
top: 1px;
z-index: -1;
width: 0em;
height: 0em;
border-top: 0em solid transparent;
border-right: 30px solid transparent;
border-bottom: 30px solid transparent;
border-left: 0em solid transparent;
border-right-color: inherit;
-webkit-transition: border-color 0.2s ease;
-moz-transition: border-color 0.2s ease;
transition: border-color 0.2s ease;
}
.required-field-block .required-icon .text {
color: #B80000;
font-size: 26px;
margin: -3px 0 0 12px;
}
Both defined styles will be applied, however where the properties overlap the second specified style will take precedence. If you use Firebug its pretty easy to see what happens:
From the CSS specification on cascading order:
Finally, sort by order specified: if two declarations have the same weight, origin and specificity, the latter specified wins. Declarations in imported style sheets are considered to be before any declarations in the style sheet itself.
So where you have conflicting styles for the same selector in the same style sheet, the last one takes precedence. So in your case, you get margin: 0em
and background-color: transparent
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With