我是Bootstrap和编码的新手。我想知道如何将下面的所有列表项目集中在一起? (包括卡片)。在询问之前我对Stackoverflow做了一些研究,但是无法使其工作。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="card">
<div class="card-header">Featured</div>
<div class="list-group list-group-flush"> <a href="#" class="list-group-item"><strong>MongoDB</strong>: NoSQL database</a>
<a href="#" class="list-group-item"><strong>Angular</strong>: JavaScript framework </a>
<a href="#" class="list-group-item"><strong>Express</strong>: Framework for Node</a>
<a href="#" class="list-group-item"><strong>Node.js</strong>: JavaScript environment</a>
<a href="#" class="list-group-item"><strong>ES2015</strong>: Latest version of JavaScript</a>
<a href="#" class="list-group-item"><strong>Babel</strong>: JavaScript compiler</a>
</div>
</div>
</div>
</div>
</div>
任何意见都会受到赞赏。
答案 0 :(得分:0)
这是代码:
<style>
.list-group-item,.card-header {
margin: 0 auto; /* Added */
/* Added */
}
</style>
<body>
<div class="container">
<div class="row">
<div class="col-lg-8">
<div class="card ">
<div class="card-header">Featured</div>
<div class="list-group list-group-flush"> <a href="#" class="list-group-item"><strong>MongoDB</strong>: NoSQL database</a>
<a href="#" class="list-group-item"><strong>Angular</strong>: JavaScript framework </a>
<a href="#" class="list-group-item"><strong>Express</strong>: Framework for Node</a>
<a href="#" class="list-group-item"><strong>Node.js</strong>: JavaScript environment</a>
<a href="#" class="list-group-item"><strong>ES2015</strong>: Latest version of JavaScript</a>
<a href="#" class="list-group-item"><strong>Babel</strong>: JavaScript compiler</a>
</div>
</div>
</div>
</div>
</div>
</body>
你可以查看小提琴:https://jsfiddle.net/ms3d25jt/
答案 1 :(得分:0)
试试这个。
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<div class="container">
<div class="card text-center">
<div class="card-header">
Featured
</div>
<div class="list-group list-group-flush"> <a href="#" class="list-group-item"><strong>MongoDB</strong>: NoSQL database</a>
<a href="#" class="list-group-item"><strong>Angular</strong>: JavaScript framework </a>
<a href="#" class="list-group-item"><strong>Express</strong>: Framework for Node</a>
<a href="#" class="list-group-item"><strong>Node.js</strong>: JavaScript environment</a>
<a href="#" class="list-group-item"><strong>ES2015</strong>: Latest version of JavaScript</a>
<a href="#" class="list-group-item"><strong>Babel</strong>: JavaScript compiler</a>
</div>
</div>
</div>
&#13;