我试图制作响应方形图像网格,每个网格由9个图像组成。
我只是使用简单的自举网格布局来制作网格 -
function clickCallback(value) {
return () => alert('Hello ' + value);
}
我需要在(绝对定位)每个方格网格上添加叠加灰色低不透明度方块,以在每个网格的中心添加h2文本。我如何继续使用它,因为网格没有特定的高度?
答案 0 :(得分:1)
你的意思是这样吗?
<!DOCTYPE HTML>
<html>
<head>
<style>
body {
height: 100%;
display: flex;
justify-content: center;
}
.grid {
width: 80%;
height: 100%;
border: 1px solid red;
position: relative;
}
.row {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.item {
width: 30%;
height: 100px;
border: 1px solid blue;
}
.grid:after {
content: "Heading Two Title"; /*allow to show up*/
width: 100%;
height: 100%; /*cover grid area*/
position: absolute;
top: 0;
left: 0; /*make it stay on the grid*/
background-color: #a0a0a0; /*instead of opacity choose a light gray color*/
z-index: -1; /*place behind so as not to cover the grid elements*/
display: flex;
justify-content: center;
align-items: center;
font-size: 3em; /*make as big as needed*/
}
</style>
</head>
<body>
<div class="grid">
<div class="row">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div class="row">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<div class="row">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
</div><!-- /grid -->
</body>
</html>
&#13;