Please explain in detail this part of YUI3 CSS Res

2020-04-07 18:36发布

What is the usefulness of these 2 things in CSS reset?

What is the problem in resizing of input elements in IE and in which version?

and if legend color doesn't inherit in IE then how it can be solved adding color:#000;

/*to enable resizing for IE*/
input,
textarea,
select {
    *font-size:100%;
}
/*because legend doesn't inherit in IE */
legend {
    color:#000;
}

标签: css xhtml yui3
1条回答
淡お忘
2楼-- · 2020-04-07 19:07

The first rule actually doesn't apply on IE only, but on all webbrowsers. Normally you would like to define a global font in the body:

body {
    font: 1.1em verdana, arial, sans-serif;
}

But this doesn't get applied (inherited) on the form controls in all webbrowsers. That rule would then apply (only) the font size on them as well. One way is to set the font to inherit on those elements:

input, select, textarea {
    font: inherit;
}

But that doesn't work in IE6/7. Another way is to just explicitly include the elements in the rule:

body, input, select, textarea {
    font: 1.1em verdana, arial, sans-serif;
}

That only the font-size is been set is probably because the YUI guys would like to keep the form controls their own browser-default font family (which is sans-serif for input and select and is monospace for textarea). The 100% is been used because IE6/7 doesn't support inherit.

As to the second rule: I am not sure what they meant here. I did a little test in IE6/7. The legend just inherits the color from its parent element. Maybe the actual problem lies somewhere else?

查看更多
登录 后发表回答