简体   繁体   English

CSS扩展文本超链接及其下划线之间的空间

[英]CSS to Expand Space Between Text Hyperlink and Its Underline

Is there a way to expand the space between letters and underlines in text-based hyperlinks using CSS? 有没有办法使用CSS扩展基于文本的超链接中字母和下划线之间的空间?

The CSS I'm planning to use is: 我计划使用的CSS是:

.post-body a {
  text-decoration: underline;
}

My blog is hosted on Blogger and uses the Simple template - http://nickalive.blogspot.com 我的博客托管在Blogger上,并使用简单模板-http://nickalive.blogspot.com

No, not using standard text-decoration settings. 不,不使用标准的text-decoration设置。

What you can do is replace the underline with a pseudo-element which you can customise to your heart's content. 可以做的是将下划线替换为可以根据您的心脏内容进行自定义的伪元素。

 a { text-decoration:none; margin:1em; display: inline-block; position: relative; } a:after { content:""; position: absolute; left:0; bottom:-12px; /* changes distance from text */ width:100%; /* width of underline */ height:5px; /* height of underline */ background: red; /* color or underline */ } 
 <a href="#">My hyperlink</a> 

Text-Decoration @ MDN 文字修饰@ MDN

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

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