Is it possible to have a non-rectangular div?

前端 未结 10 1975
滥情空心
滥情空心 2021-01-11 14:26

I need to shape ONE div tag in the following shape:

Is it possible to make it cross browser? I don\'t necessarily need rounded

10条回答
  •  时光取名叫无心
    2021-01-11 14:53

    A one div solution using pseudo elements:

    /* relevant styles for shape */
    .tab {
      border-top-left-radius: 0px;
      margin-left: 100px;
    }
    
    .tab:before {
      content:"";
      display: block;
      position: relative;
      height: 50px;
      width: 50px;
      right: 52px; /* width + border width */
      top: -2px;
      background-color: white;
      border: inherit;
      border-right-width: 0px;
      border-top-left-radius: 5px;
      border-bottom-left-radius: 5px;
    }
    
    /* styles to look like example */
    div{
      box-sizing: border-box;
      background-color: white;
      border: 2px solid red;
      height: 100px;
      width: 200px;
      border-radius: 5px;
    }
    
    div:hover {
      border-color: green;
    }

提交回复
热议问题