响应页面空白

时间:2014-12-10 07:04:38

标签: html css zurb-foundation

希望一切顺利,我通过媒体查询测试响应式网站(最大宽度为960px和480px),我怀疑为什么页面变成空白或白色背景而不是背景图像,也许它与基金会5有关溢出隐藏?覆盖基础文件?

如果我删除了头部标签下的Foundation的href链接,则背景图像会恢复正常。由于我是基金会的新手,有什么解决方案?

HTML

<!DOCTYPE html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8" />
    <title>Front End Development</title>
    <link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen">
    <link rel="stylesheet" href="css/foundation.css" type="text/css">
    <link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link href='http://fonts.googleapis.com/css?family=Gabriela' rel='stylesheet' type='text/css'>
</head>
<body>
<nav class="top-bar" data-topbar role="navigation">
  <ul class="title-area">
    <li class="name">
      <h1><a href="#">Mike Davis</a></h1>
    </li>
      <!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone -->
          <li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li>
  </ul>

<!--Section wrap -->
<section class="topbar">
    <ul class="topside-nav">
      <li><a href="#">Portfolio</a></li>
      <li><a href="#">Pictures</a></li>
      <li><a href="#">Map</a></li>
      <li><a href="#">Contact</a></li>
    </ul>   
</section>    

    <!--Short Description -->
<div class="myDiv">
    <div class="bgImage" style="position: absolute; top: 90%; left: 0px;">
        <h1>Hello! I am Mike</h1>
        <p>I enjoy building websites for individuals and businesses!</p>    
    </div>
</div>
</nav>
</body>
</html>

CSS

/* Top Bar to set center*/
.topbar ul {
    display: table; 
    margin: 0 auto;
}

/* Top Side Navagiation Listing */
.topside-nav li {
    display: table-cell;
    line-height: 33px;
    font-size: 1.25rem; 
    margin-left: 85px;
    padding-right: 2.6rem;
    font-weight: bold; 
} 

.top-bar .name h1 {
    font-family: 'Gabriela', serif;
    padding-left: 2rem;
}

/* Navigation Hover */
.topside-nav li a:hover {
    color: #f4fcff;
    background-color: #eb4747;
    border-radius: 5px;
/*    padding: 10px 10px;*/
}

.topside-nav a {
    text-decoration: none; 
    padding: 10px 10px;
}

/* New Font */
body {
    font-family: 'Gabriela', serif;
}

.top-bar {
    height: 65px;
    line-height: 65px;
    position: relative;
    background: #000;
    margin-bottom: 0; }
.top-bar ul {
    margin-top: 18px;}
.top-bar .title-area {
    position: relative;
    margin: 0; }
.top-bar .name {
    height: 45px;
    margin: 0;
    font-size: 16px; }
.top-bar .name h1 {
    line-height: 65px;
    font-size: 1.8rem;
    margin: 0; 
}

.myDiv {  
    text-align: center;
}

.myDiv h1 {
    margin-top: 150px;
    display: inline-block;
    font-family: 'Gabriela', serif;
    color: #FFF;
    font-size: 3.5em;
    border-radius: 20px;
    background: rgba(43, 166, 203, 0.5  /*this is the alpha value for background*/ );
    padding: 0.1em 0.2em 0.1em 0.5em;
}

.myDiv p {
    font-family: 'Gabriela', serif;
    text-align: center;
    color: #FFF;
    font-size: 1.8rem;
    background-color: #2ba6cb; 
    margin: auto;
    width: 80%;
}

/* Set Loop to show images differently daily if possible */
.bgImage {
/*  background: url('../img/futureHighCityC.jpg') 20% 20% / cover transparent;*/
/*  background: url('../img/futureHighCityB.jpg') 20% 20% / cover transparent;*/
/*  background: url('../img/futureHighCity.jpg') 20% 20% / cover transparent;*/
  background: url('../img/amazing_city.jpg') 20% 20% / cover transparent;    
    width: 100%;
    height: 800px;
}

.myDiv span {
    color: #fc0b0b;
}


/*Foundation Top Menu Toggle */
.top-bar .toggle-topbar {
    position: absolute;
    right: 0;
    top: 0; }
    .top-bar .toggle-topbar a {
      color: white;
      text-transform: uppercase;
      font-size: 0.8125rem;
      font-weight: bold;
      position: relative;
      display: block;
      padding: 0 15px;
      height: 45px;
      line-height: 45px; }
    .top-bar .toggle-topbar.menu-icon {
      top: 70%;
      margin-top: -16px; }
      .top-bar .toggle-topbar.menu-icon a {
        height: 34px;
        line-height: 33px;
        padding: 0 40px 0 15px;
        color: white;
        position: relative; }
        .top-bar .toggle-topbar.menu-icon a span::after {
          content: "";
          position: absolute;
          display: block;
          height: 0;
          top: 50%;
          margin-top: -8px;
          right: 15px;
          box-shadow: 0 0px 0 1px white, 0 7px 0 1px white, 0 14px 0 1px white;
          width: 16px; }
        .top-bar .toggle-topbar.menu-icon a span:hover:after {
          box-shadow: 0 0px 0 1px "", 0 7px 0 1px "", 0 14px 0 1px ""; }


/* Media Queries */

@media (max-width: 960px) {
    body {
        background: royalblue;
        background-size: auto 100%;
    }
    p {
      color: white;  
    }
}

@media (max-width: 480px) {
 body {
     background-color: darkred;
 }    
}

@media (min-width: 481px) and (max-width: 700px) {
   body {
     background-color: orange;
 }    
}

1 个答案:

答案 0 :(得分:1)

问题出在</nav>的位置。由于媒体查询,当屏幕足够小时,导航会折叠。但.bgImage包含在导航中,因此它也会折叠。 改为:

<nav class="top-bar" data-topbar role="navigation">
  <ul class="title-area">
    <li class="name">
  <h1><a href="#">Mike Davis</a></h1>
</li>
  <!-- Remove the class "menu-icon" to get rid of menu icon. Take out "Menu" to just have icon alone -->
      <li class="toggle-topbar menu-icon"><a href="#"><span></span></a></li>
  </ul>

<!--Section wrap -->
<section class="topbar">
<ul class="topside-nav">
  <li><a href="#">Portfolio</a></li>
  <li><a href="#">Pictures</a></li>
  <li><a href="#">Map</a></li>
  <li><a href="#">Contact</a></li>
</ul>   
</section>    
</nav> <!--- ADD </nav> here -->
<!--Short Description -->
<div class="myDiv">
    <div class="bgImage" style="position: absolute; top: 90%; left: 0px;">
    <h1>Hello! I am Mike</h1>
    <p>I enjoy building websites for individuals and businesses!</p>    
  </div>
    </div>
<!---  DELETE THIS NAV </nav>  -->
</body>
</html>

现在你需要修复.bgImage的顶部填充/边距,但这应该可以解决图像消失的问题。

变化:

<div class="bgImage" style="position: absolute; top: 90%; left: 0px;">

为:

<div class="bgImage" style="position: absolute; top: 19%; left: 0px;">

应该做的伎俩。最好把它移到你的style.css上。

相关问题