美文网首页
箭头div实现

箭头div实现

作者: 前端金城武 | 来源:发表于2022-02-21 21:28 被阅读0次

    需求如图


    1645450081(1).jpg
    <template>
        <div class="wrapper">
          <div class="top"  :class="actived ? 'actived' : ''"></div>
          <div class="content">
            <slot></slot>
          </div>
          <div class="bottom" :class="actived ? 'actived' : ''"></div>
        </div>
      </template>
      
      <script>
        export default {
          props: ['actived'],
          methods: {
            click() {
              
            }
          }
        }
      </script>
      
      
      <style lang="less">
      
      .wrapper {
        cursor: pointer;
        display: inline-block;
        padding-left: 5px;
        position: static;
        .top,
        .bottom {
          width: 200px;
          height: 15px;
          border: 2px solid grey;
        }
      
        .top {
          transform: skewX(30deg);
          transform-origin: left top;
          border-bottom: unset;
        }
      
        .top.actived, .bottom.actived {
          background: red;
        }
      
        .bottom {
          transform: skewX(-30deg);
          transform-origin: left bottom;
          border-top: unset;
        }
        .content {
          width: 200px;
          position: absolute;
          text-align: center;
          top: 0;
          z-index: 100;
      
          line-height: 50px;
        }
      }
      </style>
      
    

    相关文章

      网友评论

          本文标题:箭头div实现

          本文链接:https://www.haomeiwen.com/subject/aizilrtx.html