中央に寄せるためにはmarginの左右にautoを指定する。
marginにautoを指定するときは必ずwidthも併せて指定しましょう。
なお、上下のmarginにautoは指定できません。
style.css
.box {
width: 300px;
margin: 0 auto;
}
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 5 years have passed since last update.
中央に寄せるためにはmarginの左右にautoを指定する。
marginにautoを指定するときは必ずwidthも併せて指定しましょう。
なお、上下のmarginにautoは指定できません。
.box {
width: 300px;
margin: 0 auto;
}
Register as a new user and use Qiita more conveniently
Go to list of users who liked