问答详情
源自:13-4 起飞咯 - 浮动模型

三个块状元素怎么破???

怎么安排中间块状元素居中???

提问者:CarmenLu 2018-05-20 11:48

个回答

  • 慕九州8563217
    2018-05-20 20:18:02

    效果图

    https://img3.mukewang.com/5b01676a00018cb610300809.jpg

  • 慕九州8563217
    2018-05-20 20:16:38

    <!DOCTYPE html>
    <html>	
    <head>		
        <meta charset="UTF-8">		
        <title></title>		
        <style>			
            father{				
                width: 500px;				
                height: 500px;				
                background: #000;			
            }						
            .son1{				
                height: 100px;				
                background: green;			
            }						
            .son2{				
                height: 200px;				
                background: yellow;			
            }						
            .son3{				
                height: 100px;				
                background: red;			
            }						
            .son2 h1{				
                text-align: center;				
                line-height: 200px;				
                margin: 0;			
            }		
        </style>	
    </head>	
    
    <body>		
        <div class="father">			
            <div class="son1"></div>			
            <div class="son2">				
                <h1>中间块的元素居中</h1>			
            </div>			
            <div class="son3"></div>		
        </div>	
    </body>
    </html>   
    	      
    	


  • 慕兄7758
    2018-05-20 15:37:29

    感觉 用一个父块 然后三个字块 把三个字块放进父块中!