【问题标题】:The footer has a blank space between it and the bottom of the page when I resize it for mobile当我为移动设备调整页脚大小时,页脚和页面底部之间有一个空白区域
【发布时间】:2019-08-05 04:41:19
【问题描述】:

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

margin-bottom: -100px; 底部填充:0;

CSS 和 HTML 代码如下:

@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;
}
<!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>

对于页脚和导航栏的颜色与图像相比的一些建议将不胜感激。这是一个项目。

谢谢

【问题讨论】:

    标签: html css


    【解决方案1】:

    由于您没有上传图片,我无法正确测试它,如果您希望页脚位于底部,请更改以下内容:

    `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;
    }`
    

    我不明白你为什么给它一个margin-top,但它可能与我们无法访问的其他内容或库(引导程序、图像..)有关,我希望它仍然有帮助:)

    【讨论】:

      【解决方案2】:

      您可以调整页脚类。特别是margin-top

      像这样:

          footer {
        margin-top:50px;
      }
      

      【讨论】:

        【解决方案3】:

        在页脚标签中你只需要删除margin-top:100px;

        只有这个

        footer {
          background: #212529;
          color: white;
          bottom: 0;
        }
        

        这会起作用

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2012-09-15
          • 2018-08-18
          • 1970-01-01
          • 2018-04-07
          • 1970-01-01
          • 2020-01-08
          相关资源
          最近更新 更多