02 Mobile-Side Layouts

Source: Internet
Author: User

I. REM 1, meaning: When the px fixed width cannot accommodate different screen sizes, the layout needs to produce REM 2, REM and EM differences 2.1 rem:root, with the root node (HTML) as the reference size 2.2 em: Determine the size of 1em = 1font-size (parent) According to parent Font-size 3, change the HTML root element font-size as the screen width changes, thus controlling the REM value to achieve the corresponding effect (other HTML child elements width, etc. are REM)
function Autorem () {    var html = document.documentelement;     // DocumentElement returns the document root node HTML    var htmlwidth = Html.getboundingclientrect (). width;     // getboundingclientrect (). Width includes width + padding * 2 + border * 2    Html.style.fontSize = htmlwidth/16 + ' px ';     // 16 is based on their own page settings, non-fixed use, in order to facilitate subsequent calculations (IPhone5 in the 320 screen, just divisible, a screen just 16rem) }// from this, assuming the iPhone5 test, then the html font-size = 320/60 = 20px     1rem = 20px

Second, use less to calculate the REM 1, less use method: 1.1 Installs the little operating environment (not the CSS pre-compiler, but the browser does not have its compilation environment, need to compile it into a CSS file, thereby indirectly using CSS) 1.1 .1 NPM install-g Less See the less Chinese network: http://lesscss.cn/1.2 to write the less files needed locally after installing less, such as Style.less 1.3 Open the Command window and switch to the folder where less files are located, compile the corresponding CSS file LESSC style.less style.css (lessc less file name CSS file name) 2, use less computing power, calculate REM
@r:10rem;. main{    400/@r;     400px---->40rem}
Third, the use of border-sizing layout 1, the amount of size, width contains border and so on, and then normal settings border 2, Border-sizing:border-box; Let border in the width range (content contains width + padding + border) Next Chapter continued ...

02 Mobile-Side Layouts

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.