1
0
Fork 0
mirror of https://github.com/twbs/bootstrap.git synced 2022-11-09 12:25:43 -05:00

add list group component

This commit is contained in:
Mark Otto 2013-03-30 16:07:50 -07:00
parent 731903a175
commit 2a9604fdd2
8 changed files with 424 additions and 0 deletions

View file

@ -163,12 +163,25 @@
</ul>
</li>
<li><a href="#media">Media object</a></li>
<li>
<a href="#list-group">List group</a>
<ul class="nav">
<li><a href="#list-group-basic">Basic list group</a></li>
<li><a href="#list-group-chevrons">With chevrons</a></li>
<li><a href="#list-group-badges">With badges</a></li>
<li><a href="#list-group-badges-chevrons">With badges and chevrons</a></li>
<li><a href="#list-group-linked">Linked items</a></li>
<li><a href="#list-group-custom-content">Custom content</a></li>
<!-- <li><a href="#list-group-pic">Leading picture</a></li> -->
</ul>
</li>
<li>
<a href="#panels">Panels</a>
<ul class="nav">
<li><a href="#panels-basic">Basic panel</a></li>
<li><a href="#panels-heading">Panel with heading</a></li>
<li><a href="#panels-alternatives">Contextual alternatives</a></li>
<li><a href="#panels-list-group">With list groups</a></li>
</ul>
</li>
<li><a href="#wells">Wells</a></li>

View file

@ -2944,6 +2944,80 @@ fieldset[disabled] .btn-link:focus {
z-index: 1051;
}
.list-group {
margin: 0 0 20px;
background-color: #ffffff;
}
.list-group-item {
position: relative;
display: block;
padding: 10px 30px 10px 15px;
margin-bottom: -1px;
border: 1px solid #dddddd;
}
.list-group-item:first-child {
border-top-right-radius: 4px;
border-top-left-radius: 4px;
}
.list-group-item:last-child {
margin-bottom: 0;
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
}
.list-group-item-heading {
margin-top: 0;
margin-bottom: 5px;
}
.list-group-item-text {
margin-bottom: 0;
line-height: 1.3;
}
a.list-group-item .list-group-item-heading {
color: #333;
}
a.list-group-item .list-group-item-text {
color: #555;
}
a.list-group-item:hover,
a.list-group-item:focus {
text-decoration: none;
background-color: #f5f5f5;
}
a.list-group-item.active {
z-index: 2;
color: #ffffff;
background-color: #428bca;
border-color: #428bca;
}
a.list-group-item.active .list-group-item-heading,
a.list-group-item.active .list-group-item-text {
color: inherit;
}
.list-group-item > .badge,
.list-group-item > .glyphicon-chevron-right {
float: right;
margin-right: -15px;
}
.list-group-item > .glyphicon-chevron-right {
margin-right: -15px;
}
.list-group-item > .glyphicon + .badge {
margin-right: 5px;
}
.panel {
padding: 15px;
margin-bottom: 20px;
@ -3006,6 +3080,23 @@ fieldset[disabled] .btn-link:focus {
border-color: #bce8f1;
}
.list-group-flush {
margin: 15px -15px -15px;
}
.list-group-flush .list-group-item {
border-width: 1px 0;
}
.list-group-flush .list-group-item:first-child {
border-top-right-radius: 0;
border-top-left-radius: 0;
}
.list-group-flush .list-group-item:last-child {
border-bottom: 0;
}
.well {
min-height: 20px;
padding: 19px;

View file

@ -311,6 +311,7 @@ section > ul li {
.bs-docs-example > .jumbotron:last-child,
.bs-docs-example > .alert:last-child,
.bs-docs-example > .panel:last-child,
.bs-docs-example > .list-group:last-child,
.bs-docs-example > .well:last-child {
margin-bottom: 0;
}
@ -339,6 +340,10 @@ section > ul li {
margin: 0;
}
/* List groups */
.bs-docs-example > .list-group {
max-width: 400px;
}
/* Navbar examples */
.bs-navbar-top-example,

View file

@ -4369,6 +4369,172 @@ For example, <code>&lt;section&gt;</code> should be wrapped as inline.
<!-- List group
================================================== -->
<div class="bs-docs-section" id="list-group">
<div class="page-header">
<h1>List group</h1>
</div>
<p class="lead">List groups are a flexible and powerful component for displaying not only simple lists of elements, but complex ones with custom content.</p>
<h3 id="list-group-basic">Basic list group</h3>
<p>The most basic list group is simply an unordered list with list items, and the proper classes. Build upon it with the options that follow, or your own CSS as needed.</p>
<div class="bs-docs-example">
<ul class="list-group">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
</div>
{% highlight html linenos %}
<ul class="list-group">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
{% endhighlight %}
<h3 id="list-group-chevrons">With chevrons</h3>
<p>Adding Glyphicon chevrons are automatically moved to the right.</p>
<div class="bs-docs-example">
<ul class="list-group">
<li class="list-group-item">
<span class="glyphicon glyphicon-chevron-right"></span>
Cras justo odio
</li>
<li class="list-group-item">
<span class="glyphicon glyphicon-chevron-right"></span>
Dapibus ac facilisis in
</li>
<li class="list-group-item">
<span class="glyphicon glyphicon-chevron-right"></span>
Morbi leo risus
</li>
</ul>
</div>
{% highlight html linenos %}
<ul class="list-group">
<li class="list-group-item">
<span class="glyphicon glyphicon-chevron-right"></span>
Cras justo odio
</li>
</ul>
{% endhighlight %}
<h3 id="list-group-badges">With badges</h3>
<p>Add the badges component to any list group item and it will automatically be positioned on the right.</p>
<div class="bs-docs-example">
<ul class="list-group">
<li class="list-group-item">
<span class="badge">14</span>
Cras justo odio
</li>
<li class="list-group-item">
<span class="badge">2</span>
Dapibus ac facilisis in
</li>
<li class="list-group-item">
<span class="badge">1</span>
Morbi leo risus
</li>
</ul>
</div>
{% highlight html linenos %}
<ul class="list-group">
<li class="list-group-item">
<span class="badge">14</span>
Cras justo odio
</li>
</ul>
{% endhighlight %}
<h3 id="list-group-badges-chevrons">With badges and chevrons</h3>
<p>Why not both?</p>
<div class="bs-docs-example">
<ul class="list-group">
<li class="list-group-item">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="badge">14</span>
Cras justo odio
</li>
<li class="list-group-item">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="badge">2</span>
Dapibus ac facilisis in
</li>
<li class="list-group-item">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="badge">1</span>
Morbi leo risus
</li>
</ul>
</div>
{% highlight html linenos %}
<ul class="list-group">
<li class="list-group-item">
<span class="glyphicon glyphicon-chevron-right"></span>
<span class="badge">14</span>
Cras justo odio
</li>
</ul>
{% endhighlight %}
<h3 id="list-group-linked">Linked list group</h3>
<p>Linkify list group items by using anchor tags instead of list items (that also means a parent <code>&lt;div&gt;</code> instead of an <code>&lt;ul&gt;</code>. No need for individual parents around each element.</p>
<div class="bs-docs-example">
<div class="list-group">
<a href="#" class="list-group-item active">Cras justo odio</a>
<a href="#" class="list-group-item">Dapibus ac facilisis in</a>
<a href="#" class="list-group-item">Morbi leo risus</a>
<a href="#" class="list-group-item">Porta ac consectetur ac</a>
<a href="#" class="list-group-item">Vestibulum at eros</a>
</div>
</div>
{% highlight html linenos %}
<div class="list-group">
<a href="#" class="list-group-item active">Cras justo odio</a>
<a href="#" class="list-group-item">Dapibus ac facilisis in</a>
<a href="#" class="list-group-item">Morbi leo risus</a>
<a href="#" class="list-group-item">Porta ac consectetur ac</a>
<a href="#" class="list-group-item">Vestibulum at eros</a>
</div>
{% endhighlight %}
<h3 id="list-group-custom-content">Custom content</h3>
<p>Add nearly any HTML within, even for linked list groups like the one below.</p>
<div class="bs-docs-example">
<div class="list-group">
<a href="#" class="list-group-item active">
<h4 class="list-group-item-heading">List group item heading</h4>
<p class="list-group-item-text">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
</a>
<a href="#" class="list-group-item">
<h4 class="list-group-item-heading">List group item heading</h4>
<p class="list-group-item-text">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
</a>
<a href="#" class="list-group-item">
<h4 class="list-group-item-heading">List group item heading</h4>
<p class="list-group-item-text">Donec id elit non mi porta gravida at eget metus. Maecenas sed diam eget risus varius blandit sit amet non magna.</p>
</a>
</div>
</div>
{% highlight html linenos %}
<div class="list-group">
<a href="#" class="list-group-item active">
<h4 class="list-group-item-heading">List group item heading</h4>
<p class="list-group-item-text">...</p>
</a>
</div>
{% endhighlight %}
</div>
<!-- Panels
================================================== -->
<div class="bs-docs-section" id="panels">
@ -4430,6 +4596,31 @@ For example, <code>&lt;section&gt;</code> should be wrapped as inline.
<div class="panel panel-warning">...</div>
<div class="panel panel-danger">...</div>
<div class="panel panel-info">...</div>
{% endhighlight %}
<h3 id="panels-list-group">With list groups</h3>
<p>Easily include full-width <a href="./docs/#list-group">list groups</a> within any panel.</p>
<div class="bs-docs-example">
<div class="panel">
<!-- Default panel contents -->
<div class="panel-heading">Panel heading</div>
<p>Some default panel content here. Nulla vitae elit libero, a pharetra augue. Aenean lacinia bibendum nulla sed consectetur. Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
<!-- List group -->
<ul class="list-group list-group-flush">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
</div>
</div>
{% highlight html linenos %}
<div class="panel">
<div class="panel-heading">Panel heading</div>
Panel content
</div>
{% endhighlight %}
</div>

1
less/bootstrap.less vendored
View file

@ -30,6 +30,7 @@
@import "component-animations.less";
@import "glyphicons.less";
@import "dropdowns.less";
@import "list-group.less";
@import "panels.less";
@import "wells.less";
@import "close.less";

94
less/list-group.less Normal file
View file

@ -0,0 +1,94 @@
//
// List groups
// --------------------------------------------------
// Base class
//
// Easily usable on <ul>, <ol>, or <div>.
.list-group {
// No need to set list-style: none; since .list-group-item is block level
margin: 0 0 20px; // reset all margins because ul and ol
background-color: @list-group-bg;
}
// Individual list items
// -------------------------
.list-group-item {
position: relative;
display: block;
padding: 10px 30px 10px 15px;
// Place the border on the list items and negative margin up for better styling
margin-bottom: -1px;
border: 1px solid @list-group-border;
}
// Round the first and last items
.list-group-item:first-child {
.border-top-radius(@border-radius-base);
}
.list-group-item:last-child {
margin-bottom: 0;
.border-bottom-radius(@border-radius-base);
}
// Custom content options
// -------------------------
.list-group-item-heading {
margin-top: 0;
margin-bottom: 5px;
}
.list-group-item-text {
margin-bottom: 0;
line-height: 1.3;
}
// Linked list items
// -------------------------
// Custom content within linked items
a.list-group-item {
.list-group-item-heading {
color: #333;
}
.list-group-item-text {
color: #555;
}
}
// Hover state
a.list-group-item:hover,
a.list-group-item:focus {
text-decoration: none;
background-color: @list-group-hover-bg;
}
// Active class on item itself, not parent
a.list-group-item.active {
z-index: 2; // Place active items above their siblings for proper border styling
color: @list-group-active-text;
background-color: @list-group-active-bg;
border-color: @list-group-active-border;
// Force color to inherit for custom content
.list-group-item-heading,
.list-group-item-text {
color: inherit;
}
}
// Chevrons and badges within list items
// -------------------------
.list-group-item > .badge,
.list-group-item > .glyphicon-chevron-right {
float: right;
margin-right: -15px;
}
.list-group-item > .glyphicon-chevron-right {
margin-right: -15px;
}
.list-group-item > .glyphicon + .badge {
margin-right: 5px;
}

View file

@ -58,3 +58,21 @@
border-color: @panel-info-border;
}
}
// List groups in panels
.list-group-flush {
margin: 15px -15px -15px;
.list-group-item {
border-width: 1px 0;
// Remove border radius for top one
&:first-child {
.border-top-radius(0);
}
// But keep it for the last one
&:last-child {
border-bottom: 0;
}
}
}

View file

@ -293,6 +293,17 @@
@progress-bar-info-bg: @brand-info;
// List group
// -------------------------
@list-group-bg: #fff;
@list-group-border: #ddd;
@list-group-border-radius: @border-radius-base;
@list-group-hover-bg: #f5f5f5;
@list-group-active-text: #fff;
@list-group-active-bg: @link-color;
@list-group-active-border: @list-group-active-bg;
// Panels
// -------------------------
@panel-bg: #fff;