简体   繁体   English

关于编写有效的 CSS 2.1 样式表且无错误的 2 个问题

[英]2 questions on writing a valid CSS 2.1 stylesheet without errors

I have two questions on how to write a correct/without error CSS 2.1 stylesheet:关于如何编写正确/无错误 CSS 2.1 样式表,我有两个问题:

  1. The CSS validator says to me that overflow-y: scroll is not supported on CSS 2.1. CSS 验证器告诉我overflow-y: scroll在 CSS 2.1 上不受支持。 So, what can I use for the same effect?那么,我可以用什么来达到同样的效果呢?
  2. I have something like 500 warnings that say Same colors for color and background-color in two contexts.error and.contact3 (about different classes, of course), what does it mean?我有类似 500 条警告,它们在两个 contexts.error 和.contact3 (当然,关于不同的类)中的颜色和背景颜色相同 colors ,这是什么意思? And how can I resolve this?我该如何解决这个问题?

Thanks谢谢

1. CSS validator say to me that overflow-y: scroll is not supported on CSS 2.1. 1. CSS 验证器对我说,在 CSS 2.1 上不支持溢出-y:滚动。 So, what can I use for the same valid effect?那么,我可以使用什么来获得相同的有效效果?

They're not valid because they were introduced in CSS3.它们无效,因为它们是在 CSS3 中引入的。 In CSS 2.1, you can only set overflow for both horizontal and vertical at the same time.在 CSS 2.1 中,您只能同时为水平和垂直设置overflow

Most browsers support overflow-y now, so I would worry less about 2.1 validation (as your CSS will be valid with a CSS 3 validator).大多数浏览器现在都支持overflow-y ,所以我不太担心 2.1 验证(因为您的 CSS 将与 CSS 3 验证器一起有效)。 You can use overflow: auto as a fallback for unsupported browsers.您可以使用overflow: auto作为不支持的浏览器的后备。

2. I have somethings like 500 warning that say Same colors for color and background-color in two contexts.error and.contact3 (about different classes, of course), what does it means? 2. 我有类似 500 的警告,在两个 contexts.error 和.contact3 (当然,关于不同的类)中说颜色和背景颜色相同的 colors,这是什么意思? And how can I resolve this trouble?我该如何解决这个麻烦?

The problem is what it says it is.问题是它所说的那样。 If you have the background-color the same as the color , it generates a warning because any text will not be visible to the user.如果您的background-colorcolor相同,它会生成警告,因为用户看不到任何文本。 If that is your intention, you would be better off setting the foreground color to transparent on those elements:如果这是您的意图,最好将这些元素的color设置为transparent

.error {
    color: transparent;
}

Beyond that, though, warnings are just warnings and your CSS is valid with them.但是,除此之外,警告只是警告,您的 CSS 对它们有效。 Warnings exist to let you know that you may have made a mistake.存在警告,让您知道您可能犯了错误。

You can use overflow:auto;您可以使用overflow:auto; This will add scrollbars when needed.这将在需要时添加滚动条。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM