The difference and usage of single-line and double-line layout in Flex mobile layout

The difference and usage of single-line and double-line layout in Flex mobile layout

Here is a single-line layout using ul>li for layout

<ul class="local-nav">
        <li>
            <a href="#">
                <span class="local-nav-icon-icon1"></span> Attractions </a>
        </li>
        <li>
            <a href="#">
                <span class="local-nav-icon-icon2"></span> Tickets and entertainment </a>
        </li>
        <li>
            <a href="#">
                <span class="local-nav-icon-icon3"></span> Food Forest </a>
        </li>
        <li>
            <a href="#">
                <span class="local-nav-icon-icon4"></span> Tours nearby </a>
        </li>
        <li>
            <a href="#">
                <span class="local-nav-icon-icon5"></span> Day Tours </a>
        </li>
    </ul>

The CSS style is as follows. Due to laziness, the text is added directly at the end without being put into the tag. First define the overall

.local-nav li [class^="local-nav-icon"]

In the li, the class name starting with local-nav-icon writes the style, and then replaces different sprite images in different li.

.local-nav {
    display: flex;
    height: 64px;
    background-color: #fff;
    border-radius: 8px;
    margin: 3px 4px;
}

.local-nav li {
    flex: 1;
}

.local-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 12px;
}

.local-nav li [class^="local-nav-icon"] {
    width: 32px;
    height: 32px;
    margin-top: 8px;
    background: url(../images/localnav_bg.png) no-repeat 0 0;
    background-size: 32px auto;
}

.local-nav li .local-nav-icon-icon2 {
    background-position: 0 -32px;
}

.local-nav li .local-nav-icon-icon3 {
    background-position: 0 -64px;
}

.local-nav li .local-nav-icon-icon4 {
    background-position: 0 -96px;
}

.local-nav li .local-nav-icon-icon5 {
    background-position: 0 -128px;
}

In the double-row layout, the following is the writing method for one li, and the other li are the same.

<ul class="subnav-entry">
        <li>
            <a href="#" title="Free Travel">
                <span class="subnav-entry-icon1"></span>
                <span>Free travel</span>
            </a>
        </li>

The CSS style is as follows

.subnav-entry {
    display: flex;
    border-radius: 8px;
    margin: 0px 4px;
    background-color: #fff;
    flex-wrap: wrap;
}
.subnav-entry li {
    /* flex: 1; */
    flex: 20%;
}

Here the flex is 20%, which allows every 5 to be arranged in a row and sets line breaks. Each line will automatically wrap if it doesn't fit

.subnav-entry a {
    display: flex;
     flex-direction: column;
    align-items: center;
}

Here, the y-axis is used as the main axis and the x-axis is used as the lateral axis.

.subnav-entry [class^="subnav-entry-icon"] {
    width: 28px;
    height: 28px;
    margin-top: 4px;
    background: url(../images/subnav-bg.png) no-repeat;
    background-size: 28px auto;
}

.subnav-entry-icon2 {
    background: url(../images/subnav-bg.png) no-repeat;
    background-size: 28px auto;
}

The above method is easier to understand and remember.

Summarize

This concludes this article about the differences and detailed usage of single-line and double-line layouts in Flex mobile layout. For more relevant Flex mobile layout content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

<<:  Application nesting of HTML ul unordered tables

>>:  6 Ways to Elegantly Handle Objects in JavaScript

Recommend

Vue Page Stack Manager Details

Table of contents 2. Tried methods 2.1 keep-alive...

Sharing several methods to disable page caching

Today, when developing, I encountered a method wh...

A brief discussion on the use of GROUP BY and HAVING in SQL statements

Before introducing the GROUP BY and HAVING clause...

v-for directive in vue completes list rendering

Table of contents 1. List traversal 2. The role o...

Example of configuring multiple SSL certificates for a single Nginx IP address

By default, Nginx supports only one SSL certifica...

js code to realize multi-person chat room

This article example shares the specific code of ...

JS implements a simple counter

Use HTML CSS and JavaScript to implement a simple...

Solution to IDEA not being able to connect to MySQL port number occupation

I can log in to MYSQL normally under the command ...

MySQL 8.0.19 Installation Tutorial

Download the installation package from the offici...

Several methods of implementing two fixed columns and one adaptive column in CSS

This article introduces several methods of implem...

Data storage implementation method in WeChat applet

Table of contents Global variable globalData Page...

How to use vue-video-player to achieve live broadcast

Table of contents 1. Install vue-video-player 2. ...