【问题标题】:Footer Positioning Issue - Pushed under body content页脚定位问题 - 推送到正文内容下方
【发布时间】:2013-12-25 08:40:31
【问题描述】:

我的页脚有问题,我花了很多时间。实际上,页脚被推到了正文内容之下。这是demo page

HTML5 结构

<div id="main" class="main">

<header>
  <div class="wrapper">
     <div class="logo">                    
     </div>

    <div class="top-box">                    
    </div>

    <nav>
       <div id="menu" class="menu">                        
       </div>
     </nav>
  </div>
</header>

<div class="content" id="content">
    <div id="top-two-column">
    <div class="wrapper">  

        <div id="top-slider-section">
            <div class="slider-wrapper theme-default">
                <div id="slider" class="nivoSlider"></div>
            </div>
        </div>

        <div id="top-login-section">
            <div class="head"></div>
            <div class="head-body">
                <div style="margin: 0 0 35px;"></div>                    
            </div>
        </div>

    </div>
    </div>
</div>

<div class="clear"></div>

<div id="bottom-two-column">
   <div id="bottom-top20songs-section">
       <div id="switch-tabs">

          <ul class="tabs">
             <li><a href="#tabTop" class="headertitlewhite">TOP 20 SONGS</a></li>
              <li><a href="#tabMost" class="headertitlewhite">MOST DOWNLOADED</a></li>
          </ul>

          <div class="content-section" id="tabTop20">
             <div class="songlists"></div>
             <div class="songlists"></div>
             <div class="songlists"></div>
          </div>

          <div class="content-section" id="tabMostDownloaded">
             <div class="songlists"></div>
             <div class="songlists"></div>
             <div class="songlists"></div>               
          </div>

      </div>           
     </div>

   </div>

   <div class="clear"></div>

   <footer>
            Footer
   </footer>

CSS

html, body{ height: 100%;  width: 100%; }

.main{ margin: 0 auto; position: relative;  width: 957px; }

header{ height: 170px;}

.wrapper{ width: 100%; min-height: 100%; overflow: hidden; }

.clear{clear:both;display:block;overflow: hidden; visibility: hidden; width: 0;height: 0;}

.top-box{float: right;padding: 5px 15px;background: #d80000;margin-top: 25px;margin-right: 0px; min-width: 350px;}

nav{ margin-top: 100px;}

.menu{ background: url(navigation-bg.png) no-repeat scroll 0 0 rgba(0, 0, 0, 0); height: 50px; width: 100%; float: left;}

.content{ padding: 2px;}

#top-slider-section{width: 650px; float: left;
background: url(slider-bg.png) no-repeat scroll 0 0 / 650px 285px rgba(0, 0, 0, 0);}

#bottom-top20songs-section{ width: 650px; float: left;}

#top-login-section{width: 280px;background: #303030;float: right;}

.head{ background: url(topbox-bg.png) no-repeat scroll 0 -2px / 280px 44px rgba(0, 0, 0, 0);height: 27px; padding: 7px 10px;}

.head-body{padding: 7px 10px;border: 1px solid #bc0000; min-height: 230px;}

#switch-tabs{background: url(topbox-bg.png) no-repeat scroll 0 -2px / 650px 50px rgba(0, 0, 0, 0); height: 50px;}

.tabs{ padding: 12px 12px 0 7px;}
.tabs li{list-style: none; display: inline; }
.tabs a { padding: 10px 7px; }
.tabs a.active, .tabs a:hover { background: #8A0808 !important;border-radius: 10px; }

.content-section{margin-top: 15px; padding: 7px 10px;border: 1px solid red;}

.songlists{background: #fff;border-radius: 3px; min-height: 100px; margin: 10px 0;padding: 5px;}


footer{bottom: 0;margin-top: 10px;width: 100%;height: 200px;position: relative;background-color: #D80000;}

【问题讨论】:

    标签: css html position footer


    【解决方案1】:

    在 mainAll.css 文件中尝试更改 #switch-tabs 样式:

    #switch-tabs {
        background: url("../images/topbox-bg.png") no-repeat scroll 0 -2px / 650px 50px rgba(0, 0, 0, 0);
        height: 50px;
    }
    

    到:

    #switch-tabs {
        background: url("../images/topbox-bg.png") no-repeat scroll 0 -2px / 650px 50px rgba(0, 0, 0, 0);
    }
    

    【讨论】:

    • 感谢您的快速响应,但这不适用于您的解决方案 bottom: -400px; 仅在将页脚设置为底部限制的内容固定时才有效@ 987654323@,内容变大会怎样?
    • 嗯...固定页脚怎么样?您可以设置 position: fixed 然后添加一个 z-index(例如 1000)以使其保持在其他内容之上,但是没有转义该页脚...您不能将页脚移出该表单吗?
    • 我不喜欢粘页脚。我希望页脚可以随内容滚动。
    • 在 mainAll.css 文件中尝试更改 #switch-tabs 样式:#switch-tabs { background: url("../images/topbox-bg.png") no-repeat scroll 0 -2px / 650px 50px rgba(0, 0, 0, 0);高度:50px; } to: #switch-tabs { background: url("../images/topbox-bg.png") 无重复滚动 0 -2px / 650px 50px rgba(0, 0, 0, 0); }
    • 如果我这样做然后在控制台中执行 $('.songlists').clone().appendTo('#tabTop20') (并重复)以添加到歌曲列表中,页脚工作正常...
    猜你喜欢
    • 2012-08-19
    • 1970-01-01
    • 2017-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-11
    相关资源
    最近更新 更多