[英]Why is there a white space on the right side of my website?
我有一個網站,頁面右側有一個空白區域。 它使頁面可以水平滾動。 我添加了overflow: hidden
到 css。當 web 在 Chrome 中打開時,它工作得很好。 然而,當我嘗試用 safari 或手機打開它時,空白又回來了。
網站截圖可以在這里看到: https://drive.google.com/file/d/1UryAukJhRS4yTHBPuJ8F_3uqeVcdWrln/view?usp=sharing
我的 html:
{% load static %}
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<link rel="stylesheet" href="{% static 'web/style.css' %}">
<!-- Add icon library -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>Eximia Denim Co.</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-transparent fixed-top">
<div class="container">
<a class="navbar-brand" href="{% url 'web:index' %}" id="brand-name">Eximia Denim Co.</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- <a class="brand" style="margin: 0; float: none; text-align:center" href="#">
<img src="https://i.imgur.com/GyjZFjL.png" width="100px" />
</a> -->
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="{% url 'web:index' %}">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'web:about' %}">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'web:contact' %}">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://shopee.co.id/shop/292750693/">Order</a>
</li>
</ul>
</div>
</div>
</nav>
<section id='highlight-1'>
</section>
<a href="https://shopee.co.id/shop/292750693/">
<img src="{% static 'web/images/promo2020.jpg' %}" id="promo-1">
</a>
<section id='cards-1'>
<div class="row">
<div class="col-md-6" id="card-1">
<h1>Unique. Soft.</h1>
<img src="{% static 'web/images/soft.jpg' %}"class="center">
</div>
<div class="col-md-6" id="card-2">
<h1>Fashionable. Tough.</h1>
<img src="{% static 'web/images/hard.jpg' %}" class="center">
</div>
</div>
</section>
<section>
<img src="{% static 'web/images/new-product-banner.jpg' %}" id="new-product">
</section>
<footer class="footer">
<br>
<div class="row justify-content-center">
<a href="https://www.instagram.com/eximia.denim/" class="fa fa-instagram fa-2x"></a>
<a href="https://wa.me/628114538300" class="fa fa-whatsapp fa-2x"></a>
</div>
<div class="footer-copyright text-center py-3">
© 2020 Copyright
</div>
</footer>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
</body>
</html>
樣式.css:
.navbar {
position: absolute;
min-height: 70px;
}
.navbar a {
font-size: 20px;
color: white !important;
font-weight: lighter;
text-decoration: none;
transition: 0.3s;
}
.navbar a:hover {
opacity: 0.5;
}
body {
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
#brand-name {
font-size: 24px;
font-weight: normal;
text-decoration: none;
}
#highlight-1 {
height: 100vh;
background-image: url("images/highlight-1.jpg");
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
width: 100%;
padding: 0 7%;
display: table;
margin: 0;
max-width: none;
}
#promo-1 {
max-width: 100%;
}
#cards-1 {
width: 100%;
}
#cards-1 #card-1 {
text-align: center;
height: 100%;
background-color: #f4b41a;
}
#cards-1 #card-1 h1 {
padding-top: 40px;
color: #143d59;
}
#cards-1 #card-2 {
text-align: center;
height: 100%;
background-color: #143d59;
}
#cards-1 #card-2 h1 {
padding-top: 40px;
color: #f4b41a;
}
.center {
display: block;
margin-left: auto;
margin-right: auto;
max-width: 100%;
}
#new-product {
max-width: 100%;
}
.footer {
background-color: #222222;
color: white;
width: 100%;
}
.fa {
color: white !important;
margin-right: 20px;
margin-left: 20px;
}
.fa:hover {
text-decoration: none;
}
@media (max-width: 767px) {
}
任何幫助將不勝感激。
編輯:終於修復了網站。
添加到我的 style.css:
* {
overflow-x: hidden;
}
嘗試設置margin: 0;important;
在.row
當我遇到同樣的問題時,我設法以這種方式解決了它。
希望能有所幫助
*PS 如果你不把你的內容放在 .col inside of .row 中,就會發生這種情況
嘗試將此添加到您的 CSS 中:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
讓我知道這個是否奏效!
刪除margin-left: -15px和margin-right: -15px for your.row class 您可以在#cards-1 部分 >.row 中找到
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.