开发者

div centering techniques / question

开发者 https://www.devze.com 2023-04-03 18:31 出处:网络
I\'ve got a div with a background color blue, that needs to be centered in another div with background green -- just for looks.I centered the blue div inside the green div with a \"margin: 10px auto\"

I've got a div with a background color blue, that needs to be centered in another div with background green -- just for looks. I centered the blue div inside the green div with a "margin: 10px auto". Now, I need the text inside this blue div to be left justified, not centered, so I put the text inside a div and gave it a margin of zero. That didn't work.

Obviously I'm confused about centering things in general, and am still coming up the css centering / positioning learning curve. Any thoughts / comments appreciated. 开发者_如何学Go Thanks.


You need to place a:

text-align: left

style on the DIV containing the text.

margin: auto only works for centering DIVS, has no effect on actual text

0

精彩评论

暂无评论...
验证码 换一张
取 消