简体   繁体   English

IE7:菜单上方的标题

[英]IE7: header above menu

I am having trouble with IE7. IE7出现问题。 I have a header, which is an IMG. 我有一个标头,它是IMG。 Under it I have a div that represents a menu, they have to be attached to eachother without space in between. 在它下面,我有一个表示菜单的div,它们必须彼此连接,而彼此之间没有空格。 Both are 1000px width. 两者均为1000px宽度。 In Opera and FireFox the header and the menu are neatly attached to eachother. 在Opera和FireFox中,标题和菜单彼此整齐地附加在一起。 However, in IE7, there is a small space between the menu DIV and the IMG. 但是,在IE7中,菜单DIV和IMG之间的空间很小。 I have tried explicitly defining padding and margin on the IMG, however it does not work. 我尝试过在IMG上明确定义填充和边距,但是它不起作用。 I have had this problem before, so it seems to be a IE7 quirk. 我之前曾遇到过此问题,所以这似乎是IE7的怪癖。

My HTML Code: 我的HTML代码:

 <div id="middle"> <img id="ctl00_headerHolder_headerImage" src="pictures/headers/header_home.jpg" style="border-width:0px;" /> <div id="ctl00_menuPanel" class="menu"> <a id="ctl00_home" href="Default.aspx" style="color:#FFCC33;">Home</a> | <a id="ctl00_leden" href="Leden.aspx">Leden</a> | <a id="ctl00_agenda" href="Agenda.aspx">Agenda</a> | <a id="ctl00_fotos" href="Fotos.aspx">Foto's</a> | <a id="ctl00_geschiedenis" href="Geschiedenis.aspx">Geschiedenis</a> | <a id="ctl00_gastenboek" href="Gastenboek.aspx">Gastenboek</a> </div> </div> 

Try the IE Developer Toolbar, which will let you inspect what is going on with the elements and give you outlines of the areas covered. 尝试使用IE Developer Toolbar,该工具栏将使您检查元素所发生的情况并为您概述所涵盖的领域。 It might give you a better understanding of the problem. 它可以使您更好地理解问题。

The solution: 解决方案:

img {
padding: 0px;
margin: 0px;
display: block;
}

display: block 显示:块

I run into this a lot. 我遇到了很多。 Rather than hunting down the specific behavior, try sanity checking by explicity setting padding and margin properties for img/div/etc selectors to 0, set border-style: none border-width: 0px border="0" etc. 与其寻找特定的行为,不如尝试通过将img / div / etc选择器的padding和margin属性显式设置为0,设置border-style:none border-width:0px border =“ 0”等来进行健全性检查。

IE Dev Toolbar is a must-have but whether it helps you with figuring out single-pixel issues is unlikely. IE Dev Toolbar是必不可少的,但它能否帮助您解决单像素问题却不太可能。

Instead of resorting to display block, note that IE7 does some seriously odd things with whitespace; 请注意,IE7不会使用显示块,而是使用空白做了一些严重的奇怪事情; try removing the whitespace between the image and the div, and see what happens. 尝试删除图像和div之间的空白,然后看看会发生什么。

CSS Resets (like the YUI Reset CSS ) are great for this kind of thing. CSS重置(例如YUI Reset CSS )非常适合这种情况。 They reset paddings, margins, and other display properties on a lot of HTML elements to minimize the display differences. 它们会在许多HTML元素上重置填充,边距和其他显示属性,以最大程度地减少显示差异。

The solution...display: block 解决方案...显示:块

That question couldn't be answered properly without knowing the rendering mode that the browser was in; 如果不知道浏览器所处的渲染模式,就无法正确回答该问题。 you need to tell people what doctype you have if you have CSS rendering issues. 如果您遇到CSS呈现问题,则需要告诉别人您拥有哪种文档类型。 The image behaviour you refer to is different in quirks mode as opposed to standards mode. 您引用的图像行为在“怪癖”模式下与“标准”模式不同。 A minimal test case must include a full HTML document and the CSS to reproduce the problem. 最小的测试用例必须包括完整的HTML文档和CSS,以重现该问题。 Please don't ask people for help without giving them the information they need to answer easily without wasting their time... 请不要在不给别人提供他们需要轻松回答而又不浪费时间的情况下向他们求助...

真正的解决方案:

#middle { font-size: 0; line-height: 0; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM