Home > Article > Web Front-end > A detailed introduction to list groups in Bootstrap
This article will give you a detailed introduction to the list group in Bootstrap. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
List group is a new component of the Bootstrap framework. It can be used to create lists, vertical navigation and other effects. It can also be used with other components to create more beautiful components. . Related recommendations: "bootstrap Tutorial"
The basic list group looks like a list item with the list symbol removed and equipped with some specific styles. . The basic list group in the Bootstrap framework mainly consists of two parts:
☑ list-group: List group container, commonly used is the ul element, of course it can also be the ol or p element
☑ list-group-item: list item, commonly used is the li element, of course it can also be the p element
For the basic list group, there are not many style settings, mainly setting its spacing, borders and rounded corners. Wait
.list-group { padding-left: 0; margin-bottom: 20px; } .list-group-item { position: relative; display: block; padding: 10px 15px; margin-bottom: -1px; background-color: #fff; border: 1px solid #ddd; } .list-group-item:first-child { border-top-left-radius: 4px; border-top-right-radius: 4px; } .list-group-item:last-child { margin-bottom: 0; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px; }
<ul class="list-group"> <li class="list-group-item">HTML</li> <li class="list-group-item">CSS</li> <li class="list-group-item">javascript</li> <li class="list-group-item">bootstrap</li> <li class="list-group-item">jquery</li> </ul>
.list-group-item > .badge { float: right; } .list-group-item > .badge + .badge { margin-right: 5px; }
<ul class="list-group"> <li class="list-group-item"> <span class="badge">33</span>HTML </li> <li class="list-group-item"> <span class="badge">60</span>CSS </li> <li class="list-group-item"> <span class="badge">192</span>javascript </li> <li class="list-group-item"> <span class="badge">20</span>bootstrap </li> <li class="list-group-item"> <span class="badge">26</span>jquery </li> </ul>##Link
<li>
tags can form a list group that is all links (also note that the <ul></ul>
tags need to be replaced with <p></p>
tag). It is not necessary to add a parent element to each element in the list group<pre class="brush:css;toolbar:false;">a.list-group-item {
color: #555;
}
a.list-group-item .list-group-item-heading {
color: #333;
}
a.list-group-item:hover,
a.list-group-item:focus {
color: #555;
text-decoration: none;
background-color: #f5f5f5;
}</pre><pre class="brush:html;toolbar:false;"><div class="list-group">
<a href="#" class="list-group-item ">HTML</a>
<a href="#" class="list-group-item">CSS</a>
<a href="#" class="list-group-item">javascript</a>
<a href="#" class="list-group-item active">bootstrap</a>
<a href="#" class="list-group-item">jquery</a>
</div></pre>
##Button
instead of
<p></p> ), and there is no need to wrap a separate parent element for each button .
Be careful not to use the standard .btn
class<pre class="brush:html;toolbar:false;"><div class="list-group">
<button type="button" class="list-group-item ">HTML</button>
<button type="button" class="list-group-item">CSS</button>
<button type="button" class="list-group-item">javascript</button>
<button type="button" class="list-group-item">bootstrap</button>
<button type="button" class="list-group-item">jquery</button>
</div></pre>
Customized content
<div class="list-group"> <a href="##" class="list-group-item"> <h4 class="list-group-item-heading">HTML</h4> <p class="list-group-item-text">HTML被认为是前端知识体系里面最简单的知识,几年前,很多人都推荐在W3C上学习个几天就能够基本掌握。但随着HTML5和移动端的强势发展,HTML的技能点也越来越难。世上无难事,好学好总结...</p> </a> <a href="##" class="list-group-item"> <h4 class="list-group-item-heading">CSS</h4> <p class="list-group-item-text">CSS是前端工程师的基本功,但好多执迷于学习javascript的人的基本功并不扎实。可能一些人从w3school网站匆匆过了一遍,只是对CSS常用概念有一些表面上的理解,就一头扎进javascript的深坑里跳不出来。实际上,javascript中比较复杂的逻辑很有可能使用CSS几行样式就能解决问题,而且性能还好。CSS之所以能成为一门优雅的语言,以及有其对应的重构工程师的岗位,是因为这本语言本身就有很强的存在价值,且真正要理解它并不容易。从CSS禅意花园开始,写CSS成为一种艺术。从CSS2.1到3再到4,CSS所涵盖的内容及可实现的功能得到了极大的丰富,使得CSS的学习成本也越来越高。再多的知识,一个知识点一个知识点去学,总能学明白...</p> </a> <a href="##" class="list-group-item"> <h4 class="list-group-item-heading">javascript</h4> <p class="list-group-item-text">javascript就如同魔法一样,它是一门充满活力、简单易用的语言,又是一门具有许多复杂微妙技术的语言。即使是经验丰富的javascript开发者,如果没有认真学习的话,也无法真正理解它们,这就是javascript的矛盾之处。由于javascript不必理解就可以使用,因此通常来说很难真正理解语言本身,这就是我们面临的挑战。不满足于只是让代码正常工作,而是想要弄清楚为什么,勇于挑战这条崎岖颠簸的少有人走的路,拥抱整个javascript...</p> </a> </div><p></p>
State settings
.list-group-item.disabled, .list-group-item.disabled:hover, .list-group-item.disabled:focus { color: #777; background-color: #eee; } .list-group-item.active, .list-group-item.active:hover, .list-group-item.active:focus { z-index: 2; color: #fff; background-color: #428bca; border-color: #428bca; }
<div class="list-group"> <a href="#" class="list-group-item ">HTML</a> <a href="#" class="list-group-item">CSS</a> <a href="#" class="list-group-item">javascript</a> <a href="#" class="list-group-item active">bootstrap</a> <a href="#" class="list-group-item disabled">jquery</a> </div><p></p>
Colorful list group
<div class="list-group"> <a href="##" class="list-group-item">默认</a> <a href="##" class="list-group-item list-group-item-success">成功</a> <a href="##" class="list-group-item list-group-item-info">信息</a> <a href="##" class="list-group-item list-group-item-warning">警告</a> <a href="##" class="list-group-item list-group-item-danger">错误</a> </div><p></p>
More For more programming related knowledge, please visit: programming video
! ! <p></p>The above is the detailed content of A detailed introduction to list groups in Bootstrap. For more information, please follow other related articles on the PHP Chinese website!