简体   繁体   English

CSS布局问题

[英]CSS Layout Problems

I have a problem with my CSS Code. 我的CSS代码有问题。 I don't want any srcollbars in my webiste and I want the footer to stay at the bottom. 我不想在我的网站中有任何srcollbars,并且我希望页脚停留在底部。 I think there is something wrong with the height and position values, but I don't get it. 我认为高度和位置值有问题,但我不明白。 Hope somebody could help me out. 希望有人可以帮助我。

HTML 的HTML

<div class="content">


  <nav>
    <ul class"nav">
      <li><a href="photo.html">Photo</a></li>
      <li><a href="video.html">Video</a></li>
      <li><a href="gear.html">Gear</a></li>
      <li><a href="contact.html">Contact</a></li>
    </ul>
  </nav>

  <div class="mainContent">
    <article class="article">
     <h3>News</h3>
      <p>This site is currently under construction. Please revisit soon.</p>
    </article>
  tsdfsdfsdfsdfsdfsdf</div>

  <footer>
  © <a href="index.html">MAREYUS PICTURES</a> - all rights reserved </footer>

</div>

CSS 的CSS

    html{
        height:100%;
        padding:0;
        margin:0;
        /* overflow-x: hidden;
        overflow-y: hidden; */
        background: url(../images/Distortion_Symmetry_Object.jpg) no-repeat center center fixed; 
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
    }

    body{
        height:100%;
        padding:0;
        margin:0;
    }

    .content{
        position:absolute;
        height:100%;
        width:100%;
        margin:0;
        padding:0;
    }

    nav{
        background-color:#000;
        margin-top:10px;
        height:15px;
        padding:10px;
        color:#FFF;
    }

    .mainContent{
        position: relative;
        height:100%;
        background-color:rgba(0,102,204,1);
        overflow:hidden;
    }

    .article{
        position:absolute;
        right:0;
        bottom:0;
        width:150px;
        height:350px;
        background:#333;
        color:#FFF;
        padding:10px;
        text-align:center;
    }

    footer{
        position:absolute;
        bottom:0;
        width:100%;
        background-color:rgba(255,255,255,1);
        text-align:center;
    }



    nav a:active, nav a:hover, nav a:focus nav a:visited{
        color: #E58459;
    }

    ul{
        list-style-type: none;
        margin: auto;
        margin-right:50px;
    }

    ul a{
        padding-right: 32px;
        padding-left: 32px;
        text-decoration: none;
        color:#FFF;
    }

    li{
        float:right;
    }

    li:nth-child(n+1):before {
        content: " // ";
    }

Just change your .mainContent css as shown below: 只需更改您的.mainContent css,如下所示:

.mainContent{
    position: absolute;  /*replace with relative */
    top: 45px; /* height :15px; margin-top: 10px; padding:10px; (15 + 10 + 20) of the "nav" */
    bottom: 0; /* give the value equal to the height of the "footer" */
    left: 0;
    right: 0;
    background-color: rgba(0,102,204,1);
    overflow: hidden;
}

Working Bin 工作箱

please do some changes in the CSS file. 请在CSS文件中进行一些更改。 Remove all css code of .mainContent .The changes which i have done are place left:0 in footer as if don't place this then footer would cause problem in IE(<=7) browsers. 删除.mainContent的所有css代码 。我所做的更改在页脚中左移0,好像不放置此页脚将在IE(<= 7)浏览器中引起问题。

 .content{
    position:relative;
    min-height:100%;
    width:100%;
    margin:0;
    padding:0;
float:left;
width:100%;
background-color: rgba(0,102,204,1);
}



 nav{
    background-color:#000;
    height:15px;
    padding:10px;
    color:#FFF;
}
 footer{
    position:absolute;
    bottom:0;
    width:100%;
left:0;
    background-color:rgba(255,255,255,1);
    text-align:center;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM