:root {
--red: rgba(255, 0, 0, 1);
--white-low-opacity: rgba(255, 255, 255, .3);
--white-high-opacity: rgba(255, 255, 255, .7);
--black-low-opacity: rgba(0, 0, 0, .3);
--black-high-opacity: rgba(0, 0, 0, .7);
}
div {
\t width: 100px;
\t height: 100px;
\t margin: 10px;
}
.element1 {
\t background:
linear-gradient(var(--white-low-opacity), var(--white-low-opacity)) no-repeat,
\t linear-gradient(var(--red), var(--red)) no-repeat;
}
.element2 {
\t background:
linear-gradient(var(--white-high-opacity), var(--white-high-opacity)) no-repeat,
\t linear-gradient(var(--red), var(--red)) no-repeat;
}
.element3 {
\t background:
linear-gradient(var(--black-low-opacity), var(--black-low-opacity)) no-repeat,
\t linear-gradient(var(--red), var(--red)) no-repeat;
}
.element4 {
\t background:
linear-gradient(var(--black-high-opacity), var(--black-high-opacity)) no-repeat,
\t linear-gradient(var(--red), var(--red)) no-repeat;
}
<div class="element1">hello world</div>
<div class="element2">hello world</div>
<div class="element3">hello world</div>
<div class="element4">hello world</div>
所以聽起來像你應該使用多個元素.... – epascarello
我不喜歡,但它似乎我可能必須... :( – JoshyRobot