^^行きます。私は通常、<figure>
タグに<img>
と<div>
が含まれ、同じレベルにしたいというテキストを含むように設定します。
<figure>
<img src="http://stephboreldesign.com/wp-content/uploads/2012/03/lorem-ipsum-logo.jpg">
<div class="info">
Content goes here
</div> <!-- /.info -->
</figure>
およびCSSので<figure>
タグは、相対位置を有し、.info
はtop: 0; bottom: 0; left: 0; right: 0
固定width
と絶対配置を有します。
figure {
margin: 3px;
display: inline-block;
position: relative;
}
figure .info {
width: calc(100% - 30px);
height: calc(100% - 30px);
position: absolute;
top: 0;
left: 0;
opacity: 0;
transition: opacity 300ms;
background-color: rgba(233,233,233, .8);
color: #333;
margin: 15px;
text-align: center;
}
は、ケースであなたがflexbox
ポジショニングで追加<div>
を使用することができ.info
コンテナにテキストだけの1行以上を追加することもできます。
あなたは完全な例を見ることができるhere
変換:翻訳(-50%、-50%);はSafari 8以下では動作しません。 – nashcheez
これをサポートしたい場合は、以下も含める必要があります。 -webkit-transform:translate(-50%、-50%); –