Home > Web Front-end > CSS Tutorial > Detailed explanation of how to use list-style and inline in CSS

Detailed explanation of how to use list-style and inline in CSS

黄舟
Release: 2017-06-29 09:49:40
Original
2178 people have browsed it

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
Copy after login


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'); }
Copy after login

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;}
Copy after login

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; }
Copy after login

浏览器支持

所有浏览器都支持 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; }
Copy after login

浏览器支持

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

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

二. inline 的说明 :

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

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

,

,

,
,

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