CSS3复习整理(box-sizing,column,flex,inline-box布局)_html/css_WEB-ITnose
- 布局除了 position,float之外,还可以使用 inline-box
- vertical-align 属性会影响到 inline-block元素,你可能会把它的值设置为top。
- 你需要设置每一列的宽度
- 如果HTML源代码中元素之间有空格,那么列与列之间会产生空隙 更多display
nav {display: inline-block;vertical-align: top;width: 25%;border: 1px solid yellowgreen;}.column {display: inline-block;vertical-align: top;width: 74%;border: 1px solid #66BAB7;}
Copy after login
清除浮动
.box { float: left; width: 200px; height: 100px; margin: 1em; border: 1px solid #66BAB7;}.after-box { clear: left;/*left和both都可以*/ border: 1px solid yellowgreen;}
Copy after loginhttp://zh.learnlayout.com/clearfix.html清除浮动水很深
column多列布局
.three-column{ border: 1px solid #66BAB7; padding: 1em; -webkit-column-count: 3; column-count: 3; -webkit-column-gap: 1em; column-gap: 1em;}
Copy after login大概这么个效果
box-sizing当你设置一个元素为 box-sizing: border-box 时,此元素的内边距和边框不再会增加它的宽度。
/*此时内边距和边框都不会增加它的宽度*/.simple { width: 500px; margin: 20px auto; border: 1px solid blue; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;}.fancy { width: 500px; margin: 20px auto; padding: 50px; border: 10px solid blue; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box;}
Copy after loginflex布局
- 简单的 flex 布局
.container {display: -webkit-flex;display: flex;background: lightblue;}nav {width: 200px;background: #66BAB7;}.flex-column {flex: 1;-webkit-flex: 1;background: yellowgreen;}
Copy after login - 复杂的 flex 布局
.container {display: flex;display: -webkit-flex;}.first {flex: initial;-webkit-flex: initial;width: 200px;min-width: 100px;background: red;}.none {flex: none;-webkit-flex: none;width: 200px;background: yellow;}.flex1 {flex: 1;-webkit-flex: 1;background: yellowgreen;}.flex2 {flex: 2;-webkit-flex: 2;background: #66BAB7;}
Copy after login - 居中 flex 布局 安利:http://zh.learnlayout.com/toc.html
.vertical-container {height: 500px;display: -webkit-flex;display: flex;-webkit-align-items: center;align-items: center;-webkit-justify-content: center;justify-content: center;}.div {width: 200px;height: 200px;border: 10px solid #66BAB7;}
Copy after login
- 简单的 flex 布局

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



In front-end interviews, we are often asked how to implement dice/mahjong layout using CSS. The following article will introduce to you how to use CSS to create a 3D dice (Flex and Grid layout implement 3D dice). I hope it will be helpful to you!

What are the common properties of flex layout? Specific code examples are required. Flex layout is a powerful tool for designing responsive web page layouts. It makes it easy to control the arrangement and size of elements in a web page by using a flexible set of properties. In this article, I will introduce the common properties of Flex layout and provide specific code examples. display: Set the display mode of the element to Flex. .container{display:flex;}flex-directi

During development, the flex attribute is often used to act on the child elements of the flexible box, such as: flex:1 or flex: 1 1 auto. So how does this attribute control the behavior of the element? What exactly does flex:1 mean? Let this article take you through a thorough understanding of the flex property!

This article will give you an in-depth understanding of the three properties of CSS Flex layout: flex-grow, flex-shrink, and flex-basis. I hope it will be helpful to you!

How to achieve the sliding menu effect through CSSFlex elastic layout. In web design, sliding menu is a common interactive effect, which can make the web page more smooth and beautiful. This article will teach you how to use CSSFlex elastic layout to achieve this effect, and provide specific code examples. CSSFlex is a new layout method that can easily achieve various complex layout effects. It controls the layout by setting the properties of the container and child elements, of which the flex property is one of the most important properties. First, we need a

Title: Detailed explanation of grid spacing and border processing methods in CSSFlex elastic layout Introduction: CSSFlex elastic layout is a modern page layout method that allows web pages to automatically adapt to different screen sizes and is flexible and responsive. When using CSSFlex flexible layout, we often encounter situations where we need to set grid spacing and borders. This article will introduce in detail the grid spacing and border processing methods in CSSFlex flexible layout, and provide specific code examples. 1. Grid spacing

This article will take you through the Flex layout in CSS3, I hope it will be helpful to you!

CSS adaptive layout attribute optimization tips: flex and grid In modern web development, implementing adaptive layout is a very important task. With the popularity of mobile devices and the diversification of screen sizes, it is an essential requirement to ensure that the website can be displayed well on various devices and adapt to different screen sizes. Fortunately, CSS provides some powerful properties and techniques for implementing adaptive layout. This article will focus on two commonly used properties: flex and grid, and provide specific code examples.
