我正在创建一个投资组合网站,因为我需要将它交付给学校。 现在我正在尝试在网页上对齐中心我的按钮。我尝试了很多, 给li,ol和几个类:text-align:center,margin-right / margin-left:auto。似乎没什么用。我已经被困了超过1.5小时,所以如果你们中的一个人可以帮我解决这个问题,那就太棒了。
提前多多感谢!
诺亚
图片来源:https://imgur.com/EAQTdVM
HTML:
<div class="jumbotron">
<div class="container container-fluid">
<div class="row">
<div class="col-md-12 midden ">
<ol>
<li><a href="#" role="button">Contact</a></li>
<li><a href="#" role="button">Work</a></li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-3-offset-3">
<h1>Noah Wallaart</h1>
</div>
<div class="col-md-6">
</div>
</div>
</div>
</div>
Css:
.jumbotron {
background: url("/image/background4.JPG") no-repeat scroll center center / cover;
height: 720px;
margin-top: -20px;
}
div h1 {
font-family: 'Open Sans', sans-serif;
font-weight: 400;
font-size: 50px;
color: white !important;
text-align: center;
margin-top: 0.2em;
}
p {
font-family: 'Open Sans', sans-serif;
font-size: 30px;
color: white;
}
a {
text-decoration: none;
color: black;
font-family: 'Open Sans', sans-serif;
border: 3px solid black;
padding: 10px 20px 10px 20px;
display: inline;
float: left;
margin: 20px;
}
li {
display: inline;
float: right;
}
a:hover {
text-decoration: none;
background-color: #BDBFBD;
color: white;
border: 3px solid white;
}
/* Lookbook */
section {
width: 80%;
margin-left: auto;
margin-right: auto;
}
.row-margin {
margin-bottom: 20px;
margin-top: 20px;
}
.img-responsive {
display: block;
max-width: 100%;
height: auto;
}
.less-padding {
padding: 0px;
}
/* Buttons */
li a {
text-decoration: none;
color: white;
font-weight: 200 font-family: 'Roboto', sans-serif;
border: 0.15em solid white;
padding: 10px 20px 10px 20px;
display: inline;
float: left;
margin: 20px;
}
li {
display: inline;
width: 120px;
}
a:hover {
text-decoration: none;
background-color: #BDBFBD;
color: white;
border: 3px solid white;
margin-bottom: 0px;
margin-left: 20px;
}
答案 0 :(得分:1)
你的一些标记已关闭,&#39; midden&#39;不是一个字,你所要做的就是&#39; text-center&#39; 行,它工作正常。祝你好运!
<div class="jumbotron">
<div class="container container-fluid">
<div class="row text-center">
<div class="col-md-12">
<ul class="list-unstyled list-inline">
<li><a href="#" role="button">Contact</a></li>
<li><a href="#" role="button">Work</a></li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-3-offset-3">
<h1>Noah Wallaart</h1>
</div>
<div class="col-md-6">
</div>
</div>
</div>
</div>
答案 1 :(得分:0)
当您使用Bootstrap时,您不想覆盖框架提供的属性。相反,您需要做的就是为容器提供text-center
类,它应该可以正常工作。
<div class="jumbotron">
<div class="container container-fluid">
<div class="row">
<div class="col-md-12 text-center"> <!-- THIS LINE CHANGED -->
<ol>
<li><a href="#" role="button">Contact</a></li>
<li><a href="#" role="button">Work</a></li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-3-offset-3">
<h1>Noah Wallaart</h1>
</div>
<div class="col-md-6">
</div>
</div>
</div>
</div>
答案 2 :(得分:0)
我们开始添加这些样式
TCP
TURN
.midden ol {
margin-top: 0;
margin-bottom: 10px;
display: table;
margin: 0 auto;
}
.midden li{
float: none;
}