首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我为移动端调整页脚大小时,页脚与页面底部之间有一块空白。

当我为移动端调整页脚大小时,页脚与页面底部之间有一块空白。
EN

Stack Overflow用户
提问于 2019-08-05 04:10:44
回答 3查看 95关注 0票数 0

我在页脚有这个问题,因为我把这些属性添加到了我的背景图像中,如果我不添加这些属性,那么页面在背景图像和页脚之间就会有一个空白,有人能帮忙吗?:

空白处-底部:-100px;填充-底部: 0;

CSS和HTML代码如下:

代码语言:javascript
复制
@import url('https://fonts.googleapis.com/css?family=Gloria+Hallelujah:100,200,300,400,500,600,700|Special+Elite:100,200,300,400,500,600,700');
/*---------------------------------Navigation Bar*/ 

/*----Navbar Buttons*/
.navbar-nav  li  a {
  color: #ffffff !important;
  font-family: "Gloria Hallelujah" , sans-serif;
  text-transform: uppercase;
  font-size: large;
  font-weight: 500;
  text-decoration: none;
  border:none;
  padding: 8px 8px;
  margin:4px 2px;
}

nav li  a,
nav li  a:after,
nav li  a:before {
  transition: all .5s;
}
#navbar-select-color:hover {
  color: #c8c8c8 !important;
}

#logo-transparent {
  opacity: 1.0;
  filter: alpha(opacity=50);
  transition-timing-function: ease-in-out;
  transition: all .5s;
}

#logo-transparent:hover {
  opacity: 0.8;
  filter: alpha(opacity=100);
  transition-timing-function: ease-in-out;
  transition: all .5s;
}
/*----Navbar Animation*/
nav.stroke ul li a {
  position: relative;
}

nav.stroke ul li a:after {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
  width: 0%;
  content: '.';
  color: transparent;
  background: #aaa;
  height: 1px;
}
nav.stroke ul li a:hover:after {
  width:100%;
}

/*---------------------------------Footer*/
footer {
  background: #212529;
  color: white;
  margin-top:100px;
  bottom: 0;
}

footer a {
  color: #fff;
  font-size: 14px;
  transition-duration: 0.2s;
}

footer a:hover {
  color: #ced3d7;
  text-decoration: none;
}

.copy {
  font-size: 12px;
  padding: 10px;
  border-top: 1px solid #FFFFFF;
}

.footer-middle {
  padding-top: 2em;
  color: white;
}


/*---------------------------------Social Icons*/

/* footer social icons */

ul {
  list-style-type: none;
  display: flex;
  justify-content: center;

}

ul .social-network {
  display: inline;
  margin-left: 0 !important;
  padding: 0;
  float: center;
  
}

 ul .social-network li {
  display: inline;
  margin: 0 5px;
  list-style: none;
}


.social-network a.icoTwitter:hover i {
  color: #007bb7;
}
.social-network a.icoFacebook:hover i {
  color: #3B5998;
}

.social-network a.icoYoutube:hover i {
  color: #c4302b;
}


.social-circle li a {
  display: block;
  position: relative;
  margin: 15px 15px 15px;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  border-radius: 50%;
  text-align: center;
  width: 65px;
  height: 65px;
  font-size:40px;

}

.social-circle li i {
  margin: 0;
  line-height: 30px;
  text-align: center;
}

.social-circle li a:hover i,
.triggeredHover {
  -moz-transform: rotate(360deg);
  -webkit-transform: rotate(360deg);
  -ms--transform: rotate(360deg);
  transform: rotate(360deg);
  -webkit-transition: all 0.2s;
  -moz-transition: all 0.2s;
  -o-transition: all 0.2s;
  -ms-transition: all 0.2s;
  transition: all 0.2s;
}

.social-circle i {
  color: #595959;
  -webkit-transition: all 0.8s;
  -moz-transition: all 0.8s;
  -o-transition: all 0.8s;
  -ms-transition: all 0.8s;
  transition: all 0.8s;
}

.social-network a {
  background-color: #F9F9F9;
}

/*---------------------------------Background*/

body, html {
  height: 100%;
}

img {
  width:100%;
  height:auto;
  position: relative;
  
}

#bg {

  /* Full height */
  height: 100%;


  /* Center and scale the image nicely */
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  width: 100%;
  height: 100%;
  margin-bottom: -100px;
  padding-bottom: 0;
}
代码语言:javascript
复制
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" type="text/css" />
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css" />
    <link rel="stylesheet" href="assets/css/style.css" type="text/css" />
    <title>Home|The Monkees</title>
</head>
<body>
  <header>
<!--------------------Navigation-->
    <nav class="navbar navbar-expand-sm bg-dark navbar-dark stroke">
      <a class="navbar-brand" href="index.html">
        <img src="assets/image/LOGO.png" id="logo-transparent" alt="logo" style="width:143px;">
      </a>
      <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse">
        <span class="navbar-toggler-icon"></span>
      </button>
    
    <div class="collapse navbar-collapse" id="navbarCollapse">  
      <ul class="navbar-nav">
        <li class="nav-item">
          <a class="nav-link " id="navbar-select-color" href="index.html">Home</a>
        </li>
        
        <li class="nav-item">
          <a class="nav-link" id="navbar-select-color" href="music.html">Music</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" id="navbar-select-color" href="video.html">Video</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" id="navbar-select-color" href="shop.html">Shop</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" id="navbar-select-color" href="contact.html">Contact</a>
        </li>
      </ul>
    </div>
    </nav>
  </header>
  <section>
    <div id="bg">
      <img src="assets/image/monkees_portrait_402.jpg" alt="">
    </div>
  </section>

<footer class="mainfooter bg-dark " role="contentinfo">
  <div class="footer-middle">
      <ul class="social-network social-circle">
             <li><a href="https://www.facebook.com/" class="icoFacebook" title="Facebook"><i class="fa fa-facebook"></i></a></li>
             <li><a href="https://twitter.com/" class="icoTwitter" title="Twitter"><i class="fa fa-twitter"></i></a></li>
             <li><a href="https://www.youtube.com" class="icoYoutube" title="Youtube"><i class="fa fa-youtube"></i></a></li>
             
      </ul>	
	<div class="col-md-12 copy">
			<p class="text-center">&copy; Copyright 2019 - The Monkees.  All rights reserved. //<a href="about.html"> About </a> //<a href="privacy_policy.html"> Privacy Policy </a> //<a href="terms_of_use.html"> Terms of Use </a> //<a href="contact.html"> Contact </a></p>
  
	</div>
  </div>
</footer>
  
</body>
</html>

一些关于页脚和导航栏的颜色与图像相比的建议将非常感谢。这是为一个项目准备的。

谢谢

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2019-08-05 04:36:04

因为你没有上传图片,所以我无法正确测试它,如果你想让页脚正好在底部,请更改以下内容:

代码语言:javascript
复制
`footer {background: #212529;
 color: white;
 margin-top:100px;
 position: absolute;
 /*--Your body does not cover the entire screen´s height therefore the 
 -20px--*/
 bottom: -20px;
}`

我不能理解为什么你给它一个页边距-顶部,但它可能与我们不能访问的其余内容或库有关(引导程序,图像..),我希望它仍然有帮助:)

票数 0
EN

Stack Overflow用户

发布于 2019-08-05 04:19:02

你可以调整脚注类。特殊的页边距-顶部

如下所示:

代码语言:javascript
复制
    footer {
  margin-top:50px;
}
票数 0
EN

Stack Overflow用户

发布于 2019-08-05 04:30:30

在页脚标记中,您只需删除margin-top:100px;

只有这一点

代码语言:javascript
复制
footer {
  background: #212529;
  color: white;
  bottom: 0;
}

这将会起作用

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57349899

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档