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
Here is an introduction to changing the password ...
Table of contents 2. Tried methods 2.1 keep-alive...
Today, when developing, I encountered a method wh...
Before introducing the GROUP BY and HAVING clause...
Table of contents 1. List traversal 2. The role o...
Scenario simulation: Some domestic companies need...
By default, Nginx supports only one SSL certifica...
I am a beginner in SQL and thought that the insta...
This article example shares the specific code of ...
Use HTML CSS and JavaScript to implement a simple...
I can log in to MYSQL normally under the command ...
Download the installation package from the offici...
This article introduces several methods of implem...
Table of contents Global variable globalData Page...
Table of contents 1. Install vue-video-player 2. ...