css - 在 CSS 中使用具有线性渐变属性的 3 种颜色
问题描述
我想在下面的 CSS 中得到这个结果
有 3 种背景颜色。灰色、深灰色和黑色。在查看谷歌时,我必须使用该属性linear-gradient
,但我不知道如何获得我的示例中的结果。
我被困住了,我现在有这个
background-image: linear-gradient(grey, black);
body{
padding: 0;
margin: 0;
}
.wrapper{
display: flex;
}
.background-wrapper{
padding: 10px 10px 0px 10px;
width: 290px;
height: 170px;
background-image: linear-gradient(grey, black);
color: white;
text-align: center;
}
.img-box{
position: relative;
top: 10px;
}
.title{
font-size: 24px;
margin-top: 10px;
color: white;
}
.text{
font-size: 14px;
color:white;
margin: 20px;
}
<div class="wrapper">
<div class="background-wrapper">
<img class="img-box" src="https://zupimages.net/up/20/13/qjqq.png" alt="img-01">
<div class="title">Planning & Strategy</div>
<div class="text">a major breakthrough that we provide to our investors. and with a great marketing strategy.</div>
</div>
<div class="background-wrapper">
<img class="img-box" src="https://zupimages.net/up/20/13/zsrk.png">
<div class="title">Planning & Strategy</div>
<div class="text">a major breakthrough that we provide to our investors. and with a great marketing strategy.</div>
</div>
<div class="background-wrapper">
<img class="img-box" src="https://zupimages.net/up/20/13/gw1j.png">
<div class="title">Planning & Strategy</div>
<div class="text">a major breakthrough that we provide to our investors. and with a great marketing strategy.</div>
</div>
</div>
解决方案
只需为每个 .background-wrapper div 添加一些特定的类。或者可以这样做:
.background-wrapper:nth-child(1) {background-color: #5a5a5a;}
.background-wrapper:nth-child(2) {background-color: #4a4a4a;}
.background-wrapper:nth-child(3) {background-color: #3e3e3e;}
并删除
background-image: linear-gradient(grey, black);
推荐阅读
- php - PHP数组仅显示for循环中的最后一项
- excel - 如何使用 VBA 将一个工作簿中的多个表复制到新工作簿?
- angular - 如何更改 Angular Material 表中的滚动条样式?
- javascript - 如何防止 Chromes 自动填充弄乱我的 vuetify 登录表单?
- android - 无法从 android 发出 WritableMap 数组到 react-native
- javascript - 只有 Firefox 类型错误:“尝试获取资源时出现网络错误。”
- json - kubectl patch:是否可以在单个补丁执行中向数组添加多个值
- python - Python os.startfile 在 ubuntu 中不起作用
- python - Python & Discord.py,离开命令
- c# - json文件中的凭据未发布