search
HomeWeb Front-endCSS TutorialDetailed explanation of how to use list-style and inline in CSS

In the past, only list-style:none; was used. I thought it was the only way. This method is just to remove the mark before li. Let me introduce CSS: list-style and Detailed explanation of inline usage, friends who are interested should not miss it I usually only focus on writing programs, such as p or span or ul li, etc., and I often encounter an inexplicable problem. My solution may be top: -10px or float:left. Of course, the problem can be solved. Just like taking a ship to New York and taking a plane to New York, the result is the same. They both arrive in New York, but in different ways. In comparison, flying is faster and more convenient. Choose for yourself!

display:inline; 
list-style:none outside none; 
white-space
:nowrap


First let’s look at the usage of list-style:

I used to only use list-style:none; this way, I thought it was the only way. Well, this method is just to remove the tag before li!

In fact list-style can be divided into three attributes: list-style-type list-style -position list-style-image

Look at what w3c says:

Definition and usage

list -style shorthand attribute sets all list properties in one declaration.

Description

This attribute is a shorthand attribute that covers all other list style attributes. Since it applies to all elements with display list-item, it can only be used on li elements in normal HTML and XHTML, but in fact it can be applied to any element and is inherited by list-item elements.

You can set the following properties in order:

list-style-type

list-style-position

list-style-image

You can not set one of the values, such as "list-style:circle inside;" is also allowed. Properties that are not set use their default values.

disc outside noneyesCSS1object.style.listStyle="decimal inside"

Example

Set the image as the list item markup in the list:

ul { list-style:square inside url('/i/arrow.gif'); }

Browser support

All browsers support the list-style attribute.

Note: The attribute value "inherit" is not supported by any version of Internet Explorer (including IE8).

CSS list-style-type attribute

Definition and usage

The list-style-type attribute sets the type of list item tag.
discyesCSS1object.style.listStyleType="square" instance

Set different list styles:

ul.circle {list-style-type:circle;} 
ul.square {list-style-type:square;}
ol.upper-roman {list-style-type:upper-roman;} 
ol.lower-alpha {list-style-type:lower-alpha;}

Browser support

All browsers support list -style-type attribute.

Note: Any version of Internet Explorer (including IE8) does not support the attribute values ​​"decimal-leading-zero", "lower-greek", "lower-latin", "upper-latin", " armenian", "georgian" or "inherit".
Possible values ​​CSS2 values: none No tag. disc default. Markers are filled circles. The circle mark is a hollow circle. The square mark is a solid square. decimal markers are numbers. decimal-leading-zero0 starting number mark. (01, 02, 03, etc.) lower-roman lowercase Roman numerals (i, ii, iii, iv, v, etc.) upper-roman uppercase Roman numerals (I, II, III, IV, V, etc.) lower-alphaThe marker is lower-alpha (a, b, c, d, e, etc.)upper-alphaThe marker is upper-alpha (A, B, C, D, E, etc.) ) lower-greek lowercase Greek letters (alpha, beta, gamma, etc.) lower-latin lowercase Latin letters (a, b, c, d, e, etc.) upper-latin uppercase Latin letters (A, B, C , D, E, etc. ) hebrew traditional Hebrew numbering armenian traditional Armenian numbering georgan traditional Georgian numbering (an, ban, gan, etc.) cjk-ideographic simple ideographic number hiragana mark is: a , i, u, e, o, ka, ki, etc. (Japanese katakana) katakana marks are: A, I, U, E, O, KA, KI, etc. (Japanese katakana) hiragana-iroha marks are: i, ro, ha, ni, ho, he, to, etc. (Japanese katakana) katakana-iroha marks are: I, RO, HA, NI, HO, HE, TO, etc. (Japanese katakana) CSS2.1 values: disc | circle | square | decimal | decimal-leading-zero | lower-roman | upper-roman | lower-greek | lower-latin | upper-latin | armenian | georgian | none | inherit

CSS list-style-position property

Definition and usage

list-style-position property sets where to place the list item markup .
Description

This attribute is used to declare the position of the list mark relative to the content of the list item. The outside flag is placed at a certain distance from the border of the list item, but this distance is undefined in CSS. Inside flags are treated as if they were inline elements inserted at the front of the list item's content.
outsideyesCSS1object.style.listStylePosition="inside" Example

Specifies the position of the list item mark in the list:

ul { list-style-position:inside; }

浏览器支持

所有浏览器都支持 list-style-position 属性。

注释:任何的版本的 Internet Explorer (包括 IE8)都不支持属性值 "inherit"。
可能的值 inside列表项目标记放置在文本以内,且环绕文本根据标记对齐。outside默认值。保持标记位于文本的左侧。列表项目标记放置在文本以外,且环绕文本不根据标记对齐。inherit规定应该从父元素继承 list-style-position 属性的值。

CSS list-style-image 属性

定义和用法

list-style-image 属性使用图像来替换列表项的标记。
说明

这个属性指定作为一个有序或无序列表项标志的图像。图像相对于列表项内容的放置位置通常使用 list-style-position 属性控制。

注释:请始终规定一个 "list-style-type" 属性以防图像不可用。
noneyesCSS1object.style.listStyleImage="url('/images/blueball.gif')"实例

把图像设置为列表中的项目标记:

ul { list-style-image:url("/i/arrow.gif"); list-style-type:square; }

浏览器支持

所有浏览器都支持 list-style-image 属性。

注释:任何的版本的 Internet Explorer (包括 IE8)都不支持属性值 "inherit"。
可能的值 URL图像的路径。none默认。无图形被显示。inherit规定应该从父元素继承 list-style-image 属性的值。

二. inline 的说明 :

display:block就是将元素显示为块级元素.

block元素的特点是:
总是在新行上开始;
高度,行高以及顶和底边距都可控制;
宽度缺省是它的容器的100%,除非设定一个宽度

,

,

,

,

The above is the detailed content of Detailed explanation of how to use list-style and inline in CSS. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
php如何使用PHP的Intl扩展?php如何使用PHP的Intl扩展?May 31, 2023 pm 08:10 PM

PHP的Intl扩展是一个非常实用的工具,它提供了一系列国际化和本地化的功能。本文将介绍如何使用PHP的Intl扩展。一、安装Intl扩展在开始使用Intl扩展之前,需要安装该扩展。在Windows下,可以在php.ini文件中打开该扩展。在Linux下,可以通过命令行安装:Ubuntu/Debian:sudoapt-getinstallphp7.4-

如何使用CakePHP中的数据库查询构造器?如何使用CakePHP中的数据库查询构造器?Jun 04, 2023 am 09:02 AM

CakePHP是一个开源的PHPMVC框架,它广泛用于Web应用程序的开发。CakePHP具有许多功能和工具,其中包括一个强大的数据库查询构造器,用于交互性能数据库。该查询构造器允许您使用面向对象的语法执行SQL查询,而不必编写繁琐的SQL语句。本文将介绍如何使用CakePHP中的数据库查询构造器。建立数据库连接在使用数据库查询构造器之前,您首先需要在Ca

php如何使用CI框架?php如何使用CI框架?Jun 01, 2023 am 08:48 AM

随着网络技术的发展,PHP已经成为了Web开发的重要工具之一。而其中一款流行的PHP框架——CodeIgniter(以下简称CI)也得到了越来越多的关注和使用。今天,我们就来看看如何使用CI框架。一、安装CI框架首先,我们需要下载CI框架并安装。在CI的官网(https://codeigniter.com/)上下载最新版本的CI框架压缩包。下载完成后,解压缩

php如何使用PHP的Ctype扩展?php如何使用PHP的Ctype扩展?Jun 03, 2023 pm 10:40 PM

PHP是一种非常受欢迎的编程语言,它允许开发者创建各种各样的应用程序。但是,有时候在编写PHP代码时,我们需要处理和验证字符。这时候PHP的Ctype扩展就可以派上用场了。本文将就如何使用PHP的Ctype扩展展开介绍。什么是Ctype扩展?PHP的Ctype扩展是一个非常有用的工具,它提供了各种函数来验证字符串中的字符类型。这些函数包括isalnum、is

Vue 中的单文件组件是什么,如何使用?Vue 中的单文件组件是什么,如何使用?Jun 10, 2023 pm 11:10 PM

作为一种流行的前端框架,Vue能够提供开发者一个便捷高效的开发体验。其中,单文件组件是Vue的一个重要概念,使用它能够帮助开发者快速构建整洁、模块化的应用程序。在本文中,我们将介绍单文件组件是什么,以及如何在Vue中使用它们。一、单文件组件是什么?单文件组件(SingleFileComponent,简称SFC)是Vue中的一个重要概念,它

php如何使用PHP的geoip扩展?php如何使用PHP的geoip扩展?Jun 01, 2023 am 09:13 AM

PHP是一种流行的服务器端脚本语言,它可以处理网页上的动态内容。PHP的geoip扩展可以让你在PHP中获取有关用户位置的信息。在本文中,我们将介绍如何使用PHP的geoip扩展。什么是PHP的GeoIP扩展?PHP的geoip扩展是一个免费的、开源的扩展,它允许你获取有关IP地址和位置信息的数据。该扩展可以与GeoIP数据库一起使用,这是一个由MaxMin

php如何使用PHP的DOM扩展?php如何使用PHP的DOM扩展?May 31, 2023 pm 06:40 PM

PHP的DOM扩展是一种基于文档对象模型(DOM)的PHP库,可以对XML文档进行创建、修改和查询操作。该扩展可以使PHP语言更加方便地处理XML文件,让开发者可以快速地实现对XML文件的数据分析和处理。本文将介绍如何使用PHP的DOM扩展。安装DOM扩展首先需要确保PHP已经安装了DOM扩展,如果没有安装需要先安装。在Linux系统中,可以使用以下命令来安

php如何使用PHP的socket编程功能?php如何使用PHP的socket编程功能?Jun 03, 2023 pm 09:51 PM

PHP是一门广泛应用于Web开发的编程语言,支持许多网络编程应用。其中,Socket编程是一种常用的实现网络通讯的方式,它能够让程序实现进程间的通讯,通过网络传输数据。本文将介绍如何在PHP中使用Socket编程功能。一、Socket编程简介Socket(套接字)是一种抽象的概念,在网络通信中代表了一个开放的端口,一个进程需要连接到该端口,才能与其它进程进行

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft