您的問題一個很乾淨的解決方案,具有4種文字重疊定位。
<div class="module top">
<h2>Skyscrapers</h2>
</div>
<div class="module mid">
<h2>Skyscrapers</h2>
</div>
<br style="clear: both;">
<div class="module cap">
<p>Skyscraper are really neat and stuff because they are tall.</p>
</div>
<div class="module lr">
<p>Skyscrapers sometimes have nicknames like jim or shim.</p>
</div>
CSS
@import url(https://fonts.googleapis.com/css?family=Roboto:400,900);
.module {
background:
linear-gradient(
rgba(0, 0, 0, 0.6),
rgba(0, 0, 0, 0.6)
),
url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/skyscrapers.jpg);
background-size: cover;
width: 300px;
height: 200px;
margin: 10px 0 0 10px;
position: relative;
float: left;
}
.module:hover{
background: rgba(1,222,123,0.3);
}
.top h2 {
color: white;
margin: 0;
padding: 20px;
}
.lr p {
font-family: 'Roboto', sans-serif;
position: absolute;
bottom: 20px;
left: 20px;
color: white;
margin: 0;
}
.mid h2 {
font-family: 'Roboto', sans-serif;
font-weight: 900;
color: white;
text-transform: uppercase;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
font-size: 2rem;
transform: translate(-50%, -50%);
}
.cap p {
padding: 20px;
color: white;
font: 12px Monaco, Mono-Space;
margin: 0;
}
所以肯定已經有這樣的一個答案。你在搜索過嗎?而不是搜索「文字圖像疊加」,搜索「圖像上的中心文字」。 –