Table of Contents
How to make various lists on H5 mobile terminal (1)
Preface
The simplest list
html code
SASS code
It’s still a simple list
Summary
Home Web Front-end H5 Tutorial How to make various lists on H5 mobile terminal (1)

How to make various lists on H5 mobile terminal (1)

Mar 10, 2017 pm 04:28 PM

How to make various lists on H5 mobile terminal (1)

Preface

With the development of the mobile Internet, A large number of front-end personnel have switched from PC to mobile. However, a lot of PC-side front-end experience is not applicable to mobile. A blog post I wrote a few days ago "Summary of some basic knowledge points of mobile H5" received a lot of clicks. Therefore, FungLeo decided that in the next time, I will launch a series of tutorials around the mobile terminal.

The CSS part of this series of articles will all be written in SASS syntax. If you don’t If you know SASS, it is recommended to read relevant tutorials, including my "Summary of SASS Learning Experience with CSS Precompilation Technology" tutorial.
This series of articles will refer to the two basic documents reset.scss and mixin.scss, which are used to reset browser styles, and some basic SASS code blocks. Since the code is longer, please refer to the "Mobile Terminal Series Blog Basics reset.scss and mixin.scss》Get.

My level is limited and my ability is average, so there will inevitably be errors and omissions in the article. Therefore, everyone is welcome to leave comments in the article. I will report it as soon as possible Response within. Thank you all.

The simplest list

First, let’s make the simplest list. The effect we want to achieve is as shown in the figure below:

How to make various lists on H5 mobile terminal (1)

As shown above, what we want to achieve is such a simple list. This is not difficult at all.

html code

<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>list 1</title>
<link rel="stylesheet" href="../style/style.css">
</head>
<body>
<p class="list_1">
    <ul>
        <li><a href="">这是一个列表1</a></li>
        <li><a href="">这是一个列表2</a></li>
        <li><a href="">这是一个列表3</a></li>
        <li><a href="">这是一个列表4</a></li>
        <li><a href="">这是一个列表5</a></li>
        <li><a href="">这是一个列表6</a></li>
        <li><a href="">这是一个列表7</a></li>
        <li><a href="">这是一个列表8</a></li>
    </ul></p></body></html>
Copy after login

What needs to be explained here is that the mobile terminal You must add <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" /> code. Otherwise, the mobile browser will treat it as a PC version of the web page, which is scalable.

It is recommended that the server, database, back-end program, front-end HTML and CSS all be unified into utf-8 encoding .Avoid garbled codes caused by encoding.

SASS code

.list_1 {    ul {}
    li {
        border-bottom: 1px solid #ddd;padding:0 1.6rem;        
        a {display: block;height: 4rem;line-height: 4rem;overflow: hidden;font-size: 1.4rem;}
    }
}
Copy after login

All units here use rem, wereset In .scss, the font size of html has been set to 62.5%, which is equivalent to 10px under normal circumstances. In other words, the above 1.6 rem is equivalent to 16px. As for why it is written this way, please go to the link at the beginning of this article to see the explanation in the article I wrote earlier.
If you don’t know sass, please read the sass related tutorials first. Don’t think it’s difficult. You can definitely learn it in one hour and you can play it very smoothly in two days.

It’s still a simple list

First of all , let’s take a look at the rendering:

How to make various lists on H5 mobile terminal (1)

At first glance, this list is no different from the list above. However, if we look carefully, we will find that the lines below are not The top one.

Don’t be surprised. Many times, designers have their own design concepts when designing this way. As front-end personnel, we must faithfully restore some of the small details of the designer’s design. Even if you think This is a bit unnecessary. Haha.

html code is exactly the same as the first example. I will not repeat the code here

SASS code

.list_1 {    ul {padding-left: 1.6rem;}
    li {        border-bottom: 1px solid #ddd;padding-right: 1.6rem;        
    a {display: block;height: 4rem;line-height: 4rem;overflow: hidden;font-size: 1.4rem;}
    }
}
Copy after login

In fact, it is just a slight transformation Here’s an idea. Just assign the padding value on the loaded li in demo1 to ul and li.

Summary

Okay, through these two demos, we should Some basic situations have been understood. FungLeo will gradually increase the complexity of the list in the following chapters. Presenting you with a variety of different lists.

These are two appetizers, very It's simple. What needs to be explained is the following:

  1. Do not set the width of any element, because this is a list that occupies one line

  2. Without setting the width, you can set the inner padding, which will not cause any problems.

  3. It is necessary to handle the hidden overflow to prevent the title from being too long and causing line breaks.

The above is the detailed content of How to make various lists on H5 mobile terminal (1). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Table Border in HTML Table Border in HTML Sep 04, 2024 pm 04:49 PM

Guide to Table Border in HTML. Here we discuss multiple ways for defining table-border with examples of the Table Border in HTML.

HTML margin-left HTML margin-left Sep 04, 2024 pm 04:48 PM

Guide to HTML margin-left. Here we discuss a brief overview on HTML margin-left and its Examples along with its Code Implementation.

Nested Table in HTML Nested Table in HTML Sep 04, 2024 pm 04:49 PM

This is a guide to Nested Table in HTML. Here we discuss how to create a table within the table along with the respective examples.

HTML Table Layout HTML Table Layout Sep 04, 2024 pm 04:54 PM

Guide to HTML Table Layout. Here we discuss the Values of HTML Table Layout along with the examples and outputs n detail.

HTML Input Placeholder HTML Input Placeholder Sep 04, 2024 pm 04:54 PM

Guide to HTML Input Placeholder. Here we discuss the Examples of HTML Input Placeholder along with the codes and outputs.

Moving Text in HTML Moving Text in HTML Sep 04, 2024 pm 04:45 PM

Guide to Moving Text in HTML. Here we discuss an introduction, how marquee tag work with syntax and examples to implement.

HTML Ordered List HTML Ordered List Sep 04, 2024 pm 04:43 PM

Guide to the HTML Ordered List. Here we also discuss introduction of HTML Ordered list and types along with their example respectively

HTML onclick Button HTML onclick Button Sep 04, 2024 pm 04:49 PM

Guide to HTML onclick Button. Here we discuss their introduction, working, examples and onclick Event in various events respectively.

See all articles