當div爲position: fixed自適應居中
<html>
<head>
<meta charset="UTF-8">
<title>當div爲position: fixed自適應居中</title>
<style>
.fixed {
width: 300px;
height: 150px;
background-color: red;
position: fixed;
top: 20%;
left: 0;
right: 0;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="foxed">
fixed浮動居中
</div>
</body>
</html>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.