浮子坏吗?应该在其位置使用什么 [英] Are floats bad? What should be used in its place

查看:97
本文介绍了浮子坏吗?应该在其位置使用什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大约一个星期前,我已经从表设计跳到css,从那以后,我一直在阅读更多。昨天,我在这里读了一个很长的帖子,在那里的海报敲敲浮子和他们是如何贬值。有很多关于 inline-block 的讨论。

I've made the jump from table design to css about a week ago and have since been reading more about it. Yesterday, I read a long post here on SO where the posters were knocking floats and about how depreciated they are. There was a lot of talk about inline-block being used in its place.

我有一个HTML5设计我刚刚完成,它看起来梦幻般的firefox和chrome,但当从运行explorer版本7,8和9的其他计算机测试时,设计绝对爆炸。这似乎对我来说,在这个设计中,我浮动正确的任何东西在IE没有荣誉。它似乎包裹在它的左边的任何东西。

I have a HTML5 design that I just finished and it looks fantastic in firefox and chrome but when tested from other computers running explorer versions 7, 8 and 9, the design absolutely explodes. It seems to me that anything in this design that I've floated right is not honored in IE. It just seems to wrap under whatever is to the left of it.

我想知道如果我对浮动是好的,或者如果我应该使用 inline-block 。一个例子是如何使两个div相邻,其中一个在左边,另一个在右边,使用 inline-block 将是很好的。

I'd like to know if I'm OK with floats or if I should I be using inline-block instead. An example of how to have two divs next to one another where one is on the left side and the other on the right, using inline-block would be nice.

我有另一个困境,希望有人能帮助我。我在一个老的开发机上运行XP SP1。我可以测试的最好的IE浏览器是6.我想以某种方式得到一个东西,将允许我测试版本7,8和9(和10如果它还没有)。有人可以为此推荐任何解决方案吗?

I have another dilemma here that hopefully someone can help me with. I am on an old development machine running XP SP1. The best IE browser I can test with is 6. I'd like to somehow get a hold of something that will allow me to test versions 7, 8 and 9 (and 10 if it's out yet). Can someone recommend any solution for this?

推荐答案

浮点数从不用于布局。 >

Floats were never meant for layout.


它们只是用来接受一个元素,放在一边,让其他内容在它周围流动。

They’re simply meant to take an element, put it to one side, and let other content flow around it. That’s all.

那么为什么要使用它们进行布局?


因为你可以清除两个浮动列下面的页脚,浮动布局
开始生效了。如果曾经有一种方法来清除元素
下面定位的元素,我们永远不会打扰使用浮动为
布局。

Because you can clear a footer below two floated columns, float layout came into being. If there had ever been a way to "clear" elements below positioned elements, we’d never have bothered to use floats for layout.

为什么我们仍在使用它们进行布局?

http://www.w3.org/TR/css3-flexbox\"> CSS弹性框布局模块和 CSS模板布局模块仍在工作草稿,并且不受所有浏览器支持。

Because better alternatives, like the CSS Flexible Box Layout Module and the CSS Template Layout Module are still working drafts and are not supported by all browsers.

为什么您的设计突破IE 7,8和9?

您的代码可能有问题,也就是说,您没有使用浮动广告。这不是完全是你的错,因为他们从来不是为了布局首先。但是,我可以向你保证,他们工作。

There's probably a problem with your code, that is, you're not using floats right. This is not totally your fault, since they were never meant for layout in the first place. However, I can assure you that they work. I have been using floats for layout for a long time and was always able to make it work in most browsers.

内嵌块更好吗?我们一直在使用浮动块布局很长一段时间,总是能够使它在大多数浏览器中工作。

Are inline blocks better?

可以使用浮动块完成的许多布局都可以使用内嵌块。然而,他们不解决每个布局问题,他们也不是为布局也。我发现他们中的一个通常更适合于预期的布局。

Many layouts that can be done with floats can be done with inline blocks. However, they don't solve every layout problem and they were not meant for layouts as well. I find that one of them will usually be more suitable for the intended layout.

参考资料

如果你使用它们,请不要吸吮

这篇关于浮子坏吗?应该在其位置使用什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆