html
  • css
  • 2014-07-04 42 views 0 likes 
    0
    <!DOCTYPE html> 
    <html> 
        <head lang="en"> 
         <meta charset="utf-8"> 
         <title>Jack Yuan | Web Developer</title> 
         <link rel="stylesheet" href="CSS/normalize.css"> 
         <link href='http://fonts.googleapis.com/css?family=Gloria+Hallelujah' rel='stylesheet' type='text/css'> 
         <link href='http://fonts.googleapis.com/css?family=Lobster&subset=latin,cyrillic-ext' rel='stylesheet' type='text/css'> 
         <link rel="stylesheet" href="CSS/main.css"> 
         <link rel="stylesheet" href="CSS/responsive.css"> 
    
        </head> 
    
        <body> 
    
         <header> 
    
          <a href="index.html" id="logo"> 
           <h1>Jack Yuan</h1> 
           <h2>Web Developer</h2> 
          </a> 
    
          <nav> 
    
           <ul> 
            <li><a href="about.html"class="selected">About</a></li> 
            <li><a href="portfolio.html">Portfolio</a></li> 
            <li><a href="contact.html">Contact</a></li> 
           </ul> 
    
          </nav> 
         </header> 
         <div id="wrapper"> 
         <section> 
          <ul id="gallery"> 
           <li id="pic1"> 
            <a href="img/Jack.jpg"> 
            <img src="img/Jack.jpg" width="500" height="400" alt=""> 
            <p> This is me </p> 
            </a> 
           </li> 
           <li id="pic2"> 
            <a href="img/Life.jpg"> 
            <img src="img/Life.jpg"width="500" height="400" alt=""> 
            <p> This concludes my life(lol!) </p> 
            </a> 
           </li> 
           <li id="pic3"> 
            <a href="img/Study.jpg"> 
            <img src="img/Study.jpg"width="500" height="400" alt=""> 
            <p> This shows what I study </p> 
            </a> 
           </li> 
           <li id="pic4"> 
            <a href="img/2.jpg"> 
            <img src="img/2.jpg"width="500" height="400" alt=""> 
            <p> This is what I believe</p> 
            </a> 
           </li> 
          </ul> 
         </section> 
         <footer> 
          <div id="mus"> 
          <embed src="Neo.mp3" loop="true" autostart="true" height="55mm"> 
          </div> 
          <div id="logo"> 
          <a href="https://www.facebook.com/jackyuan.jack"> 
          <img src="img/facebook.gif" alt="FaceBook Logo" class="icon"> 
          </a> 
          <a href="https://twitter.com/Jack19909100"> 
          <img src="img/twitter.png" alt="Twitter Logo" class="icon"> 
          </a> 
          </div> 
          <p>Jack Yuan</p> 
          <p>All Rights Reserved.</p> 
         </footer> 
         </div> 
        </body> 
    </html> 
    

    这里是我的CSS如何让页脚占据网页宽度的100%?

    a { 
        text-decoration:none; 
    } 
    
    
    
    #wrapper { 
        max-width:940px; 
        margin: 0 auto; 
        padding: 0 5%; 
    } 
    
    #logo { 
        text-align: center; 
        margin: 0; 
    } 
    
    h1 { 
        margin: 0; 
        padding-top: 4mm; 
        font-size: 2em; 
        font-family: 'Lobster', cursive; 
        font-weight: normal; 
        line-height: 0.8em; 
    } 
    
    h2 { 
        font-family: 'Gloria Hallelujah', cursive; 
        font-size: 1.5em; 
        margin: -5px 0 0; 
        font-weight: normal; 
    } 
    
    body{ 
        font-family: 'Gloria Hallelujah', cursive; 
    } 
    
    a { 
        color: #6ab47b; 
    } 
    
    header{ 
        background: #6ab47b; 
        border-color:#599a68; 
        float:left; 
        margin: 0; 
        padding: 5px 0 0 0; 
        width: 100%; 
    } 
    
    nav{ 
        background: #599a68; 
        text-align: center; 
        margin: 20px 0 0; 
    } 
    
    nav a, nav a:visited { 
        color:#fff; 
    } 
    
    nav ul{ 
        list-style: none; 
        margin: 0 10px; 
        padding: 0; 
    } 
    
    
    
    nav a{ 
        font-weight: 800; 
        padding: 15px 10px; 
    } 
    
    h1, h2{ 
        color:#fff; 
    } 
    
    nav a.selected , nav a:hover { 
        color:#32673f; 
    } 
    
    footer{ 
        font-size: 1em; 
        text-align: center; 
        clear:both; 
        padding-top: 20px; 
        color: #ccc; 
        line-height: 0.8em; 
        background: black; 
        margin:0; 
    } 
    
    
    img{ 
        max-width: 100%; 
    } 
    
    #gallery{ 
        margin: 0; 
        padding: 0; 
        list-style: none; /** remove bullet point **/ 
    } 
    
    #gallery li{ 
        float:left; 
        width: 45%; 
        margin: 2.5%; 
        background-color: #f5f5f5; 
        color: #bdc3c7; 
    } 
    
    #gallery li a p{ 
        margin: 0; 
        padding: 0; 
        font-size: 1.5em; 
        color: #bdc3c7; 
    } 
    
    
    
    .icon{ 
        width: 40px; 
        height: 40px; 
        margin: 5mm 5px; 
    } 
    
    body{ 
        background: orange; 
        margin:0; 
        color:#999; 
    } 
    

    为什么只需要在网页的宽度的部分? 我试图设置最大宽度和宽度100%,它没有工作。 如何让页脚占据网页宽度的100%? 这就是我想要做的。

    +0

    把你的页脚出来的'< div class =“wrapper”>' – Era

    +0

    耶,我们现在知道你的Facebook和Twitter页面的地址!那嵌入的mp3文件!?欢迎回到1999年。 – Husman

    回答

    4

    您的footer位于div.wrapper之内。将它移动到div之外。您必须修复margin

    0

    当前的结构是:

    <div id="wrapper"> ... <footer> .. </footer> </div> 
    

    你必须从包装DIV拉出尾像:

    <div id="wrapper"> ... </div> <footer> .. </footer> 
    

    Demo

    0
    <!DOCTYPE html> 
    <html> 
        <head lang="en"> 
         <meta charset="utf-8"> 
         <title>Jack Yuan | Web Developer</title> 
         <link rel="stylesheet" href="CSS/normalize.css"> 
         <link href='http://fonts.googleapis.com/css?family=Gloria+Hallelujah' rel='stylesheet' type='text/css'> 
         <link href='http://fonts.googleapis.com/css?family=Lobster&subset=latin,cyrillic-ext' rel='stylesheet' type='text/css'> 
         <link rel="stylesheet" href="CSS/main.css"> 
         <link rel="stylesheet" href="CSS/responsive.css"> 
    
        </head> 
    
        <body> 
    
         <header> 
    
          <a href="index.html" id="logo"> 
           <h1>Jack Yuan</h1> 
           <h2>Web Developer</h2> 
          </a> 
    
          <nav> 
    
           <ul> 
            <li><a href="about.html"class="selected">About</a></li> 
            <li><a href="portfolio.html">Portfolio</a></li> 
            <li><a href="contact.html">Contact</a></li> 
           </ul> 
    
          </nav> 
         </header> 
         <div id="wrapper"> 
         <section> 
          <ul id="gallery"> 
           <li id="pic1"> 
            <a href="img/Jack.jpg"> 
            <img src="img/Jack.jpg" width="500" height="400" alt=""> 
            <p> This is me </p> 
            </a> 
           </li> 
           <li id="pic2"> 
            <a href="img/Life.jpg"> 
            <img src="img/Life.jpg"width="500" height="400" alt=""> 
            <p> This concludes my life(lol!) </p> 
            </a> 
           </li> 
           <li id="pic3"> 
            <a href="img/Study.jpg"> 
            <img src="img/Study.jpg"width="500" height="400" alt=""> 
            <p> This shows what I study </p> 
            </a> 
           </li> 
           <li id="pic4"> 
            <a href="img/2.jpg"> 
            <img src="img/2.jpg"width="500" height="400" alt=""> 
            <p> This is what I believe</p> 
            </a> 
           </li> 
          </ul> 
         </section> 
         </div> 
        <footer> 
         <div id="mus"> 
         <embed src="Neo.mp3" loop="true" autostart="true" height="55mm"> 
         </div> 
         <div id="logo"> 
         <a href="https://www.facebook.com/jackyuan.jack"> 
         <img src="img/facebook.gif" alt="FaceBook Logo" class="icon"> 
         </a> 
         <a href="https://twitter.com/Jack19909100"> 
         <img src="img/twitter.png" alt="Twitter Logo" class="icon"> 
         </a> 
         </div> 
         <p>Jack Yuan</p> 
         <p>All Rights Reserved.</p> 
        </footer> 
        </body> 
    </html> 
    

    沃金jsFiddle

    其实你必须拿出你的......主要DIV外

    0

    试试这个:

    CSS

    footer{ 
    font-size: 1em; 
    text-align: center; 
    clear:both; 
    margin:0; 
    } 
    
    .footer_content{ 
    width: 100%; 
    position: absolute; 
    left: 0; 
    font-size: 1em; 
    text-align: center; 
    clear:both; 
    padding-top: 20px; 
    color: #ccc; 
    line-height: 0.8em; 
    background: black; 
    margin:0; 
    } 
    

    HTML

    <footer> 
         <div class="footer_content"> 
         <div id="mus"> 
         <embed src="Neo.mp3" loop="true" autostart="true" height="55mm"> 
         </div> 
         <div id="logo"> 
         <a href="https://www.facebook.com/jackyuan.jack"> 
         <img src="img/facebook.gif" alt="FaceBook Logo" class="icon"> 
         </a> 
         <a href="https://twitter.com/Jack19909100"> 
         <img src="img/twitter.png" alt="Twitter Logo" class="icon"> 
         </a> 
         </div> 
         <p>Jack Yuan</p> 
         <p>All Rights Reserved.</p> 
         </div> 
        </footer> 
    
    相关问题