bootstrap怎么让表单居中
展开全部
置如下样式是可以使表格内容居中的,没有居中的原因可能是你还设置了其他的样式(把这个样式覆盖了):
.table th, .table td {
text-align: center;
height:38px;
}
你可以新建一个单独的html文件复制如下代码来测试一下:
<!DOCTYPE html>
<html>
<head>
<title>
Bootstrap Table
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css"
rel="stylesheet">
<style>
.table th, .table td {
text-align: center;
height:38px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-10">
<h1>
表格(内容居中)
</h1>
<table class="table" >
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<td>2</td>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<td>3</td>
<td colspan="2">Larry the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.2.0/bootstrap.min.js"></script>
</body>
</html>
.table th, .table td {
text-align: center;
height:38px;
}
你可以新建一个单独的html文件复制如下代码来测试一下:
<!DOCTYPE html>
<html>
<head>
<title>
Bootstrap Table
</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="http://cdn.bootcss.com/bootstrap/3.2.0/css/bootstrap.min.css"
rel="stylesheet">
<style>
.table th, .table td {
text-align: center;
height:38px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-10">
<h1>
表格(内容居中)
</h1>
<table class="table" >
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<td>2</td>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<td>3</td>
<td colspan="2">Larry the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.2.0/bootstrap.min.js"></script>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询