简体   繁体   English

在div内浮动的跨度 - 为什么IE中的新行?

[英]a span floated right within a div - why a new line in IE?

I have 1 span within a container div. 我在容器div中有1个跨度。 I want the span floated to the right. 我希望跨度向右浮动。 The content within the div and the span should be on one line. div和span中的内容应该在一行上。

In Firefox, that's how it displays. 在Firefox中,这就是它的显示方式。

But in IE, the span is displayed on a new line: 但在IE中,跨度显示在一个新行上:

http://i48.tinypic.com/etzg5f.png http://i48.tinypic.com/etzg5f.png

Why do the browsers display the content differently? 为什么浏览器以不同的方式显示内容?

You should float the other content to the left. 您应该将其他内容浮动到左侧。 So have two floats; 所以有两个花车; left and right. 左和右。

Another approach could be using position absolute on the span, andposition relative on the surrounding div. 另一种方法可能是在跨度上使用绝对位置,并在周围的div上使用相对位置。 Then you could put the positions (top, left, right and bottom) and position the elements as you should! 然后你可以放置位置(顶部,左侧,右侧和底部)并按要求定位元素!

You could probably get away with specifying a width on your .catalogSelection#top #rss style definition. 您可以通过在.catalogSelection#top #rss样式定义中指定宽度来.catalogSelection#top #rss When setting the element to float it considers it a block level element and since your existing text is not floated, it wraps to the next line. 将元素设置为float时,将其视为块级元素,并且由于现有文本未浮动,因此它将换行到下一行。 Either this, or you need to float your Choose Catalog text to the left as well. 要么是这个,要么你需要将Choose Catalog文本浮动到左侧。 Or as Kevin suggested, you can just put your Floated elements to the left of the non-floated, but this can be an issue when it comes to screen readers as it reads from left to right in your code, and is not semantically correct. 或者正如凯文建议的那样,你可以将你的Floated元素放在非浮动元素的左边,但这对于屏幕阅读器来说可能是一个问题,因为它在你的代码中从左到右读取,并且在语义上不正确。

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

相关问题 需要说明为什么将右浮动元素作为div中的第一个元素来解决新行问题 - Need explanation why putting right floated element as first element in div fixes the new line issue 为什么浮动父级中的空span标签会在新行上呈现? - Why does an empty span tag in a floated parent render on a new line? 右浮动div元素未水平显示,请换行 - Right floated div element not show horizontally, break into new line 右浮动范围似乎不在父div中 - right floated span does not appear to be in parent div <span>向右</span>浮动<span>,其余(文本)在左侧,内部</span>浮动 <div> <span>在即7</span> - Float <span> on right and the rest(text) on left, within <div> in ie 7 在chrome / IE中,浮动div旁边的字段集在右侧溢出,在FF中下一行 - Fieldset next to floated div overflows to the right in chrome/IE, breaks to the next line in FF 右浮动div和min-width,div移动到浏览器调整大小的新行 - right floated div and min-width, div moves to the new line on browser resize IE7 - 在新线上浮动元素 - IE7 - floated elements on new line 为什么我的浮动左div使用960.gs转到IE6中的下一行? - Why does my floated left div go to the next line in IE6 using the 960.gs? <span>漂浮在里面</span> <li> <span>在FF中创建新行,但不在Chrome中创建新行</span> - <span> floated inside <li> creates new line in FF but not in Chrome
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM