Html <div style="clear:both"> 中的“两者”是什么意思
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5299965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does "both" mean in <div style="clear:both">
提问by Tom Gullen
<div style="float:left">Hello</div>
<div style="float:right">Howdy dere pardner</div>
<div style="clear:both"></div>
I get what it does, but why the name both
? What does both
mean?
我明白它的作用,但为什么叫这个名字both
?什么both
意思?
回答by Quentin
Both means "every item in a set of two things". The two things being "left" and "right"
两者的意思都是“一组两件物品中的每一项”。两件事是“左”和“右”
回答by Sagar Pise
Description of the possible values:
可能值的说明:
left
: No floating elements allowed on the left sideright
: No floating elements allowed on the right sideboth
: No floating elements allowed on either the left or the right sidenone
: Default. Allows floating elements on both sidesinherit
: Specifies that the value of the clear property should be inherited from the parent element
left
: 左侧不允许浮动元素right
: 右侧不允许浮动元素both
: 左侧或右侧都不允许浮动元素none
: 默认。允许两侧浮动元素inherit
: 指定clear属性的值应该从父元素继承
Source: w3schools.com
资料来源:w3schools.com
回答by al123
Clear:both gives you that space between them.
清除:两者都为您提供了它们之间的空间。
For example your code:
例如你的代码:
<div style="float:left">Hello</div>
<div style="float:right">Howdy dere pardner</div>
Will currently display as :
当前将显示为:
Hello ................... Howdy dere pardner
If you add the following to above snippet,
如果您将以下内容添加到上面的代码段中,
<div style="clear:both"></div>
In between them it will display as:
在它们之间,它将显示为:
Hello ................
Howdy dere pardner
giving you that space between hello and Howdy dere pardner.
为您提供 hello 和 Howdy dere pardner 之间的空间。
Js fiiddle http://jsfiddle.net/Qk5vR/1/