Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法使用 CSS/JS 以自定义方式为一大块文本下划线?我不知道文本会是什么,它可以有换行符,所以我不能采用使用边框底部的常规方式。
抱歉,如果问题不清楚。关键词是“定制”。像不同颜色的虚线或一些花哨的星星,或其他什么。我们可以使用背景或边框底部属性来做到这一点,但仅限于单行文本。如果有换行符,它将仅应用于底部。我正是这个意思。
该text-decoration属性是您正在寻找的。如果您将类underlined分配给要为其文本添加下划线的封闭元素,您的 CSS 将如下所示:
text-decoration
underlined
.underlined { text-decoration: underline; }