首页 > 解决方案 > 如何使下划线出现在移动视图中的第二行之后?

问题描述

我已经为公司名称实现了蓝色下划线的代码,但是当它在移动视图中时,蓝线出现在第一行。我怎样才能让那个开始出现在第二行?

我的 CSS 代码

 label {
  margin: 0;
  cursor: pointer;
  position: relative;
  text-decoration: none;
  color: $text-default-color;
  margin-right: 25px;

  @media #{$sm-and-less} {
    display: flex;
    justify-content: space-between;
  }

  &:after {
    @extend %nav-underline;
    @extend %ease;
  }

输出图像 输出图像

标签: htmlcsssass

解决方案


你可以这样做:

label {
  position: relative;
  display: block;
  padding-bottom: 8px;
  margin-bottom: 30px;
}

label::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  display: block;
  width: 40px;
  height: 4px;
  background-color: blue;
 }
<label>
  On one line Lorem ispum dolor sit amed
</label>

<label style="width: 100px;">
  On two lines Lorem ispum
</label>


推荐阅读