我使用的CSS边界顶值的顺序是否重要? [英] Does it matter which order I use for my CSS border-top values?

查看:94
本文介绍了我使用的CSS边界顶值的顺序是否重要?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我看到不同作者使用的 border-top 属性时,他们都说用不同的方式。

When I see the border-top property used by different authors, they all say to use it a different way.

例如,在 http://www.w3schools.com/css/pr_border -top.asp 按照以下顺序定义:

For example, at http://www.w3schools.com/css/pr_border-top.asp it is defined in this order:

width style color

如果我以另一种方式定义,例如 color

If I define in another way, like color or style first, will I get problems?

推荐答案

首先,我会遇到问题吗?如果您在使用 border 速记标记时不使用正确的属性顺序。此外,你似乎被不同的属性顺序的定义抛出。

I'm assuming you are asking what the problems could be if you don't use the correct order of properties when using a border shorthand tag. Additionally you seem to be thrown of by different definitions of the order of properties.

我会引用 W3边框shorthands的CSS参考

'border'
    Value:      [ <border-width> || <border-style> || <'border-top-color'> ]

因此只有 $ c> border-top 速记是1.设置宽度,2.样式,3.颜色。 不正确

So the only correct way to use border-top shorthand is to 1. set the width, 2. style, 3. color. incorrect

正如保罗所指出的,双杠||表示属性可以以任何顺序出现,因此通常浏览器不会出现问题,无论以什么顺序向他们抛出。

As pointed out by Paul, the double bar "||" means that the properties can appear in any order, so usually browsers don't have a problem no matter what order you throw at them.

但是:我通常看到以 border-top:1px solid red; 的形式的定义 - 但是这可能只是最佳实践,但最终没有关系。

However: I usually see definitions in the form of border-top: 1px solid red; - but that might just be "best practice" but doesn't matter in the end.

这篇关于我使用的CSS边界顶值的顺序是否重要?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆