(X)HTML+CSS 验证警告

发布于 2024-08-06 21:20:01 字数 166 浏览 5 评论 0原文

我尝试通过我的 css 验证,但仍然有一些警告,如下所示:

在 (x)HTML+CSS 中,浮动元素需要声明宽度。只有具有固有宽度的元素(html、img、input、textarea、select 或 object)不受影响。

事实上,我不太明白它的真正含义。任何人都可以解释一下吗?

I try to pass my css valiation yet I still have a few warnings like the following:

In (x)HTML+CSS, floated elements need to have a width declared. Only elements with an intrinsic width (html, img, input, textarea, select, or object) are not affected

In fact, I don't understand very well what it relly means. Anyone can explain?

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

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

发布评论

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

评论(4

清醇 2024-08-13 21:20:01

这只是意味着,如果您在没有固有宽度的元素上设置 float 属性,则还需要设置 width 属性。

编辑:此外,W3C 标准已取消该要求。在我看来,您使用的验证引擎可能已经过时了。

It just means that if you set the float property on an element that doesn't have an intrinsic width, you need to also set the width property.

Edit: Also, that requirement has been stricken from the W3C standard. Seems to me like the validation engine you're using could be outdated.

沐歌 2024-08-13 21:20:01

这意味着如果您想在某个元素上应用 float: 属性,则还必须向该元素应用 width: 属性

It means that if you want to apply a float: property on an element, you also have to apply a width: property to that same element

花落人断肠 2024-08-13 21:20:01

向没有声明或内置宽度(固有宽度)的元素添加宽度的原因是,浮动元素随后将扩展到父级的整个宽度,并且您会失去通过浮动它想要获得的内容。

The reason for adding width to elements with no declared or built-in width (intrinsic) is because the floated element will then expand to full width of the parent and you lose what you wanted to gain by floating it.

找回味觉 2024-08-13 21:20:01

从某种意义上说,这不是验证错误,不像您输入“funt”而不是“font”或忘记关闭括号。它只是告诉你你的 CSS 并没有真正的意义。

如果某个东西要像块元素默认那样占据容器宽度的 100%,那么浮动它有什么意义呢?

In a sense that isn't a validation error, not like you typed "funt" instead of "font" or forgot to close a bracket. It's just telling you that your CSS doesn't really make sense.

What's the point in floating something if it's going to take up 100% of the width of the container anyway, as block elements do by default?

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