.bg_color {
width: 100vw; /* view width */
height: 100vh; /* view height */
padding: 1rem;
-webkit-box-sizing: border-box;
box-sizing: border-box;
/*
Create the diagonal line in the background by setting each color to take
up 50% of the space. Setting the break points to 49.9% and 50.1% will minimize
the jagged line that is created if gradient colors were to be set to 50%/50%.
*/
background-image: -webkit-gradient(linear, right bottom, left top, color-stop(49.9%, #000000), color-stop(50.1%, #1DA1F2));
background-image: -webkit-linear-gradient(bottom right, #000000 49.9%, #1DA1F2 50.1%);
background-image: -o-linear-gradient(bottom right, #000000 49.9%, #1DA1F2 50.1%);
background-image: linear-gradient(to top left, #000000 49.9%, #1DA1F2 50.1%);
}
<div class="bg_color">
<h1>Half Background</h1>
</div>
I want to set half background like this
在我的代码中,我想使用 colored颜色 代码添加一半的背景.我已经try 按照代码进行操作,但我不知道如何正确设置!