`

IE6下解决text-align:center

    博客分类:
  • Css
阅读更多
Html代码  收藏代码
  1. <style type="text/css">  
  2. .container{  
  3.   text-align: center;  
  4.   border: solid 1px blue;  
  5. }  
  6. </style>  
  7.   
  8. <div class=container>  
  9.     <table>  
  10.         <tr><td>Text</td></tr>  
  11.     </table>  
  12. </div>  

   在IE下"Text"居中显示,FF下"Text"靠左显示.

 

二、解决问题:

    方案1:

   

Html代码  收藏代码
  1. <style type="text/css">  
  2. .container{  
  3.   text-align: center;  
  4.   border: solid 1px blue;  
  5. }  
  6.   
  7. table {  
  8.     margin-left:auto;  
  9.     margin-right:auto;  
  10. }  
  11. </style>  
  12.   
  13. <div class=container>  
  14.     <table>  
  15.         <tr><td>Text</td></tr>  
  16.     </table>  
  17. </div>  

 

    方案2:

    

Html代码  收藏代码
  1. <style type="text/css">  
  2. .container{  
  3.   text-align:-moz-center; /*FF*/  
  4.   #text-align: center; /*IE */  
  5.   border: solid 1px blue;  
  6. }  
  7. </style>  
  8.   
  9. <div class=container>  
  10.     <table>  
  11.         <tr><td>Text</td></tr>  
  12.     </table>  
  13. </div>  

 

    方案3:

   

Html代码  收藏代码
  1. <style type="text/css">  
  2. .container{  
  3.   border: solid 1px blue;  
  4. }  
  5. </style>  
  6.   
  7. <center>  
  8. <div class=container>  
  9.     <table>  
  10.         <tr><td>Text</td></tr>  
  11.     </table>  
  12. </div>  
  13. </center>  

 

 

分享到:
评论

相关推荐

    在ie7下css居中样式text-align:center;偏左问题解决方法

    复制代码代码如下: body { text-align:center; } 用ie7打开是居左的。 万能 float 闭合(非常重要!) 关于 clear float 的原理可参见 [How To Clear Floats Without Structural Markup] 将以下代码加入Global CSS 中...

    让IE也支持margin居中告别text-align:center

    谨以此篇献给那些和我一样使用 myeclipse 开发,为了在 IE 下居中一直使用 text-align:center 居中的童鞋,接下来介绍让IE也支持margin居中的实现方法

    IE7下当position:fixed遇到text-align:center的解决方法

    IE7下当position:fixed遇到text-align:center 的一些状况,大家可以参考下。

    margin:0 auto与text-align:center的基本概念及区别介绍

    1.text-align: 属性规定元素中的文本的水平对齐方式;  该属性通过指定行框与哪个点对齐,从而设置块级元素内文本的水平对齐方式;  一般情况下设置文本对齐方式的时使用此属性。支持值 justify。  Example: div...

    三星9305收索

    text-align:center;*z-index:1}#ftCon{height:100px;position:absolute;bottom:44px;text-align:center;width:100%;margin:0 auto;z-index:0;overflow:hidden}#ftConw{width:720px;margin:0 auto}body{font:12px ...

    GridView自定义分页实例详解(附demo源码下载)

    本文实例讲述了GridView... text-align:center; } .gvHeader { color: #3F6293; background-color: #F7F7F7; height: 24px; line-height: 24px; text-align: center; font-weight: normal; font-variant: no

    javascript实现操作cookie实现的可记忆菜单

    text-align:center} a{color:#4D4D4D;text-decoration:none} a:hover{color:#AD0000;text-decoration:none} #menu {width:160px;margin:0px;padding:0px;text-align:left;list-style:none;border:1px solid #B0D4ED...

    IE下css常见问题总结及解决

    1、div的垂直居中问题:  解决方法:将行距增加到和整个DIV一样高: 复制代码代码如下:div{ height: 100px; line-height: 100px;...ie6下,div设置为float时,左(右)margin会加倍。  解决方法:在这个div里面加上d

    如何使div垂直水平居中的css代码

    主要的样式定义如下,这也是最简单的方法: body {TEXT-ALIGN: center;} #center { MARGIN-RIGHT: auto; MARGIN-LEFT: auto; } 说明: 首先在父级元素定义TEXT-ALIGN: center;这个的意思就是在父级元素内的内容居中...

    jQuery的手机端九宫格转盘抽奖代码.zip

    &lt;... &lt;head&gt; &lt;meta charset="utf-8"&gt;...meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;...meta name="viewport" content="width=device-width, initial-scale=1, maximum-...text-align: center; }

    兼容ie ff div 层 打开+关闭+ 拖动+遮罩+移动+动画改变高宽

    body{text-align:center} #dd{ margin:50px auto} #odiv{ width:400px; height:200px;border:1px dotted red; border:1px dashed green;} #odiv ul{ list-style:none; text-align:left; width:150px; font-size:...

    CSS中将Span标签设置为固定宽度的方法

    text-align:center; display:block; } 实际验证结果:IE6 OK, FIREFOX 3 OK。 一、形如&lt;span&gt;ABC&lt;/span&gt;DEF格式行设置SPAN为固定宽度的方法如下: span {width:60px; text-align:center; display:block; float:...

    雅虎TAB效果代码 Javascript实现

    text-align:center; background: url(images/top.gif); z-index:500;} #tabs ul {padding:0; margin:0; width:400px; list-style:none; position:relative;} #tabs ul li {float:left; display:inline; width:125px...

    ZeroClipboard插件实现多浏览器复制功能(支持firefox、chrome、ie6)

    但是值得注意的是官方介绍中已明确表态说这个插件不支持ie6,下面将提供多实例化Zero Clipboard复制功能的实现及兼容ie6的写法! 先下载ZeroClipboard //www.jb51.net/jiaoben/24961.html &lt;style type=text/css&...

    简洁的EXTJS日期选择插件.rar

     2.td text-align:center (ie 必须为td 指定宽度才居中)  3.按照星期构建表格,注意前后月边界问题  4.table ie处理问题,需要强制指定用dom操作  5.colSpan cellSpacing hideFocus (colspan cellspacing ie ...

    js加入购物车抛物线动画与购物车效果特效

    text-align:center} .box p{line-height:20px; padding:4px 4px 10px 4px; text-align:left} .box:hover{border:1px solid #f90} .box h4{line-height:32px; font-size:14px; color:#f30;font-weight:500} .box h4 ...

    诘屈聱牙之javascript中国象棋

    IE6.0 Only 非XHTML标准,可能IE 7.0也看不了….哈哈 蓝方先走 * { font:24px arial, “宋体”; font-weight:bold; color:white; cursor:default; } table { table-layout:fixed;... text-align:center

Global site tag (gtag.js) - Google Analytics