設置div自適應高度滾動


<body>
<div id="divc" style="overflow: auto;">
</div>
<a id="btn" class="btn" onclick="sub();" href="#">提交</a>

<script type="text/javascript">
$(function(){
    //設置自適應高度
    var height = window.screen.height-110;
    $("#divc").css("height", height);//通過設置CSS屬性來設置元素的高
})
</body>

作用描述:div內的內容自動滾動,提交按鈕始終處於頁面最下方。

按鈕的css樣式:

.btn{display: block;position: fixed; bottom: 0; background: #00a0ea; height: 40px;line-height:40px; text-align: center;font-size: 20px;color: #FFF;width: 100%;text-decoration:none; z-index:9999;}


免責聲明!

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



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