An example of the proportional representation of the CSS Layout Adaptive module

Source: Internet
Author: User
Tags pack

CSS, such as proportional division, in the CSS layout is more important, run the following code to view the case.

In addition to the examples of several methods, there is a better compatibility method, that is, the use of percentages, but add or subtract content, easy to disorder.

The code is as follows Copy Code

<! DOCTYPE html>
<meta charset= "Utf-8" >
<link media= "All" href= "/wp-content/themes/tonjayv2/style.css" rel= "stylesheet" >
<meta content= "Width=device-width, initial-scale=1, User-scalable=no, Minimal-ui" name= "viewport" >
<meta content= "Telphone=no" name= "Format-detection" >
<title> Division </title>
<style id= "Jsbin-css" >
. demo {line-height:44px; margin-bottom:20px text-align:center; Background-color: #0078e7; color: #fff;}
Flex-equal,. Flex-center,. Justify {display:-webkit-box; display:-ms-flexbox; display:-webkit-flex; display:flex;}
. flex-equal li {-webkit-box-flex:1;-ms-flex:1;-webkit-flex:1; flex:1;}
. table-equal {display:table; table-layout:fixed; width:100%;}
. table-equal li {Display:table-cell;}
. demo-center {border:1px solid #ccc; margin:20px; height:200px;}
. Demo-center. Children {background: #0078e7; color: #fff; width:150px; line-height:5; text-align:center;}
. flex-center {-webkit-box-pack:center;-ms-flex-pack:center;-webkit-justify-content:center; Justify-content: Center -webkit-box-align:center; -ms-flex-align:center; -webkit-align-items:center; Align-items:center; }
. translate-center {Position:relative}
. Translate-center. Children {position:absolute; top:50%; left:50%;-webkit-transform:translate ( -50%, -50%); transform : Translate (-50%,-50%);}
. justify {-webkit-box-pack:justify;-ms-flex-pack:justify;-webkit-justify-content:space-between; Justify-content: Space-between; Padding:0 10px; Background: #0078e7; Color: #fff; line-height:32px; }
</style>
<body>
<ul class= "flex-equal Demo" >
<li> Mobile </li>
<li> Contact Person </li>
<li> Information </li>
<li> Main Screen </li>
</ul>
<ul class= "flex-equal Demo" >
<li> Mobile </li>
<li> Contact Person </li>
<li> Information </li>
</ul>
<ul class= "table-equal Demo" >
<li> Mobile </li>
<li> Contact Person </li>
<li> Information </li>
<li> Main Screen </li>
</ul>
<ul class= "table-equal Demo" >
<li> Mobile </li>
<li> Contact Person </li>
<li> Information </li>
</ul>
<div class= "Flex-center demo-center" >
<div class= "Children" > child element horizontally centered </div>
</div>
<div class= "Translate-center demo-center" >
<div class= "Children" > child element horizontally centered </div>
</div>
<div class= "Justify" >
<span> Right Alignment </span></div>
</body>

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.