浮動元素垂直居中,bootstrap柵格布局垂直居中


<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>子元素在父元素里面垂直居中</title>
<link rel="stylesheet" type="text/css" href=""/>
<style>
    #d1{
        position: relative;
        border:thin solid red;
        width:900px;
        height:100px;
    }
    #d2{/*dashed也是虛線*/
        border:thin dotted blue;
        width:50px;
        height:50px;
        float:right;  
    }
    .center-vertical{
        position: relative;
        top: 50%;
        transform: translateY(-50%);
    } 
</style>  
</head>
<body>
<div id="d1">
    <div id="d2" class="center-vertical"></div>
</div>
</body>  
</html>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM