CSS替换< div align =" center"> [英] CSS replacement for <div align="center">

查看:431
本文介绍了CSS替换< 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;}

http://jsfiddle.net/NYuv8/4/


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;}

http://jsfiddle.net/NYuv8/4/

这篇关于CSS替换< div align =" center">的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆