.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>
我想像這樣設定半背景
在我的代碼中,我想使用顏色代碼添加一半的背景,我嘗試按照代碼進行操作,但我不明白如何正確設定它!
uj5u.com熱心網友回復:
如果您真的想通過 HTML 設定它 - 它可能如下所示:
<div style="width: 300px; height: 300px; background-image: linear-gradient(to left, white 0%, white 100%), radial-gradient(white 60%, transparent 60%), linear-gradient(to left, red 0%, #1DA1F2 100%); background-position: 120px 193px, -30px 170px, 0; background-repeat: no-repeat"></div>
uj5u.com熱心網友回復:
我希望這是你的發現
div {
width: 100vw;
height: 100vh;
position: relative;
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#6b43fc 0,6b4dc2 100 */
background: #6b43fc; /* Old browsers */
background: -moz-linear-gradient(left, #6b43fc 0%, #6b4dc2 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(left, #6b43fc 0%,#6b4dc2 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right, #6b43fc 0%,#6b4dc2 100%); /* W3C, IE10 , FF16 , Chrome26 , Opera12 , Safari7 */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6b43fc', endColorstr='#6b4dc2',GradientType=1 ); /* IE6-9 */
}
div::after {
position: absolute;
content: '';
top: 50%;
left: 0;
right: 0;
bottom: 0;
background: #000;
border-top-left-radius: 80px 40px;
}
<div></div>
uj5u.com熱心網友回復:
如果您使用帶有半徑的白色覆寫層作為白色部分:
div {
width: 300px;
height: 150px;
position: relative;
/* Permalink - use to edit and share this gradient: https://colorzilla.com/gradient-editor/#6b43fc 0,6b4dc2 100 */
background: #6b43fc; /* Old browsers */
background: -moz-linear-gradient(left, #6b43fc 0%, #6b4dc2 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(left, #6b43fc 0%,#6b4dc2 100%); /* Chrome10-25,Safari5.1-6 */
background: linear-gradient(to right, #6b43fc 0%,#6b4dc2 100%); /* W3C, IE10 , FF16 , Chrome26 , Opera12 , Safari7 */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#6b43fc', endColorstr='#6b4dc2',GradientType=1 ); /* IE6-9 */
}
div::after {
position: absolute;
content: '';
top: 50%;
left: 0;
right: 0;
bottom: 0;
background: #fff;
border-top-left-radius: 80px 40px;
}
<div></div>
我無法重現準確的曲線,但您可以border-top-left-radius: H V在 H 是水平方向而 V 是垂直半徑的位置進行調整。
要了解更多資訊,請查看此鏈接。
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/477738.html
