Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@heroyct

imageを2列で並び、真ん中にする方法

More than 3 years have passed since last update.

やりたいこと

画像を2列に並ぶ
画像の高さは縦横の比率で自動調整
画像のリンクはパーツのどこでも押せること

サンプルコード

説明

css
display: flex;
flex-wrap: wrap;

flexを使って、改行を入れる

css
&__column_2 {
  width: 46%;
  margin: 5px 2%;
}

2列なので、margin-left margin-rightを2%にして、widthを46%にする

css
&__link {
  display: table;
  min-height: 100px;
  height: 100%;
}

画像は高さは可変なので、画像の高さと合わせる、画像の高さが100px以下の場合は、100pxにして押しやすくする

css
&__image_container {
  display: table-cell;
  vertical-align: middle;
}

画像を真ん中にする

css
&__image {
  width: 100%;
  height: auto;
  max-height: 150px;
}

画像の幅はdivの幅と同じにして、高さは自動調整

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
heroyct
medley
医療ヘルスケア分野の課題を解決する

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?