/* 示例代码:为文本添加下划线 */
/* 方法1:使用 text-decoration 属性 */
p.underline {
text-decoration: underline;
}
/* 方法2:使用 border-bottom 属性 */
p.border-underline {
border-bottom: 1px solid black;
}
/* 方法3:使用 ::after 伪元素 */
p.after-underline::after {
content: '';
display: block;
width: 100%;
height: 1px;
background-color: black;
margin-top: 2px;
}
text-decoration: underline;
border-bottom: 1px solid black;
border-bottom
可以更灵活地控制下划线的样式(如颜色、粗细等)。适合需要自定义下划线样式的场景。::after 伪元素
::after
伪元素创建一个额外的元素来模拟下划线效果。这种方式可以实现更复杂的下划线样式,比如带间距或动画效果。下一篇:css 兄弟元素
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站