::after实现下划线

  • 效果如下


    1675146899532.png
  • 废话不多说直接看代码


// =============html部分===============
<div class="meal-nav">
      <div class="layout-flex layout-flex-center">
              <span class="meal-nav-item meal-nav-item-active">
                    企业套餐
              </span>
              <span class="meal-nav-item">
                    个人套餐
              </span>
      </div>
</div>

// =============css部分===============
 .meal-nav {
     text-align: center;
     margin-bottom: 47px;
 }
 .meal-nav-item {
     width: 120px;
     height: 24px;
     font-size: 20px;
     font-family: Inter-Regular, Inter;
     font-weight: 400;
     color: #434E70;
     text-align: center;
     line-height: 24px;
     display: inline-block;
     cursor: pointer;
 }
 .meal-nav-item-active {
     font-size: 28px;
     font-weight: bold;
     color: #0088FF;
     position: relative;
 }
 .meal-nav-item-active:after {
     position: absolute;
     content: '';
     width: 20px;
     height: 4px;
     top: 40px;
     left: 50px;
     background: #0088FF;
     display: inline-block;
     border-radius: 20px;
 }
 .meal-nav-item:last-child {
     margin-left: 60px;
 }
.layout-flex {
    display: flex;
}
.layout-flex-center {
    justify-content: center;
}

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容