I have a html-page which I would like to style (using IE9).
The following code:
<style type="text/css">
#komponenter select,
#komponenter input
{
width: 180px;
box-sizing:content-box;
}
.special_box { width: 50px; height: 150px; }
</style>
... snipp ...
<div id="col2" class="kolumn">
@Html.LabelFor(model => Model.Verksamhetskod)
<br />
@Html.TextBoxFor(model => Model.Verksamhetskod)
<br />
@Html.Label("Lat/Long")
@Html.TextBoxFor(m => m.LatitudTecken)
@Html.TextBoxFor(m => m.Latitud)
@Html.TextBoxFor(m => m.LongitudTecken)
@Html.TextBoxFor(m => m.Longitud)
<br />
@Html.Label("3 Överväganden:")
<br />
@Html.TextBoxFor(m => m.Overvagande)
<br />
@Html.Label("1 Ingångsvärden:")
<br />
@Html.TextBoxFor(m => m.Ingangsvarde, new { @class = "special_box" })
<br />
</div>
The html renders fine, the problem is that the .special_box width gets overridden by the css-statements above (the height works fine). I’ve tried putting the class first in the style section, but it did’nt make any difference.
it’s a matter of specificity: try this instead (assuming
.special_boxis aninputelement)a rule like
#komponenter inputhas a specificity of101(1 id, 0 classes, 1 element)while
.special_boxhas a specificity of10(1 class, 0 elements)see http://coding.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/ for more info