【发布时间】:2020-06-01 15:19:47
【问题描述】:
我正在尝试使用图像制作漂亮的背景,但我希望图像重复填充屏幕,不透明度设置为 0.5 并旋转 45 度。我已经尝试了很多方法来实现这一点,但都没有运气。有人有什么想法吗?
在这个 Codepen 中,我将图像旋转且不透明,但无法让背景重复工作。
.background {
height: 500px;
width: 500px;
position: relative;
display: inline-block;
padding: 100px;
border: black 3px solid;
}
.background::before {
content: "";
position: absolute;
overflow: hidden;
width: 100px;
height: 100px;
left: 0;
top: 0;
z-index: -1;
opacity: 0.5;
background: url(https://cambridgewords.files.wordpress.com/2019/11/funny.jpg);
background-size: contain;
transform: rotate(45deg);
background-repeat: repeat;
opacity: 0.5;
}
<span class='background'>HElloWorld</span>
【问题讨论】:
标签: html css background-image