How to create an triangle shape (fixed height, width=100%) with background

后端 未结 5 1248
你的背包
你的背包 2021-01-15 15:10

I have a graphic background, and I need to display a colored triangle in the top left corner (independing the resolution).

Can I create a triangle shaped element us

5条回答
  •  时光说笑
    2021-01-15 15:49

    Because you can't create a border which has a percentage, try using vw (viewer width) instead. So:

    .triangle{
       width: 0;
       height: 0;
       border-bottom: 600px solid blue;
       border-left: 100vw solid transparent;
      }
    

提交回复
热议问题