Css exercise-Multi-Element horizontal center in the container-flexbox layout application, css-flexbox

Source: Internet
Author: User

Css exercise-Multi-Element horizontal center in the container-flexbox layout application, css-flexbox

The sub-elements in such a parent element are centered.

You only need to add a style to the parent element.

{Display: flex; flex-direction: column; align-items: center ;}

Set to the flexbox layout, which is arranged vertically and centered in the third sentence.

If you want to set the distance between the three child elements, set the margin-top or margin-bottom;

If you want it to be adjusted automatically, you can add the style of the parent Element

{Justify-content: space-around ;}

In this way, the remaining space will be automatically allocated to the periphery of each element :)

At first, I thought there was no need to use sass. Now I found that many css codes are still highly reusable.

In this case, even if a small mixin parameter is saved, the parameter is automatically adjusted by default. The parameter can also be set to false, not automatically adjusted.

@ Mixin multi-elements-center ($ auto: true) {display: flex; flex-direction: column; align-items: center; @ if $ auto {justify-content: space-around ;}}

Make a little progress every day. Come on :)

For more information about flexbox, refer to the blog http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html of instructor Yan? Utm_source = tuicool

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.