css中下划线样式能设置长度吗

CSS中下划线样式能设置长度吗

能。

在css中可以通过设置文字元素的下边框来设置文字元素的下划线,只需要通过width元素设置文字元素的宽度,也即设置文字元素的下划线。

示例如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style type="text/css">
    .token1 {
    width: 100px;
    border-bottom: 1px solid black;
}
    .token2 {
    width: 200px;
    border-bottom: 1px solid black;
}
        </style>
</head>
<body>
    <div class="token1">下划线</div>
    <div class="token2">下划线</div>
</body>
</html>

输出结果:

def1cf52b2023046c0ff3dfc7c8f91b2

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容