Adaptive layout is becoming more and more common in practical applications. Today I will share several demos of adaptive layout, mainly the floating holy grail layout (also called double-wing layout, which is mainly implemented by floating and negative margin). I did not introduce the absolute positioning layout because I think you can understand the following examples. The absolute positioning layout is also very simple. PS: The Holy Grail layout has an advantage, which is that it conforms to the concept of progressive enhancement in front-end development. Because the browser parses the DOM from top to bottom, the Holy Grail layout can put the important content section of the page in front of the DOM and parse it first, while the secondary aside content is placed at the back of the DOM and parsed later. The following example can solve most of the adaptive layout problems in practical applications. Interested students can study it. The code is as follows: 1. Fixed on the left, adaptive on the right (implementation of the Holy Grail layout): Copy code The code is as follows:<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> <style type="text/css"> body{margin:0;padding:0} .wrap{ width:100%; float:left} .content{ height:300px;background:green; margin-left:200px} .right{ width:200px; height:300px; background:red; float:left; margin-left:-100%} </style> </head> <body> <div class="wrap"> <div class="content">content</div> </div> <div class="right">aside</div> </body> </html> 2. Fixed on the right, adaptive on the left (implementation of the Holy Grail layout): Copy code The code is as follows:<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> <style type="text/css"> body{margin:0;padding:0} .wrap{ width:100%; float:left} .content{ height:300px;background:green; margin-right:200px} .right{ width:200px; height:300px; background:red; float:left; margin-left:-200px;} </style> </head> <body> <div class="wrap"> <div class="content">content</div> </div> <div class="right">aside</div> </body> </html> 3. Fixed left and right sides, adaptive middle: Copy code The code is as follows:<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> <style type="text/css"> body{margin:0;padding:0} .wrap{ width:100%; float:left} .content{ height:300px;background:green; margin-left:200px;margin-right:200px} .left{ width:200px; height:300px; float:left; background:yellow; margin-left:-100%} .right{ width:200px; height:300px; background:red; float:left; margin-left:-200px} </style> </head> <body> <div class="wrap"> <div class="content">content</div> </div> <div class="left">aside</div> <div class="right">aside</div> </body> </html> |
<<: 3 Tips You Must Know When Learning JavaScript
>>: Introduction to commonly used MySQL commands in Linux environment
Docker is becoming more and more popular. It can ...
Preface When writing front-end pages, we often us...
Optimization ideas There are two main optimizatio...
This article example shares the specific code of ...
This article example shares the specific code of ...
1. What is master-slave replication? The DDL and ...
summary Project description format <img src=&q...
Table of contents 1. Scene loading 2. Find Node 1...
Table of contents Example Method 1: delete Method...
What are XHTML tags? XHTML tag elements are the b...
Table of contents Preface Actual Combat 1. No loc...
Table of contents 1. Download MySQL 2. Unzip the ...
If you often use FTP server in your study or work...
Usually the pictures uploaded by users need to be...
Table of contents K8S Advanced Features Advanced ...