Home > Web Front-end > H5 Tutorial > body text

How to make a mobile HTML5 list

一个新手
Release: 2017-09-06 10:21:19
Original
2064 people have browsed it


Preface

The CSS part of this series of articles will all be written in SASS syntax. If you don’t know SASS, it is recommended to read relevant tutorials, including my own "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 a mobile HTML5 list

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;}
    }
}
这里的单位全部使用的是,我们里面,已经将的字体大小设置为了,也就相当于正常情况下的10px.也就是说,上面的相当于.至于为什么这么写,请到本文开头的链接里面查看前面我写的文章中的解释. 
不会sass的,请先阅读sass相关教程.不要觉得难,一个小时保证学会,两天能玩的非常溜.
Copy after login

It’s still a simple list

First, let’s look at the rendering:

How to make a mobile HTML5 list

At first glance, this list is no different from the list above. However, if we take a closer look, we will find that the lines below are not straight.

Don’t be surprised , many times, designers have their own design concepts when designing like this. 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. The code will not be repeated 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 change of thinking. The loading li in demo1 will be Just assign the padding value to ul and li.


The above is the detailed content of How to make a mobile HTML5 list. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!