<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;}