How to put text on a CSS Triangle

前端 未结 2 1864
再見小時候
再見小時候 2021-01-07 01:59

I must be missing a simple step. I have made a triangle in CSS and I\'m trying to put text on top of the triangle. It works if I don\'t have the width:0; and

2条回答
  •  [愿得一人]
    2021-01-07 02:27

    Maybe try something like this :

    body{
      background: red;
    }
    
    .log{
      position: relative;
      border-bottom:100px solid transparent ;
      border-left:100px solid transparent;
      border-top: 180px solid black;
      border-right:100px solid transparent;
      display: inline-block;
      transition: all .25s ease;
    }
    
    .log:hover{
      border-top-color: rgba(255, 255, 255, .5);
    }
    
    .log:hover .login{
      color: #000;
    }
    
    .login{
      position: absolute;
      color: #fff;
      left: -50%;
      top: -90px;
      display: block;
      width: 200px;
      height: 180px;
      transform: translate(-50%,-50%);
      text-align: center;
      box-sizing: border-box;
      padding: 30px 0;
      transition: all .25s ease;
    }
    
      
    

提交回复
热议问题