大纲:none VS 大纲:0
outline: none VS outline: 0
我正在阅读 this question on disabling the dashed borders around <a>
links. Some answers used outline: none
, while some 使用 outline: 0
使用outline: none
和outline: 0
有什么区别吗?
根据MDN:
The CSS outline
property is a shorthand property for setting one or more of the individual outline properties outline-style
, outline-width
and outline-color
in a single declaration
所以当你将outline
设置为none
或0
时,你实际上是在告诉浏览器设置3个属性(outline-style
、outline-width
和outline-color
)
我使用 Firefox Developer Tools 来找出区别:
如您所见,它们都使用默认文本颜色作为 outline-color
,并且它们都将 outline-style
设置为 none
。唯一的区别是 outline-width
:
- 当
outline
为0
时,outline-width
为0px
- 当
outline
为none
时,outline-width
为medium
这是两者之间的唯一区别。您可以使用任何一个,它们都将以相同的方式显示(因为 outline-style
是 none
,轮廓的宽度无关紧要)。
我正在阅读 this question on disabling the dashed borders around <a>
links. Some answers used outline: none
, while some 使用 outline: 0
使用outline: none
和outline: 0
有什么区别吗?
根据MDN:
The CSS
outline
property is a shorthand property for setting one or more of the individual outline propertiesoutline-style
,outline-width
andoutline-color
in a single declaration
所以当你将outline
设置为none
或0
时,你实际上是在告诉浏览器设置3个属性(outline-style
、outline-width
和outline-color
)
我使用 Firefox Developer Tools 来找出区别:
如您所见,它们都使用默认文本颜色作为 outline-color
,并且它们都将 outline-style
设置为 none
。唯一的区别是 outline-width
:
- 当
outline
为0
时,outline-width
为0px
- 当
outline
为none
时,outline-width
为medium
这是两者之间的唯一区别。您可以使用任何一个,它们都将以相同的方式显示(因为 outline-style
是 none
,轮廓的宽度无关紧要)。