在css中,可以使用“float:left”來表示左浮動,float屬性用于定義元素向哪個方向浮動,當(dāng)屬性值為right時表示元素右浮動,當(dāng)屬性值為none時表示元素不浮動。
本教程操作環(huán)境:windows10系統(tǒng)、CSS3&&HTML5版、Dell G3電腦。
css3使用什么屬性表示左浮動
float 屬性定義元素在哪個方向浮動。以往這個屬性總應(yīng)用于圖像,使文本圍繞在圖像周圍,不過在 CSS 中,任何元素都可以浮動。浮動元素會生成一個塊級框,而不論它本身是何種元素。
如果浮動非替換元素,則要指定一個明確的寬度;否則,它們會盡可能地窄。
注釋:假如在一行之上只有極少的空間可供浮動元素,那么這個元素會跳至下一行,這個過程會持續(xù)到某一行擁有足夠的空間為止。
-
left 元素向左浮動。
-
right 元素向右浮動。
-
none 默認(rèn)值。元素不浮動,并會顯示在其在文本中出現(xiàn)的位置。
-
inherit 規(guī)定應(yīng)該從父元素繼承 float 屬性的值。
示例如下:
<html> <head> <style type="text/css"> img { float:left } </style> </head> <body> <p>在下面的段落中,我們添加了一個樣式為 <b>float:left</b> 的圖像。結(jié)果是這個圖像會浮動到段落的右側(cè)。</p> <p> <img src="/i/eg_cute.gif" /> This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. </p> </body> </html>
輸出結(jié)果:
(學(xué)習(xí)視頻分享:css視頻教程)