私は最初に大きな画像を持つ画像のグリッドを作成したいと思います。それから、グリッドは4(各行に2)です。そしてその下に、一度に4つの画像の行があります。フレックスボックスを使用してメイン画像を完全に囲むイメージグリッドを作成する方法は?
ゆるやかにthis designに基づいています。
フレックスボックスは、おそらくこれを釘付けにすることができると思います。
はほとんどが、私はそれが必要なものを行い、この
.image-grid {
display: flex;
flex-wrap: wrap;
}
img {
width: 100%;
}
.image-grid > div:first-child {
flex-basis: 50%;
}
.image-grid > div {
flex-basis: 25%;
}
私はCSSでこれ
<div class="image-grid">
<div>
<img src="https://unsplash.it/1024/1024">
</div>
<div>
<img src="https://unsplash.it/1000/800">
</div>
<div>
<img src="https://unsplash.it/1100/1000">
</div>
<div>
<img src="https://unsplash.it/1120/1000">
</div>
<div>
<img src="https://unsplash.it/1130/1024">
</div>
<div>
<img src="https://unsplash.it/1101/1024">
</div>
<div>
<img src="https://unsplash.it/1020/1024">
</div>
<div>
<img src="https://unsplash.it/1021/1024">
</div>
<div>
<img src="https://unsplash.it/1002/1024">
</div>
<div>
<img src="https://unsplash.it/1003/1024">
</div>
<div>
<img src="https://unsplash.it/1004/1024">
</div>
<div>
<img src="https://unsplash.it/1005/1024">
</div>
</div>
のようないくつかのマークアップを持っていると言います。 Codepen here。
私はそれは厳しいですので、それは宇宙だ代わりに、各画像が収まるように現在の2
- ディスプレイ4枚の画像、...しかし固定された2つのものが必要グリッド(画像の周りにスペースはありません)。私は
object-fit
CSSプロパティを使用することを考えていますが、まだ動作していません。
ありがとうございます。
コードが更新されました。とにかくあなたの質問は1つの注目画像の周りのすべての画像をラップするようなものでした。最後のコードで同じことをしました。最近のコメントで更新されました。 –