请详细解释一下YUI3 CSS Reset的这一部分

发布于 2024-09-02 07:40:17 字数 295 浏览 2 评论 0原文

CSS重置中这两件事有什么用处?

在 IE 中调整输入元素大小时出现什么问题以及在哪个版本中?

如果图例颜色没有在 IE 中继承,那么如何解决添加 color:#000;

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

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;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不必了 2024-09-09 07:40:17

第一条规则实际上不仅仅适用于 IE,而是适用于所有网络浏览器。通常,您希望在 body 中定义全局字体:

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

但这不会应用于(继承)所有中的表单控件网络浏览器。然后,该规则也将(仅)应用字体大小。一种方法是将这些元素的font 设置为inherit

input, select, textarea {
    font: inherit;
}

但这在 IE6/7 中不起作用。另一种方法是在规则中明确包含元素:

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

仅设置 font-size 可能是因为 YUI 人员希望保留表单控件自己的浏览器默认字体系列(对于inputselectsans-serif,对于textareamonospace) 。使用100%是因为IE6/7不支持继承

至于第二条规则:我不确定他们在这里的意思。我在IE6/7下做了一个小测试。 legend 只是从其父元素继承颜色。也许真正的问题出在其他地方?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文