页面渲染
为了解决这个问题,我们给图片添加一个渐变的遮罩,就像图10-8那样,这样到达文字部分时,背景就变成了黑色,不会影响文字的显示,而且达到了由图片到底下列表颜色渐变的效果,非常美观。
这个效果主要靠我们的格式文件实现,我们先写我们熟悉的部分。
-
.list-top {
-
position: relative;
-
height: 100%;
-
}
-
.list-top::after {
-
content: " ";
-
display: block;
-
padding-top: 100%;
-
}
-
.top-info {
-
position: absolute;
-
bottom: 0;
-
width: 100%;
-
z-index: 3;
-
}
-
.top-img {
-
width: 100%;
-
height: 100%;
-
position: absolute;
-
}
-
-
.top-info-inner {
-
display: -webkit-box;
-
-webkit-box-align: center;
-
margin: 0 15px 25px;
-
color: #fff;
-
}
-
-
.top-info-text {
-
-webkit-box-flex: 1;
-
margin-right: 10px;
-
}
-
.top-info-title {
-
font-size: 24px;
-
line-height: 36px;
-
white-space: nowrap;
-
overflow: hidden;
-
}
-
.top-info-base {
-
font-size: 14px;
-
line-height: 20px;
-
}
复制代码
“::after”表示在“.list-top”后边添加,为了是在不修改布局文件的情况下,添加视图以达到美化的效果。
我们需要添加的遮罩为布局里“top—back”这部分,格式文件为:
-
.tl-top-b {
-
position: absolute;
-
bottom: 0;
-
width: 100%;
-
background-image: -webkit-linear-gradient(top,transparent,currentColor 80%);
-
}
-
.tl-top-b::after {
-
content: " ";
-
display: block;
-
padding-top: 60%;
-
}
复制代码
-webkit-linear-gradient(top,transparent,currentColor 80%)这行代码为我们建立了线性渐变的效果,这样我们的图片底部就会出现渐变为黑色的效果了。<