css float attribute analysis_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:03:47
Original
882 people have browsed it

Definition of float attribute : In which direction the element floats

The default value is : none

Note : A floating element will generate a block-level box, regardless of what kind of element it is.

HTML code:

<body>     <div class="main">	 <div class="d" id="d1">框1</div>	 <div class="d" id="d2">框2</div> 	 <div class="d" id="d3">框3</div>	 <div class="d" id="d4">框4</div>       </div></body>
Copy after login

1, when a sibling element When all floating elements are used, the height of the parent element without custom width and height will be zero

css style:

.main {      border: 1px solid ;   } .d {      border: 1px solid red;      width: 50px;      height: 50px;      float: left;   }
Copy after login

Display effect:

2, floating elements will be in one line if there is not enough space. Extra floating elements will jump to the next line

css style:

 .main {      border: 1px solid ;      width:130px;   } .d {      border: 1px solid red;      width: 50px;      height: 50px;      float: left;   }
Copy after login

Display effect:

3. The floating element will break away from the text flow and refer to the parent element

ccs style:

  #d1{     float:left;   }
Copy after login

Display:

 

                                     🎜>

                                                          
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template