


Three common page layouts in CSS: double-wing layout, glue layout, and left and right column layout
This article will introduce to you three common CSS page layouts: double flying wing layout, adhesion layout, and left and right column layout. I hope it will be of some help to you.
(Recommended tutorial: CSS video tutorial)
1. Left and right column layout
1. The code is as follows
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>两列布局</title> <!--左边列固定,右边列自适应--> <style type="text/css"> *{ padding: 0; margin: 0; } body{ min-width: 600px; } .lef{ width: 100px; height: 400px; background: hotpink; float: left; } .rig{ height: 400px; background: yellowgreen; margin-left: 50px; /*给right开启BFC 利用BFC的特性: bfc的区域不会与浮动的box重叠*/ /* 溢出内容部分被切割,所以使用省略号表示 */ overflow: hidden; /*出现省略号需要四个设置: * display: block; * overflow: hidden; * white-space: nowrap; * text-overflow: ellipsis * */ /* white-space: nowrap; */ /* text-overflow: ellipsis; */ } .con{ width: 300px; margin: 0 auto; } </style> </head> <body> <div class="con"> <div class="lef">left</div> <div class="rig"> lzprightrightrightrightrightrightrightrightrightrightrightrightrightright <br /> rightrightrightrightrightrightrightrightrightrightrightrightrightright <br /> rightrightrightrightrightrightrightrightrightrightrightrightrightright <br /> rightrightrightrightrightrightrightrightrightrightrightrightrightright <br /> </div> </div> </body> </html>
The effect is as follows:
2. Necessary instructions
The outer container con if For a fixed width, the overflow: hidden; of the right element is necessary, otherwise the font in the rig will not be in the rig.
If the con width of the outer container is 100%, or the default, the overflow: hidden; of the right element is optional, and the page will not be affected.
2. Adhesion layout
1. The code is as follows:
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,maximum-scale=1.0,minimum-scale=1.0"/> <title>粘连布局</title> <!-- 当页面中无内容或内容不足一屏时,footer在页面最底部显示 当页面内容很多一屏装不下时,footer紧随内容其后显示 --> <style type="text/css"> *{ padding: 0; margin: 0; } html, body{ height: 100%; } .wrap{ /* 设置wrap的最小高度,当main元素中的内容较少或者为空时,也能保持100%高度 */ min-height: 100%; background: yellowgreen; text-align: center; } .main{ /*main的height值由内容决定*/ /*当内容不足一屏时,下面的设置不会撑开父元素wrap,此时wrap的min-height设置生效, * 当内容刚好一屏时,下面的设置开始撑开父容器,其height值为100%+50px。 * 拉开这50px的原因是防止footer遮盖住main内容,这个值不是固定死的,由footer的高度值决定 * 为footer向上填充margin-top: -50px;做准备 * */ padding-bottom: 50px; } .footer{ height: 50px; line-height: 50px; background: deeppink; text-align: center; margin-top: -50px; } </style> </head> <body> <div class="wrap"> <div class="main"> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> main<br />main<br />main<br />main<br /> mlzpain<br /> </div> </div> <!--footer元素放在wrap外--> <div class="footer"> footer </div> </body> </html>
3. Double flying wings The layout
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>双飞翼三列布局</title> <style type="text/css"> /*清除浏览器默认样式*/ *{ padding: 0; margin: 0; } /*设置body的最小宽度*/ body{ min-width: 600px; } /*左浮动*/ .fl{ float: left; } /*双飞翼三列布局*/ .mid{ width: 100%; } .lef{ width: 200px; background: mediumpurple; margin-left: -100%; } .rig{ width: 200px; background: orangered; margin-left: -200px; } .inn_mid{ margin: 0 200px; background: pink; } /*等高布局*/ /* 先使子元素溢出父盒子范围,然后在父盒子中设置overflow:hidden; 清除溢出部分,从而由原来的不等高达到等高效果 */ .mid, .lef, .rig{ padding-bottom: 10000px; margin-bottom: -10000px; } .con{ border: 5px solid deepskyblue; overflow: hidden; } </style> </head> <body> <div class="con"> <div class="mid fl"> <div class="inn_mid"> <h4 id="middle">middle</h4> <h4 id="middle">middle</h4> <h4 id="middle">middle</h4> </div> </div> <div class="lef fl">left</div> <div class="rig fl">right</div> </div> </body> </html>
has the following effect:
For more programming-related knowledge, please visit: Programming Teaching! !
The above is the detailed content of Three common page layouts in CSS: double-wing layout, glue layout, and left and right column layout. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Using Bootstrap in Vue.js is divided into five steps: Install Bootstrap. Import Bootstrap in main.js. Use the Bootstrap component directly in the template. Optional: Custom style. Optional: Use plug-ins.

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

There are two ways to create a Bootstrap split line: using the tag, which creates a horizontal split line. Use the CSS border property to create custom style split lines.

WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

There are several ways to insert images in Bootstrap: insert images directly, using the HTML img tag. With the Bootstrap image component, you can provide responsive images and more styles. Set the image size, use the img-fluid class to make the image adaptable. Set the border, using the img-bordered class. Set the rounded corners and use the img-rounded class. Set the shadow, use the shadow class. Resize and position the image, using CSS style. Using the background image, use the background-image CSS property.

To set up the Bootstrap framework, you need to follow these steps: 1. Reference the Bootstrap file via CDN; 2. Download and host the file on your own server; 3. Include the Bootstrap file in HTML; 4. Compile Sass/Less as needed; 5. Import a custom file (optional). Once setup is complete, you can use Bootstrap's grid systems, components, and styles to create responsive websites and applications.

How to use the Bootstrap button? Introduce Bootstrap CSS to create button elements and add Bootstrap button class to add button text

To adjust the size of elements in Bootstrap, you can use the dimension class, which includes: adjusting width: .col-, .w-, .mw-adjust height: .h-, .min-h-, .max-h-
