DIV 區塊橫向居中
在IE瀏覽器 body{text-align:center;} 這樣就可以使區塊橫向置中,但是在Mozilla瀏覽器卻沒有效果,
必須再針對居中層加入 margin-right: auto;margin-left: auto; 例如:
body{text-align: center;}
#divs{margin-right: auto;margin-left: auto;}
<div id="divs" >這是一個相容各瀏覽器的置中區塊</div>
但這樣會連文字都置中了
你可以在為div指定文字對齊方式,例如:
text-align:left; /*文字靠左對齊*/
還有一種更簡單的方式,但是對於IE5/win沒有效果
#divs{margin : 0px auto;}
<div id="divs" >這是一個置中區塊但IE5/Win無法置中</div> <div><center>
1234567
</center></div> 目前html5 不支援
<div>[color=Red]<center>[/color]
1234567
[color=Red]</center>[/color]</div>
[color=Red]</center>[/color]此語法不支援
使用後會影響未來語法上的架構和衝突
更改語法為
[color=Red]<div style="width:100%;">
<div style="margin: atuo 0;">
文字版塊皆置中[/color]
</div>
</div> <html>
<meta charset=big5">
<body style="margin:0px; overflow:hidden;" bgcolor="#7cd9f1">
<center>
<div>
<a href="https://www.youtube.com/embed/E0JF5dwRfRQ" target="x" >勝利大遊行在北京</a>
</div>
<iframe width="1920" height="960" src="https://www.youtube.com/embed/TYRuFAJMGZo" name="x"></iframe>
</center>
</body>
</html>
頁:
[1]