Search code examples
htmlcsslinear-gradients

Css linear gradient showing zigzag


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


Solution

  • 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%)
    }