Home > Net >  Css linear gradient showing zigzag
Css linear gradient showing zigzag

Time:03-25

Trying to make a background color for my body element using linear gradient but it ends up showing a zigzag

I tried using this code, for example

Body{
    background: linear-gradient(45deg, Blue 50%, red 50%)
}

I got this:

But this is what I was expecting background image

CodePudding user response:

first give the body a height:100vh; and replace the 45deg with to bottom left because it won't work well when you shrink the screen

*{
  margin:0;
  padding:0;
  box-sizing: border-box;
}
body{
  height:100vh;
  background-image: linear-gradient(to bottom left, red 50%, blue 50%)
}

  • Related