简体   繁体   English

IE7与IE8 / IE9 / FF4的图像差异

[英]Image Difference IE7 to IE8/IE9/FF4

I have a problem with simple Images in DIV containers in IE7. 我对IE7的DIV容器中的简单图像有疑问。

I have it a few times on my homepage, here is an example: 我在首页上有几次,下面是一个示例:

 <div id="divSearchBottomLinks" class="divSearchBottomLinks">
   Meistgesucht: Wetter Ebay-Abnahmen Geld Mehr...
   <div id="divSearchButtomLinksEffect" class="divSearchButtomLinksEffect">
       <img src="Images/Design/DefaultPage/searchButtonEffect.png" alt=""
          style="border: 1px red solid;" />
   </div>
</div>

CSS is: CSS是:

.divSearchButtomLinksEffect
{
float:right;
padding-right:8px;
}
.divSearchBottomLinks
{
border: 1px solid red;
width: 99%;
height: 15px;
text-align: left;
font-size: 10px;
word-spacing: 8px;
color: Gray;
}

Here is how it looks like: http://s3.imgimg.de/uploads/2204cc79eJPG.jpg 外观如下: http : //s3.imgimg.de/uploads/2204cc79eJPG.jpg

As you can see: No reason, why the image should be more in Bottom then the other, you see left FF4 (same in IE8/IE9/Opera9/Opera10) and right only IE7 who seems to have a problem with this. 如您所见:没有理由,为什么图像的底部应该比其他图像高,您看到的是FF4(在IE8 / IE9 / Opera9 / Opera10中是相同的),而在右边的IE7中似乎对此有问题。

I can't see how to fix it, I can only see from where it somes... any ideas? 我看不到如何解决它,我只能从那里看一些想法。

For some reason the element floating to the right will float beneath the text on the line in IE7, The text takes up the full width of the container, just as a div elements does by default, and pushes the floating element down. 由于某种原因,向右浮动的元素将浮动在IE7中该行的文本下方。该文本占据容器的整个宽度,就像div元素默认情况下一样,然后将浮动元素向下推。

Put the text before the image in a div element also, and float that to the left, that way the element floating to the right will not be pushed down. 也将图像前的文本放在div元素中,然后将其浮动到左侧,这样就不会向下浮动到右侧的元素。

I would try go with something like this instead: 我会尝试使用类似这样的方法:

<div id="bottomLinks">
  <p>Meistgesucht: Wetter Ebay-Abnahmen Geld Mehr...
  </p>
  <img src=".." />
</div>
<style>
div#bottomLinks {
  overflow: hidden;
  }
  div#bottomLinks p {
    float: left;
  }
  div#bottomLinks img {
    float: right;
  }
</style>

You're problem right now is probably because of the width of 99% and that the first element doesn't float. 您现在遇到的问题可能是因为width为99%,并且第一个元素没有浮动。

Browsers have different default CSS for various HTML elements. 浏览器针对各种HTML元素具有不同的默认CSS。 The first thing I would do is add a good reset so that all elements start out with the same basic settings. 我要做的第一件事是添加一个很好的重置,以便所有元素都以相同的基本设置开始。 This will take some of the guess work out of the debugging process. 这将消除调试过程中的一些猜测工作。 Add this BEFORE the rest of your CSS - 在其余CSS之前添加此代码-

http://meyerweb.com/eric/tools/css/reset/ http://meyerweb.com/eric/tools/css/reset/

Next, you should always specify the width in a floated container. 接下来,您应始终在浮动容器中指定宽度。 IE in particular has issues if you don't specify widths properly. 如果您未正确指定宽度,则IE尤其会出现问题。

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

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