0826 CSS: どのブラウザでもcontainerが真ん中に表示される方法2つ
1、%指定
container{
top: 50%;
left: 50%;
margin-top: -○○px;
margin-left: -○○px;
}
top50%指定でcontainerの左の角がブラウザの上下のど真ん中に表示されるため、
その後containerのheightの半分のpx数をmargin-topでマイナス指定する事で
上下のど真ん中に配置される。
左右に対しても同じように指定する事で、containerはブラウザの中央に表示される。
2、0を使った指定
container{
width: ○○px;
height: ○○px;
top: 0;
right: 0;
bottom: 0;
left: 0;
margin: auto;
}
containerのwidthとheightを指定するだけ。