答:使用text-center课程
您可以简单地使用Bootstrap的内置类.text-center来将所有内联元素(如文本,图像,链接等)居中对齐在诸如a<div>或<p>element之类的块元素内。
此解决方案在Bootstrap 3和Bootstrap 4版本中均可使用。这是一个例子:
例试试这个代码»
-<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Text Centering in Bootstrap</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-lg-12 text-center">
<h1>This is a heading</h1>
<p>This is simple paragraph of text.</p>
</div>
</div>
</div>
</body>
</html>
如果您觉得本文的内容对您的学习有所帮助:
关键字:
jQuery