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

Sample code for changing the color of a png image through a CSS3 filter

This method uses the drop-shadow filter in CSS3 t...

How to make JavaScript sleep or wait

Table of contents Overview Checking setTimeout() ...

Implementation of building Kubernetes cluster with VirtualBox+Ubuntu16

Table of contents About Kubernetes Basic environm...

Introduction to MySQL method of deleting table data with foreign key constraints

When deleting a table or a piece of data in MySQL...

Implementation of Docker cross-host network (overlay)

1. Docker cross-host communication Docker cross-h...

JavaScript to display hidden form text

This article shares the specific code of JavaScri...

Brief analysis of the MySQL character set causing database recovery errors

Importing data with incorrect MySQL character set...

Detailed explanation of Vue filters

<body> <div id="root"> <...

Three examples of blur background effects using CSS3

Let’s not start with the introduction and get str...

Nginx local directory mapping implementation code example

Sometimes you need to access some static resource...

Summary of various postures of MySQL privilege escalation

Table of contents 1. Write Webshell into outfile ...