将元素设置为
inline-block不会受到下划线的影响:
a { text-decoration: underline;}a #myspan { color: black; display:inline-block;}a:active #myspan { color: grey;}a:visited #myspan { color: yellow;}a:hover #myspan { color: red;}<a href="#">A link <span id="myspan">some additional information</span></a>
请注意,文本修饰不会传播到浮动和绝对定位的后代,也不会传播到原子内联级别后代(例如内联块和内联表)的内容。
要删除文本和跨度之间的小空间,您可以摆脱空白并使用较小的边距:
a { text-decoration: underline;}a #myspan { color: black; display:inline-block; margin-left:4px;}a:active #myspan { color: grey;}a:visited #myspan { color: yellow;}a:hover #myspan { color: red;}<a href="#">A link<span id="myspan">some additional information</span></a>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)