Home  >  Article  >  Web Front-end  >  How to implement div spacing using margin and overflow attributes_Experience exchange

How to implement div spacing using margin and overflow attributes_Experience exchange

PHP中文网
PHP中文网Original
2016-05-16 12:06:361880browse

how to use margin and overflow attributes to achieve div spacing_experience exchange

How to implement div spacing using margin and overflow attributes_Experience exchange

usually when we make the above picture, we will give four p's plus different css attributes are used to achieve the middle interval. but what we hope more is that there is no need to mark html tags, and it can be realized directly through css. xiaozhi proposed a very good solution on the forum today. use the overflow:hidden attribute. maybe many people have already used it this way, but i have never used it and i find it refreshing. hehe. in fact, the reason is very simple. we set the margin-right and margin-bottom properties of li as normal. the result will naturally be more right and bottom than we expected. at this time, we set the width/ through the parent of ul. height attribute, and then overflow:hidden to hide the excess. good method, haha!

please see the picture for the solution:
How to implement div spacing using margin and overflow attributes_Experience exchange

 
 
     
         
         
         
         
         
         
         

        巧用overflow:hidden解决中间间隔问题 
         
            *{margin:0;padding:0;} 
            body{text-align:center;background:#CCC;} 
            ul{list-style:none;} 
            .main {background:white;height:800px;width:597px;margin:0 auto;} 
            .box {width:595px;height:205px;margin:20px auto;overflow:hidden;background:white;} 
            .box ul {width:600px;height:210px;} 
            .box li {float:left;margin-right:5px;margin-bottom:5px;} 
            .box div {background:white;background:#f7f7f7;width:293px;height:98px;border:1px solid #CCC} 
        .box h2 {background:#9CC;text-align:left;text-indent:10px;font-size:12px;height:24px;line-height:24px;} 
         
     
     
        
              

巧用overflow:hidden解决中间间隔问题

              
                  
                          
  •                           
                                  

    Title

                                  

    Content

                              
                          
  •                       
  •                           
                                  

    Title

                                  

    Content

                              
                          
  •                       
  •                           
                                  

    Title

                                  

    Content

                              
                          
  •                       
  •                           
                                  

    Title

                                  

    Content

                              
                          
  •                   
              
          
   

the above is the method of using margin and overflow attributes to achieve div spacing_experience exchange content, please visit for more related content follow the php chinese website (www.php.cn)!


Statement:
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