Flex Layout Method (CSS3 stretch layout tutorial)

Source: Internet
Author: User
This article is mainly for everyone to introduce the flex layout of CSS3 flexible layout, with a certain reference value, interested in small partners can refer to

. Container{align-items:center;justify-content:center;display:flex;background:white URL (image/baby.jpg) no-repeat Center;background-size:auto 100%;}. Text{display:flex; Align-items:center;height:3rem;color:white;font-family:helvetica, Sans-serif;font-size:1.5rem ; font-weight:bold;text-transform:uppercase;text-shadow:0 0 1.2rem Hsla (0,100%,100%,.4); box-shadow:0 0 1.5rem Hsla (0,100%,0%,.4); Border-radius:. 5rem;}

Adapt to various versions:

 HTML {height:100%;font-size:62.5%;/* 10px with default settings */} body {margin:0;height:100%;width:100%;/* WID Th needed for Firefox *//* old Flexbox-webkit and Firefox. For backwards compatibility */display:-webkit-box; Display:-moz-box;/* middle-aged flexbox. Needed for IE */display:-ms-flexbox;/* new Flexbox. Chrome (prefix), Opera, upcoming browsers without */display:-webkit-flex;display:flex;/* old flexbox:box-* */-webkit-bo X-align:center; -moz-box-align:center;/* Middle flexbox:flex-* */-ms-flex-align:center;/* New flexbox:various property names */-webkit -align-items:center;align-items:center;-webkit-box-pack:center; -moz-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center;justify-content:center;background:                White URL (image/baby.jpg) no-repeat Center;background-size:auto 100%;} /* Flexbox added below to show it works with anonymous boxes (e.g. text) as well it isn't needed to center the HEA      Ding itself.  Rest of the styles is just to make the demo pretty and can is ignored. */H1 {display:-webkit-box; display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;- Webkit-box-align:center; -moz-box-align:center;-ms-flex-align:center;-webkit-justify-content:center;justify-content:center;- Webkit-box-pack:center; -moz-box-pack:center;-ms-flex-pack:center;-webkit-align-items:center;align-items:center;height:10rem;padding:0 3rem;/* Background-color:hsla (0, 100%, 0%,. 9); */color:white;font-family:helvetica, Sans-serif;font-size:5rem; /* Font shorthand doesn ' t work with REM in IE10 */text-transform:uppercase;text-shadow:0 0 1.2rem hsla (0, 100%, 100%,. 4 ); box-shadow:0 0 1.5rem hsla (0, 100%, 0,. 4); Border-radius:. 5rem;

Alignment settings: Set element alignment in the container instead of setting the element itself.

Units: px pixels, relative to the resolution; the font size of the text within the current object, and the REM (root em) text font size for the Web root element.

Students who need to learn CSS, please pay attention to the PHP Chinese web CSS video tutorial, many CSS online video tutorials can be viewed for free!

Related Article

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.