コーディングデザインで画面の端からのデザインがありましたので、そのデザイン方法。
先にコードから
<div class="container">
<div class="children">
</div>
</div>
.container{
max-width: 1200px;
margin: 0 auto;
padding: 30px;
}
.children{
max-width: calc(100vw - (50% - (1200px / 2)));
width: calc(100% - 0px);
}
上のコードは最大幅が1200pxの時の例
(50% - (1200px / 2))
で左右余白の半分の幅が求まり-100vw
することで、範囲が画面端からコンテナ端まで伸びます。
コンテナの中で幅を狭めたいときは.children
のwidth
にその値を引く。
下の参考記事はより詳しく書いています。