div布局

 div水平垂直居中布局

方案一

<html>
	<head>
		<meta http-equiv = "Content-Type" content= "text/html;charset=utf-8"></meta>
		<style>
          .box{
		   position:relative;
		   width:400px;
		   height:200px;
		   background-color:grey;
		  }
		  .con{
		   position:absolute;
		   transform: translate(50px,10px);
		   width:300px;
		   height:180px;
		   background-color:yellow;
		  }
		</style>
	</head>
	<body>
		<div class="box">
			<div class="con"></div>
		</div>
	</body>

</html>

方案二

	  .con{
		   position:absolute;
		   top:50%;
		   left:50%;
		   width:300px;
		   height:180px;
		   transform:translate(-50%,-50%);
		   background-color:yellow;
		  }


 div品字形布局


代码

<html>  
    <head>  
        <meta http-equiv= "Content-Type" content= "text/html;charset=utf-8"></meta>  
        <style>  
           .box {  
             position:relative;  
           }  
           .head {  
                border:4px;  
                border-color:blue;  
                border-style:solid;  
                width:400px;  
                height:100px;  
                position:relative;  
           }  
            .left {  
                border-width: 0px 4px 4px 4px;  
                border-color:blue;  
                border-style:solid;  
                width:198px;  
                height:100px;  
                background-color:grey;  
                position:absolute;  
           }  
            .content {  
                border-width: 0px 4px 4px 0px;  
                border-color:blue;  
                border-style:solid;  
                width:198px;  
                height:100px;  
                background-color:green;  
                position:absolute;  
                left:206px;  
           }  
        </style>  
    </head>  
    <body>  
    <div class="box">  
     <div class = 'head'>head</div>  
    <div class = 'left'>left</div>  
    <div class = 'content'>content</div>  
    </div>  
    </body>  
</html>  





  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值