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
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
This method uses the drop-shadow filter in CSS3 t...
Click on the anchor link to scroll smoothly and a...
Table of contents Overview Checking setTimeout() ...
Table of contents About Kubernetes Basic environm...
When deleting a table or a piece of data in MySQL...
1. Docker cross-host communication Docker cross-h...
Table of contents HTTP hijacking, DNS hijacking a...
This article shares the specific code of JavaScri...
Importing data with incorrect MySQL character set...
<body> <div id="root"> <...
In order to prevent non-compliant data from enter...
Let’s not start with the introduction and get str...
Preface After installing MySQL and Navicat, when ...
Sometimes you need to access some static resource...
Table of contents 1. Write Webshell into outfile ...