【发布时间】:2011-08-05 21:34:26
【问题描述】:
我有一些 html:
<body>
<h1 id="header"></h1>
<div id="container">
<div id="left">
</div>
<div id="content">
<div id="titlebar">
<span id="date">Novermber 13, 3414</span>
<span id="title"> The importance of being earnest.</span>
<span id="author">HG Wellwhocares</span>
</div>
<iframe id="memo" />
<div id="attachments"></div>
<p id="description"></p>
<div id="action">
<div id="accept">Accept</div>
<div id="revise">Revise</div>
</div>
</div>
</div>
</body>
还有一些 CSS:
#container{
width: 85%;
margin: 0 auto;
background: gray;
}
#left{
float: left;
width: 20%;
padding: 1%;
}
#left:after{
clear: both;
}
#content{
margin-left: 22%;
background: silver;
padding: 3em;
}
#titlebar{
text-align: center;
}
#date{
float: left;
}
#title{
clear: both;
}
#author{
float: right;
}
#memo{
width: 100%;
min-height: 500px;
}
还有这个jQuery:
months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$(document).ready(function(){
items = new Array();
$.getJSON('_vti_bin/listdata.svc/BOTMemos?$orderby=MeetingDate', function(data){
date = "";
$.each(data.d.results, function(index, value){
if(value.MeetingDate!=null){
if(value.MeetingDate!=date){
if(date!=""){
$('#left').append('<hr />');
}
item = new Array(value.MeetingDate, value.Title0, value.Checkers);
date = value.MeetingDate;
month = months[parseInt(date.substring(5,7), 10)-1];
formattedDate = month + " " + date.substring(8,10) + ", " + date.substring(0, 4);
$('#left').append('<h1>'+formattedDate+'</h1>');
}
$('#left').append('<h2 class="memo">'+value.Title0+'</h2>');
}
});
});
});
这会导致两种不同的布局,这在 ie9 中: 这在ie7中: 我的两个问题是:
- 为什么 ie7 的左侧没有显示文字?
- 为什么
#titlebardiv 中的三个<span>标签在ie7 中不像在ie9 中那样并排显示?
【问题讨论】:
-
+1 很好的清晰和干净的问题,如果你在 jsFiddle.net 中模拟它会更好
-
您使用的是什么 DOCTYPE?您的 IE9 版本是否处于兼容模式?
-
未来参考,IE9(我认为是 IE7)拥有开发者工具,可以让您以浏览器看到的方式查看页面。您应该能够按 F12 将其调出。这可以帮助您了解为什么其中一个的行为与另一个不同。
-
@valipour:我正在考虑它,但我正在编写这个 Microsoft Sharepoint,它使用默认 doctype 做了一些奇怪的事情,我不希望它呈现任何不同的方式。
-
@Ash:它不在兼容模式下,并且 IE9 按预期运行,是 ie7 导致了问题。
标签: jquery html css layout internet-explorer-7