我的問題是,在320px寬的移動視圖中,一切都看起來不錯,但是當我手動開始放大時,導航不會保持居中。它只停留在屏幕的左側,當右側變大時。標題(h1)正常放大。導航「按鈕」應保持相同的寬度,直到768px寬的中斷。Div在放大時無法響應
body {
background-color: #FAFAFA;
font-family: helvetica;
margin: 0;
padding: 0;
}
.title {
text-align: center;
font-size: 1.5em;
margin-top: 30px;
margin-bottom: 30px;
color: #626262;
}
/*** NAVIGATION ***/
.main-nav li {
list-style: none;
}
.main-nav a {
text-decoration: none;
background-color: white;
font-weight: 600;
color: #626262;
padding-top: 15px;
padding-bottom: 15px;
font-size: .75em;
display: flex;
display: inline-block;
width: 280px;
margin-top: 5px;
text-align: center;
margin-left: -20px;
}
.profile-icon {
height: 125px;
width: 200px;
}
/****** PORTFOLIO ********/
.main-content {
background-color: #FFFFFF;
}
<header class="main-header">
<div class="container">
<h1 class="title">Title1</h1>
<ul class="main-nav">
<li><a href="#">HOME</a>
</li>
<li><a href="#">PORTFOLIO</a>
</li>
<li><a href="#">CONTACT</a>
</li>
</ul>
<img src="images/responsive-layout-profile.png" class="profile-icon">
<p>Text field</p>
</div>
</header>
<div class="main-content">
<h2 class="title-two">PORTFOLIO</h2>
</div>
請包括[最小的,verifyable示例](https://stackoverflow.com/help/mcve)在你的帖子 – TheThirdMan
這看起來像你在找什麼[鏈接](http://stackoverflow.com/questions/618097/how-do-you-easily-horizontally-center-a-div-using-css ) – Danimal