我試圖做使用Flexbox的靜態HTML CSS &網頁,但我的conten不適合在Chrome瀏覽器窗口。我可以水平滾動,因此我的瀏覽器窗口大小的水平空間更大。元素滿溢視口,導致水平滾動
這是顯示問題的截圖。包裝兩邊的邊距相同,但內容不適合瀏覽器窗口的100%寬度,所以我可以水平滾動,這不是我想要的。
我試過在Safari相同的代碼和完美的作品。這是Chrome上的flexbox問題還是我錯過了什麼?謝謝。
這是我的HTML:
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSS Stylesheets-->
<link rel="stylesheet" href="css/vendor/normalize.css">
<link rel="stylesheet" href="css/vendor/font-awesome.css">
<link rel="stylesheet" href="css/vendor/devicons.css">
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<!-- Header -->
<header>
<nav>
<ul>
<li><a href="#" class="active">ELEMENT 1</a></li>
<li><a href="#">ELEMENT 2</a></li>
<li><a href="#">ELEMENT 3</a></li>
</ul>
</nav>
</header>
<!-- Main Content -->
<main>
<div class="main-wrapper">
<div class="search-bar">
<form>
<input type="text" placeholder="Search">
</form>
</div>
</div>
</main>
</body>
這是我SCSS:
/* 2. HEADER */
nav {
width: 100%;
text-align: center;
background-color: $dark-grey;
& ul {
max-width: $width;
margin: auto;
display: flex;
}
& li {
flex: 1 1 0;
}
& a {
display: block;
color: $white-alpha;
padding: 30px 0px;
transition: color 0.3s ease;
}
& a:hover {
color: $white;
transition: color 0.3s ease;
}
& a.active {
color: $white;
}
}
/* 3. MAIN*/
main {
background-color: $light-grey;
padding: 30px 0px;
}
.main-wrapper {
max-width: $width;
margin: auto;
}
/* 3.1. SEARCH BAR */
.search-bar {
padding-bottom: 20px;
& input {
height: 45px;
width: 100%;
border-bottom: 1px solid $medium-grey;
border-radius: 2px;
text-indent: 20px;
}
}
這將有很大的幫助,如果你可以做一個codepen或複製的jsfiddle這個問題。 –