简体   繁体   English

IE7文本对齐问题-文本换行且不应

[英]IE7 text align issue - text wraps and shouldn't

If you take a look at http://wilwaldon.com/ie7sucks/inner7ie.html with IE7 you will notice that the text wraps the image. 如果您使用IE7来浏览http://wilwaldon.com/ie7sucks/inner7ie.html ,您会注意到文本将包裹图像。 With all other browsers it doesn't. 在所有其他浏览器中则不是。 I'd like it to not wrap the image in IE7. 我希望它不要将图像包装在IE7中。 I've used the ie dev tools but can't figure out what's causing the glitch. 我使用过ie开发工具,但无法弄清楚是什么原因引起的故障。

Any help would be appreciated and I'll be eternally grateful. 任何帮助将不胜感激,我将永远感激。

THANK YOU! 谢谢!

It doesn't look like it is wrapping to me. 看起来好像没有包裹在我身上。 Wrapping is where a single paragraph wraps around an image. 包装是单个段落环绕图像的位置。 What is happening here is that you have 2 paragraphs, the first of which is longer than the image and so pushes the bottom paragraph, below the image. 这里发生的是您有2个段落,其中第一个段落比图片长,因此将底部的段落推到图片下方。

Try doubling the size of the first paragraph and see if it wraps on both Firefox and IE7. 尝试将第一段的大小加倍,看看它是否在Firefox和IE7上都可以合并。 I think it probably won't. 我认为可能不会。

Therefore, your problem is that you have a bottom padding to all your paragraphs in .mainright. 因此,您的问题是.mainright中所有段落的底部都有空白。 Firefox is including this padding in the height of the paragraph whereas IE7 is, incorrectly, adding it on to the bottom. Firefox在该段落的高度中包含了该填充,而IE7错误地将其添加到了底部。 This means, in Firefox, the first paragraph isn't long enough to push the 2nd paragraph below the image whereas in IE7, it is long enough. 这意味着,在Firefox中,第一段的长度不足以将第二段推到图像下方,而在IE7中,它足够长。

If Firefox is displaying as you want it to, try removing this bottom padding. 如果Firefox如您所愿显示,请尝试删除此底部填充。 Then, if you want to retain spacing between the Featured header and the spotlight images, add the following: 然后,如果要在Featured标题和Spotlight图像之间保留间距,请添加以下内容:

.featuredbold, .spotlightbox {margin-bottom:36px;}

UPDATE: To accommodate the dynamic content you will have to do the 1 of the following: 更新:要容纳动态内容,您将必须执行以下一项操作:

1) Have a single paragraph per box and then use <br /><br /> to simulate a paragraph break. 1)每个框只有一个段落,然后使用<br /><br />模拟段落中断。

2) Put all of the paragraphs in a div and have whatever is generating the content change the class of that div. 2)将所有段落放在div中,并让生成内容的内容更改该div的类。 You could, for example have ".fat" and ".thin" as classes and then associate the appropriate widths with those classes so that the paragraphs were unable to wrap as they would be constrained by the div. 例如,您可以将“ .fat”和“ .thin”作为类,然后将适当的宽度与这些类相关联,以使段落无法换行,因为它们将受到div的约束。 You would also have to float the div to the right. 您还必须将div浮动到右侧。

Solution 2 is much better but you may not be able to implement it, depending on your setup. 解决方案2更好,但是您可能无法实现,具体取决于您的设置。

Remove, or re-set: #mainright p {padding-bottom:36px;} . 删除或重新设置: #mainright p {padding-bottom:36px;}

Also, you have some validation errors. 另外,您还有一些验证错误。

http://www.w3schools.com/css/pr_class_display.asp http://www.w3schools.com/css/pr_class_display.asp

No versions of Internet Explorer (including IE8) support the property values 
"inline-table", "run-in", "table", "table-caption", "table-cell", 
"table-column", "table-column-group", "table-row", or "table-row-group".

By setting table-row-group on your P-tags, they no longer take padding-bottom, but IE does. 通过在您的P标签上设置table-row-group,它们不再位于padding-bottom之下,而IE则是如此。

The structure of your code is wrong also. 您的代码结构也是错误的。 You need something like this: 您需要这样的东西:

<div class="spotlightbox">
  <img style="float: left">
  <div style="float: left">Text here</div>
  <div style="clear: both;"></div>
</div>

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

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