gpt4 book ai didi

html - CSS - 封面图片上的渐变?

转载 作者:太空狗 更新时间:2023-10-29 16:51:26 24 4
gpt4 key购买 nike

如何在封面图片上添加渐变层?

例如:

header {
position: relative;
height: 300px;
background-repeat: no-repeat;
background-position: center bottom;
background-image: url('http://www.planwallpaper.com/static/images/Free-Wallpaper-Nature-Scenes.jpg');
background-size: cover;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
}

h1 {
margin: 0;
padding: 100px 0;
font: 44px "Arial";
text-align: center;
}

header h1 {
color: white;
}
<header>
<h1>Header Content</h1>
</header>

<section>
<h1>Section Content</h1>
</section>

我想要在该图像上使用此渐变:

background-image: linear-gradient(to bottom right, #002f4b, #dc4225);

这可能吗?

最佳答案

使用具有透明度和双背景图像rgba

header {
position: relative;
height: 300px;
background-repeat: no-repeat;
background-position: center bottom;
background-image: linear-gradient(to bottom right, rgba(0, 47, 75, .5), rgba(220, 66, 37, .5)), url('http://www.planwallpaper.com/static/images/Free-Wallpaper-Nature-Scenes.jpg');
background-size: cover;
border-bottom-left-radius: 50%;
border-bottom-right-radius: 50%;
}
h1 {
margin: 0;
padding: 100px 0;
font: 44px "Arial";
text-align: center;
}

header h1 {
color: white;
}
<header>
<h1>Header Content</h1>
</header>

<section>
<h1>Section Content</h1>
</section>

关于html - CSS - 封面图片上的渐变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44860850/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com