这个css怎么写

clipboard.png

这个分类类目的这个图形 css怎么写 我的方法是boder-bottom加一个相对定位的伪类

有没有好的思路

阅读 2.4k
4 个回答

利用border以及:after实现, 为了观看效果方便,以下demo线条宽度设定为2px.
在线预览

html >>>>>>

<div class='treeline'></div> 

css >>>>>>

.treeline {
  display: inline-block;
  width: 100px;
  height: 26px;
  padding: 12px 0;
  box-sizing: border-box;
  border-left: 2px solid #888;
}
.treeline:after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: #888;
}

竖线用border,横线用before

    .list-ui{
      position: relative;
      margin-left: 5px;
      padding-left: 45px;
      border-left: 1px solid #ccc;
    }
    .list-ui:before{
      position: absolute;
      top: 50%;
      left: 0;
      margin-top: -0.5px;
      content: '';
      display: block;
      width: 40px;
      height: 1px;
      background: #ccc;
    }

clipboard.png

我有个大胆的想法~,用::before 和 ::after组在一起

声明一个class border写一条横线 在用伪类写个横线然后旋转90度 移动下位置 完事
然后这个class就可以复用了~~

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题