CSS替换< div align =" center"> [英] CSS replacement for <div align="center">
问题描述
我知道这个问题已被问过很多次,但我从来没有看到一个满意的答案。我的意思是,一个答案实际上是有效的。
所以,这里我们再去。使用jsFiddle: http://jsfiddle.net/KFMyn/3/
如果你从HTML中删除 align =center
,你需要使用什么CSS来使结果看起来和原来一样? p>
我发现的答案通常是 margin:0 auto
和/或 text-align:
文本对齐中心覆盖大部分文本元素,但需要一些额外的中心对齐表格
div {width :400px; text-align:center;}
table {margin:0 auto;}
table td {text-align:left;}
I know this question has been asked many times, but I never saw a satisfactory answer. I mean, an answer that actually works.
So, here we go again. Take this jsFiddle: http://jsfiddle.net/KFMyn/3/
If you remove the align="center"
from the HTML, what CSS do you need to use to make the result look the same as the original?
The answers I found usually amount to margin:0 auto
and/or text-align:center
but neither of those have the desired effect of making the result look the same as the original.
The text align center covers most of the text elements but a little extra is needed to centre align the table
div {width:400px; text-align:center;}
table {margin: 0 auto;}
table td {text-align: left;}
这篇关于CSS替换< div align =" center">的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!