我在HTML中具有CSS样式。从SQL图像生成响应图像网格。我正在尝试创建一个书签叠加层以添加为收藏夹。
我尝试了许多教程。 另外,已经复制了图像DIV并更改了Z位置以放置在图像上方,但根本看不到覆盖图像。
样式表:
#gridview {
text-align:center;
}
div.image {
margin: 10px;
display: inline-block;
position: relative;
z-index: 1;
}
div.image img {
width: 100%;
height: auto;
position: relative;
border: 1px solid #ccc;
z-index: 1;
}
div.image img:hover {
box-shadow: 0 5px 5px 0 rgba(0,0,0,0.32), 0 0 0 0px rgba(0,0,0,0.16);
z-index: 1;
position: relative;
}
div.bookmark {
margin: 10px;
display: inline-block;
position: absolute;
z-index: 3;
}
div.bookmark img {
width: 100%;
background-image: url("https://images.justwatch.com/static/compile_jw/assets/ribbon-filled.png");
height: auto;
position: absolute;
z-index: 3;
}
div.bookmark img:hover {
box-shadow: 0 5px 5px 0 rgba(0,0,0,0.32), 0 0 0 0px rgba(0,0,0,0.16);
z-index: 3;
position: absolute;
}
#grid {
margin-bottom:30px;
}
@media screen and (min-width: 1224px) {
div.image {
width: 154px;
}
}
media screen and (min-width: 1044px) and (max-width: 1224px) {
div.image {
width: 154px;
}
}
@media screen and (min-width: 845px) and (max-width: 1044px) {
div.image {
width: 154px;
}
}
PHP / HTML页面:
var tbl_body = "";
for (var i = 0; i < data.length; i++)
{
var tbl_row = "";
var t = i;
tbl_row += ("<div class='image'><a href='link/" + data[i]+ "'><IMG SRC='link/"+ data[i].poster +"'></a><div class='bookmark'></div> ");
tbl_row += ("</div>");
tbl_body += tbl_row
}
return tbl_body;
结果应为海报图像,并在每个海报的顶角覆盖书签图像。