-1

I'm looking for a way to set the background-color of an HTML document with 2 colors instead of one. This kind of question has been asked before, but I want to set the two colors height-wise (split vertically) rather than width-wise.

3 Answers3

1

I'm not sure what you found, but you can use linear-gradient for this:

body {
height: 100vh;
background: linear-gradient(0deg, rgba(204,0,0,1) 50%, rgba(0,212,255,1) 50%); 
}
<body>
</body>

You just need to set the angle to 0 deg

disinfor
  • 10,865
  • 2
  • 33
  • 44
0

You can define css like

#grad1 {
  height: 100%;
  background-color: red; /* For browsers that do not support gradients */
  background-image: linear-gradient(orange, white, green);
}

and use this css in your div

<div id="grad1"></div>

Note: change color code and height as per your need

Deep
  • 11
  • 1
  • 1
0

you can do simply like this.

<div>
        <div className='first'>
          hello
        </div>
        <div className='second'>
          hi
        </div>
      </div>

Css:

.first{
  height: calc(50vh);
  background: blue;
}
.second{
  height: calc(50vh);
    background: red;
}