卡和列表组内的Bootstrap 4中心项

时间:2018-05-26 16:08:53

标签: twitter-bootstrap bootstrap-4

我是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>

任何意见都会受到赞赏。

2 个答案:

答案 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)

试试这个。

&#13;
&#13;
<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;
&#13;
&#13;