誰知道網頁制作中規定div在網頁右邊居中不隨滾動條走怎么做到的
uj5u.com熱心網友回復:
參考這個,fixed定位,使元素位置與檔案無關,div {position: fixed;
width: 100px;
height: 100px;
background: red;
right: 20px;
top: calc(50% - 50px);
}
uj5u.com熱心網友回復:
position: fixed;uj5u.com熱心網友回復:
這個是解決fixed在ios系統下 失效的方法,如果不考慮ios系統的就直接用fixed就行了<body>
<!-- fixed定位的頭部 -->
<div class="header">
</div>
<!-- 可以滾動的區域 -->
<div class="main">
<div class="content">
<!-- 內容區域 -->
</div>
</div>
<!-- fixed定位的底部 -->
<footer class="footer">
<input type="text" placeholder="請輸入姓名">
</footer>
</body>
.header,.footer,.main{
display: block;
}
.header {
position: fixed;
top:0;
left: 0;
right:0;
height:100px;
}
.footer {
position: fixed;
bottom: 0;
left: 0;
right:0;
height: 30px;
}
.main{
/*main絕對定位,進行內部滾動*/
position: absolute;
/*top是頭部的高度*/
top: 100px;
/*bottom是底部的高度*/
bottom: 30px;
/*使之可以滾動*/
overflow-y: scroll;
/*增加彈性滾動,解決滾動不流暢的問題*/
-webkit-overflow-scrolling:touch;
}
.main .content{
height:2000px;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/114111.html
標籤:HTML(CSS)
上一篇:大學期末作業:PHP+MySQL
下一篇:asp的上傳
