I want to position a css triangle as a background

后端 未结 3 587
萌比男神i
萌比男神i 2021-01-07 05:51

I want to build the following layout:

Preferable i want only use css for that. But even with an background-image i wouldn\'t know how to build it. I searche

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-07 06:34

    This should get you close, and illustrates a CSS only approach:

    * {
      margin: 0;
      padding: 0
    }
    
    body {
      background: #ccc;
      min-height: 500px;
    }
    
    div {
      width: 0;
      height: 0;
      margin: 0px auto;
      border: 200px solid transparent;
      border-top-color: grey;
    }
    
    a {
      display: block;
      background: blue;
      color: white;
      padding: 5px 10px;
      width: 200px;
      margin: 0px auto;
      position: relative;
      top: -200px;
      text-align: center;
      text-decoration: none;
    }
    link

提交回复
热议问题