Let's talk about the usage of box-align and box-pack attributes in CSS

青灯夜游
Release: 2021-02-03 11:00:06
forward
2183 people have browsed it

Let's talk about the usage of box-align and box-pack attributes in CSS

[Recommended tutorial:CSS video tutorial]

The box-align and box-pack attributes in css can be used to set elements within the box s position.

Note: The value of dispaly of the parent element of the element that needs to be aligned must be box

When the box-align value is center, the child element is vertically centered

box-pack attribute Specifies where to place the child element when the box is larger than the size of the child element. This property specifies the horizontal position within the horizontal box, and the vertical position within the vertical box.

For horizontal boxes, when the box-pack value is center, the child elements are horizontally centered

HTML code:

div1
Copy after login

CSS code:

div{ border: solid black 1px; } #parent1{ width: 100%; height: 500px; display: -webkit-box; display: -moz-box; -webkit-box-align: center; -moz-box-align: center; -moz-box-pack: center; -webkit-box-pack: center; }
Copy after login

When box -When the pack value is justify, the child elements are dispersed and aligned

HTML code:

div2
div3
div4
div5
div6
Copy after login

CSS code:

#parent2{ width: 100%; height: 500px; display: -webkit-box; display: -moz-box; -webkit-box-align: center; -moz-box-align: center; -moz-box-pack: justify; -webkit-box-pack: justify; }
Copy after login

The effect is as follows:

Lets talk about the usage of box-align and box-pack attributes in CSS

For more knowledge about computer programming, please visit:Programming Video! !

The above is the detailed content of Let's talk about the usage of box-align and box-pack attributes in CSS. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!