Enables top and bottom pinning of mobile end, content area optimization effect

Source: Internet
Author: User

The effect of fixing the top and bottom is very easy, and many people will choose this way, that is, the top position:fixed, the bottom is also position:fixed. The effect is like the following two images, the container area is covered with the entire screen, and the scroll bar is also scrolled throughout the screen, adjust the content area only height adjustment.

In fact, there is a way to achieve better results, that is, the content area only in the middle of the top and bottom, the content and scroll bar is only the middle area scrolling

Implementation code:

<meta name= "viewport" content= "width=device-width,initial-scale=1.0, maximum-scale=1.0, user-scalable=0" > Added to the page.

<div class= "Top" > <p> top </p> </div> <div class= "Container-wrap" > <d IV class= "Container" > <p> mobile Device The default viewport is layout viewport, which is more than the width of the screen viewport, but in the development of mobile device website, we need the IDE Al Viewport. So how do you get ideal viewport? It's time for the meta tag to appear. The default viewport for mobile devices is the layout viewport, which is the viewport that is wider than the screen, but when it comes to the development of mobile device sites, we need ideal viewport. So how do you get ideal viewport? It's time for the meta tag to appear. The default viewport for mobile devices is the layout viewport, which is the viewport that is wider than the screen, but when it comes to the development of mobile device sites, we need ideal viewport. So how do you get ideal viewport? It's time for the meta tag to appear. The default viewport for mobile devices is the layout viewport, which is the viewport that is wider than the screen, but when it comes to the development of mobile device sites, we need ideal viewport. So how do you get ideal viewport? It's time for the meta tag to appear. The default viewport for mobile devices is the layout viewport, which is the viewport that is wider than the screen, but when it comes to the development of mobile device sites, we need ideal viewport. So how do you get ideal viewport? It's time for the meta tag to appear. The default viewport for mobile devices is the layout viewport, which is the viewport that is wider than the screen, but when it comes to the development of mobile device sites, we need ideal viewport. So how do you get ideal viewport? It's time for the meta tag to appear. The default viewport for mobile devices is the layout viewport, which is the viewport that is wider than the screen, but in the development of mobile device sites, we need toWant is ideal viewport. So how do you get ideal viewport? It's time for the meta tag to appear. The default viewport for mobile devices is the layout viewport, which is the viewport that is wider than the screen, but when it comes to the development of mobile device sites, we need ideal viewport. So how do you get ideal viewport? It's time for the meta tag to appear. </p> </div> </div> <div class= "Footer" > <ul> <li> Home &lt ;/li> <li> Malls </li> <li> me </li> </ul> </div>

Css:

<style> *{padding:0;margin:0;font-family: ' Microsoft Yahei ';} . Top{width:100%;height:60px;background-color: #999;position:fixed;top:0;}. Top P{color: #333; line-height:60px;text-align:center;font-size:22px;} . container-wrap{Height:100%;overflow:hidden;}. container{position:absolute;top:60px;bottom:60px; overflow-y: scroll;Overflow-x: Hidden;}        . container p{font-size:20px;line-height:32px;padding:10px 15px;} . footer{width:100%;height:60px;border-top:1px solid #999;position:fixed;bottom:0;Background-color: #fff;}        . footer Ul{list-style:none;}    . Footer ul Li{float:left;width:33.3%;text-align:center;line-height:60px;color: #333;} </style>

This implementation will enable the content to scroll only in Contianer. Very simple ~

Enables top and bottom pinning of mobile end, content area optimization effect

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.