0
3列のフレックスボックスレイアウトを作成しました。最初に3つのフレックスボックスレイアウトが作成され、最初にキャプションが付いたイメージが表示されます。何らかの理由で、このキャプション(.photo-caption
)は、その下にではなく、親要素の(.card-cont
)パディング内に表示されます。このキャプションのスタイルを、期待通りにプッシュダウンするにはどうすればよいですか?Divが親要素のパディング内に表示されます。
レイアウトサンプル:
<div class="card-cont">
<h2>Symphonic masters 1 Subscription</h2>
<div class="card">
<div class="card-img">
<a href="#"><img src="https://img.buzzfeed.com/buzzfeed-static/static/2014-05/enhanced/webdr06/14/7/enhanced-21657-1400066093-5.jpg" /></a>
<div class="photo-caption">
Photo by Humberto Howard
</div>
</div>
<div class="card-info">
<p>
Cu cum quem eros periculis, volutpat tractatos accommodare eu has, ex singulis assueverit usu. Cu cum quem eros periculis, volutpat tractatos accommodare eu has, ex singulis assueverit usu.
</p>
</div>
<div class="card-links">
<div class="button-cont">
<a class="button blue-button" href="#">Subscribe</a>
</div>
</div>
</div>
</div>
サンプルCSS:
section.events-wide .card-cont {
padding: 30px 0;
}
section.events-wide .card-cont > h2 {
padding-bottom: 15px;
font-size: 1.75em;
}
section.events-wide .card-cont .card {
display: flex;
height: 295px;
background-color: grey;
}
section.events-wide .card-cont .card .card-buy-button,
section.events-wide .card-cont .card .card-img,
section.events-wide .card-cont .card .card-info,
section.events-wide .card-cont .card .card-learn-more,
section.events-wide .card-cont .card .card-links {
flex-basis: 33.3%;
}
section.events-wide .card-cont .card .card-img a {
display: inline-block;
height: 100%;
width: 100%;
}
section.events-wide .card-cont .card .card-img a img {
object-fit: cover;
height: 100%;
width: 100%;
}
section.events-wide .card-cont .card .card-info,
section.events-wide .card-cont .card .card-learn-more,
section.events-wide .card-cont .card .card-links {
padding: 30px 2%;
}
section.events-wide .card-cont .card .card-info p a,
section.events-wide .card-cont .card .card-learn-more p a,
section.events-wide .card-cont .card .card-links p a {
font-size: 1.1em;
}
section.events-wide .card-cont .card .card-info {
text-align: left;
}
section.events-wide .card-cont .card .card-info h1,
section.events-wide .card-cont .card .card-info h2 {
display: block;
flex-flow: row nowrap;
padding: 5px 0;
line-height: 1.2;
}
section.events-wide .card-cont .card .card-info h1 {
font-size: 1.5em;
}
section.events-wide .card-cont .card .card-info h2 {
font-size: 1.1em;
}
section.events-wide .card-cont .card .card-buy-button .button-cont,
section.events-wide .card-cont .card .card-links .button-cont {
padding-bottom: 30px;
}
section.events-wide .card-cont .card .card-buy-button .button-cont .button,
section.events-wide .card-cont .card .card-links .button-cont .button {
display: inline-block;
padding: 10px 60px;
font-size: 1.2em;
}
の作業のデモ:http://codepen.io/ourcore/pen/jyBbEv。
。画像を4:3のアスペクト比に保つには、これらの高さが必要です。あなたはこれを回避する方法を考えることができますか? –
心配しないでください.JS内で 'img'の高さを動的に設定する解決策が見つかりました。ありがとう! –
@MarioParra sweet! np。 –