Mobile Terminal webpage size fixed area scroll/overflow: auto mobile terminal does not display scroll bar, overflowauto

Source: Internet
Author: User

Mobile Terminal webpage size fixed area scroll/overflow: auto mobile terminal does not display scroll bar, overflowauto

For mobile Web pages, to implement functions

Preliminary Idea: Use dl to set fixed width and height for dl and then use overflow: auto to scroll to display the complete content

Problem 1: the scroll bar is not displayed, but it can be rolled normally,

Solution

<Span style = "font-family: Microsoft YaHei; font-size: 18px; color: #333333;">/* -- scroll bar --*/:: -webkit-scrollbar {width: 5px; height: 5px; background-color: # fff; }::-webkit-scrollbar: hover {background-color: # eee ;}:: -webkit-resizer {}::-webkit-scrollbar-thumb {-webkit-border-radius: 4px; background-color: # ccc; height: 10px ;}:: -webkit-scrollbar-thumb: hover {background-color: # aaa; }::-webkit-scrollbar-thumb: active {background-color: #888 ;}</span>
Problem 2: When the function implemented by this method slides to the bottom of the block, the whole page slides up.

Solution: Use the iscroll plug-in to scroll

Html code

<Span style = "font-family: Microsoft YaHei; font-size: 18px; color: #333333; "> <div class =" wrapper "> <dl id =" scroller "> <dt> all business districts </dt> <dd> Business District 1 </dd> <dd> business district 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd>/ dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> <dd> commercial area 1 </dd> </dl> </div> </span>
Css code
<span style="font-family:Microsoft YaHei;font-size:18px;color:#333333;">.wrapper{ position: relative; left: 0; top: 40px; width: 40%; height: 150px; overflow: hidden;}.wrapper dl{ position: absolute; }</span>
Js Code

<span style="font-family:Microsoft YaHei;font-size:18px;color:#333333;"><script type="text/javascript" src="js/iscroll.js" ></script><script type="text/javascript">var myScroll;function loaded () {myScroll = new IScroll('.wrapper', { scrollY: true, scrollbars: true });}document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);</script></span>

Perfect solution!

 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.