bootstrap supports several list styles

青灯夜游
Release: 2021-11-11 11:27:40
Original
3845 people have browsed it

bootstrap supports 6 list styles: 1. ul unordered list; 2. ol ordered list; 3. Removed list; 4. Inline list, which refers to changing the vertical list into a horizontal list, and Remove the bullets and keep the list displayed horizontally; 5. dl definition list; 6. Horizontal definition list.

bootstrap supports several list styles

The operating environment of this tutorial: Windows7 system, bootsrap3.3.7 version, DELL G3 computer

List--Introduction

In HTML documents, there are three main types of list structures: ordered lists, unordered lists, and definition lists. The specific tags used are described as follows: Unordered list

<ul>
    <li>…</li>
</ul>
Copy after login

Ordered list

<ol>
    <li>…</li>
</ol>
Copy after login

Definition list

<dl>
    <dt>…</dt>
    <dd>…</dd>
</dl>
Copy after login

Bootstrap provides six forms of lists based on usual usage:

☑ Unordered list

☑ Ordered list

☑ Go to point list

☑ Inline list

☑ Definition list

☑ Horizontal definition list

Next, let’s learn this provided by Bootstrap Six ways to use lists

<!DOCTYPE HTML>
< html>
	<head>
		<meta charset="utf-8">
		<title>列表--简介</title>
		<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
	</head>
	<body>
		<ul>
			<li>无序列表信息1</li>
			<li>无序列表信息2</li>
			<li>无序列表信息3</li>
		</ul>
		<ol>
			<li>有序列表信息1</li>
			<li>有序列表信息2</li>
			<li>有序列表信息3</li>
		</ol>
		<dl>
			<dt>定义列表标题</dt>
			<dd>定义列表信息1</dd>
			<dd>定义列表信息2</dd>
		</dl>
	</body>
	</html>
Copy after login

Lists--unordered lists, ordered lists

bootstrap supports several list stylesbootstrap supports several list styles

Unordered lists The usage of ordered lists is the same as what we usually use (unordered lists use ul, ordered lists use ol tags). In terms of style, Bootstrap has only made some subtle optimizations on this basis. Please view bootstrap.css for the source code. Lines 569 to 579 of the file:

ul,
ol {
  margin-top: 0;
  margin-bottom: 10px;
}
ul ul,
ol ul,
ul ol,
ol ol {
  margin-bottom: 0;
}
Copy after login

From the source code, we can know that Bootstrap only made some adjustments to the margin for the list.

List nesting

Lists can also be nested in Bootstrap.

List--Go to the list

You can see that by default in Bootstrap, unordered list and ordered list It has bullet points, but in many cases in actual work, our lists do not need this number, such as when using unordered lists for navigation. Bootstrap has been very considerate for many developers. By adding a class name ".list-unstyled" to the unordered list, the default list style can be removed. /*For the source code, please view lines 580~583 of the bootstrap.css file*/

.list-unstyled {
padding-left: 0;
list-style: none;
}
Copy after login

As can be seen from the example, in addition to the item number, the default left padding# of the list will also be included. ##Alsocleared0.

List--inline list

Bootstrap implements an inline list by adding the class name "

.list-inline" just like a list. To put it simply, That is replace the vertical list with a horizontal list, and remove the bullets (numbers) , keep the horizontal display. It can also be said that inline lists are born for creating horizontal navigation. /*View the source code for lines 584~593 of the bootstrap.css file*/

.list-inline {
padding-left: 0;
margin-left: -5px;
list-style: none;
}
.list-inline > li {
display: inline-block;
padding-right: 5px;
padding-left: 5px;
}
Copy after login

Look at an example:

<ul class="list-inline">
    <li>W3cplus</li>
    <li>Blog</li>
    <li>CSS3</li>
    <li>jQuery</li>
    <li>PHP</li>
</ul>
Copy after login

List--Definition list

bootstrap supports several list styles

For the definition list, Bootstrap did not make too many adjustments. It just adjusted

line spacing, margin and font bold Effect. /*For the source code, please view lines 594~607 of the bootstrap.css file*/

dl {
margin-top: 0;
margin-bottom: 20px;
}
dt,
dd {
line-height: 1.42857143;
}
dt {
font-weight: bold;
}
dd {
margin-left: 0;
}
Copy after login

For the use of definition lists, it is actually very simple. It is the same as our previous method of using definition lists:

<dl>
    <dt>W3cplus</dt>
    <dd>一个致力于推广国内前端行业的技术博客</dd>
    <dt>seashen.cn</dt>
    <dd>一个真心在做HTML5教育的网站</dd>
</dl>
Copy after login

List--Horizontal definition list

bootstrap supports several list styles

Horizontal definition list Just like the inline list, Bootstrap can add the class name "

. dl-horizontal" implements horizontal display effects for definition lists. /*For the source code, please view lines 608~621 of the bootstrap.css file*/

@media (min-width: 768px) {
.dl-horizontal dt {
float: left;
width: 160px;
overflow: hidden;
clear: left;
text-align: right;
text-overflow: ellipsis;
white-space: nowrap;
  }
.dl-horizontal dd {
margin-left: 180px;
  }
}
Copy after login

A media query is added here. In other words, only when the screen

is larger than 768px, adding the class name ".dl-horizontal" will have the horizontal definition list effect. The main methods of implementation: 1. Set dt to a left float and set a width of 160px 2. Set dd to a margin-left value of 180px to achieve a horizontal effect 3. When the title width exceeds 160px , three ellipses

will be displayed and their usage is as follows:

<dl class="dl-horizontal">
    <dt>W3cplus</dt>
    <dd>一个致力于推广国内前端行业的技术博客。它以探索为己任,不断活跃在行业技术最前沿,努力提供高质量前端技术博文</dd>
    <dt>seashen.cn</dt>
    <dd>一个专业的HTML5网站</dd>
    <dt>我来测试一个标题,我来测试一个标题</dt>
    <dd>我在写一个水平定义列表的效果,我在写一个水平定义列表的效果</dd>
</dl>
Copy after login
When you shrink your browser screen, the horizontal definition list will return to its original state.

Recommended study: "

bootstrap usage tutorial"

The above is the detailed content of bootstrap supports several list styles. 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!