首页 > 技术文章 > IE6 7BUG 文本对齐

amws 2013-06-18 16:06 原文

BUG描述

设置了对齐方式text-align后,正常浏览器只有文本受影响,而IE6 7会影响到内层其他元素

BUG

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<meta name="robots" content="noindex">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Disappearing List Background Bug Demo - hasLayout.net by Zoffix Znet</title>

<style type="text/css">

body {
    background: #fff;
    color: #000;
}
#container1 { text-align: center;
            background: #0000FF;

 }

#container2 { text-align: right;
            background: #00ffFF;

 }
    .inner { width: 10em;
            background: #FF00FF;
    }
</style>
<div id="container1">
    Give me the aligns!
    <div class="inner">Oh noes!</div>
</div>

<div id="container2">
    Give me the aligns!
    <div class="inner">Oh noes!</div>
</div>

解决

改善文档结构,添加语义标签,应用FLOAT,上文中给文字段落加上标签<P>,给<P>应用FLOAT:LEFT/RIGHT

推荐阅读