作者qazsd ( )
看板Web_Design
標題[問題] 第二層Div的文字置中
時間Wed Oct 19 17:56:18 2016
<div id="div1" class="test" style="backgroud>
<div id="div2">This is the word</div>
</div>
想請教要讓div2的文字水平方向是置放在div1的中間
然後垂直方向是低於div1 200px
CSS該怎麼下才好?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 59.124.165.66
※ 文章網址: https://www.ptt.cc/bbs/Web_Design/M.1476870984.A.FA4.html
→ nottt: 不知道你要的是不是這樣,利用margin讓div2低於div1 200px 10/19 20:06
推 steven11329: div2 margin:auto; margin-top:200; 10/20 14:35
→ steven11329: 忘記加px 10/20 14:35
推 steven11329: 不過你的div1要指定寬度才有效 10/20 14:39
→ steven11329: 說錯是div2要加text-align: center; 10/20 14:45