2016-11-10 9 views
2

まず、私は小さな画面上で、私のサイトをテストし、フッターコンテンツが重複して実現するまでうまく働い 私のページの一番上にフッタがあるのはなぜですか?

#copyright { 
position: fixed; 
bottom: 0; 
left: 0; 
right: 0; 
height: 50px 
} 

footer { 
position: fixed; 
bottom: 50px; 
left: 0; 
right: 0; 
} 

を使用しました。それでは、私は 100%htmlbody高さを設定しても、私の wrapperは高さ 100%をminに設定すると、より相対フッターを期待して、下にフッターを配置してみました。しかし今、それはトップに立ち往生しています、これは何を引き起こしていますか?

#wrapper { 
 
\t display: block; 
 
    \t position: fixed; 
 
    \t text-align: center; 
 
    \t min-height: 100%; 
 
    \t width: 100%; 
 
    \t top: 0; 
 
    \t bottom: 0; 
 
    \t left: 0; 
 
    \t right: 0; 
 
} 
 

 
#header p { 
 
\t font-size: 2em; 
 
\t margin: 0; 
 
} 
 

 
#header ul { 
 
\t list-style-type: none; 
 
} 
 

 
#header ul li { 
 
\t display: inline; 
 
\t padding: 20px 20px; 
 
\t font-size: 1.5em; 
 
\t margin: 0 30px; 
 

 
} 
 

 

 
#copyright { 
 
\t position: relative; 
 
\t height: 50px; 
 
\t width: 100%; 
 
\t text-align: center; 
 
\t font-size: 0.8em; 
 
} 
 

 
#footer { 
 
\t position: relative; 
 
\t margin-top: 15px; 
 
\t height: 50px; 
 
\t width: 100%; 
 
\t text-align: center; 
 
\t font-size: 0.8em; 
 
} 
 

 
#footer ul { 
 
\t list-style-type: none; 
 
} 
 

 
#footer ul li { 
 
\t display: inline; 
 
\t margin: 0 15px; 
 
}
<div id="wrapper"> 
 
<div id="header"> 
 
<p>Pavel Design</p> 
 
<ul> 
 
<li><a href="index.html">Home</a></li> 
 
<li><a href="about.html">About</a></li> 
 
<li><a href="gallery.html">Gallery</a></li> 
 
<li><a href="services.html">Services</a></li> 
 
<li><a href="contact.html">Contact</a></li> 
 
</ul> 
 
</div> 
 
<div id="contentwrapper"> 
 
<div id="content"> 
 
<h1>Lorem Ipsum</h1> 
 
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tempus  imperdiet nulla scelerisque bibendum. Praesent eu tempus dolor, vel venenatis purus.</p> 
 
</div> 
 
</div> 
 
</div> 
 

 
<footer id="footer"> 
 
    <ul> 
 
\t <li><a href="index.html">Home</a></li> 
 
\t <li><a href="about.html">About</a></li> 
 
\t <li><a href="gallery.html">Gallery</a></li> 
 
\t <li><a href="services.html">Services</a></li> 
 
\t <li><a href="contact.html">Contact</a></li> 
 
\t <li><a href="mailto:[email protected]">[email protected]</a></li> 
 
    </ul> 
 
<p>© Pavel Design 2016 | Photography, design and website construction by Pavel Design 2016</p> 
 
</footer> 
 
\t

EDIT:

Iは画面全体を覆っている背景画像を使用するので、私は、これにtop: 0bottom: 0とを割り当てることができるように、私のラッパーは、固定された位置を使用する場合、Iのみ代わりに、ページ

+0

'wrapper'とそのすべての内容は' fixed'位置しているので...ここで – kukkuz

+0

は将来のためにチェックするためにいくつかのヒントです:なぜそれがありませんが、ここに滞在しますか?だから、あなたは 'place'、' panel'、 'frame'、ということについて考えることができます...それらはすべて' position'に関連しています。したがって、問題を解決するためにすべての 'position'をチェックしてください。がんばろう。 –

+0

私の試して、それは動作します! –

答えて

2

フッターを2つ与える必要はなく、あなた

がここFiddle

HTML

<div id="wrapper"> 
<div id="header"> 
<p>Pavel Design</p> 
<ul> 
<li><a href="index.html">Home</a></li> 
<li><a href="about.html">About</a></li> 
<li><a href="gallery.html">Gallery</a></li> 
<li><a href="services.html">Services</a></li> 
<li><a href="contact.html">Contact</a></li> 
</ul> 
</div> 
<div id="contentwrapper"> 
<div id="content"> 
<h1>Lorem Ipsum</h1> 
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tempus  imperdiet nulla scelerisque bibendum. Praesent eu tempus dolor, vel venenatis purus.</p> 
</div> 
</div> 
</div> 

<footer> 
     <ul> 
      <li><a href="index.html">Home</a></li> 
      <li><a href="about.html">About</a></li> 
      <li><a href="gallery.html">Gallery</a></li> 
      <li><a href="services.html">Services</a></li> 
      <li><a href="contact.html">Contact</a></li> 
      <li><a href="mailto:[email protected]">[email protected]</a></li> 
     </ul> 
    <p>© Pavel Design 2016 | Photography, design and website construction by Pavel Design 2016</p> 
    </footer> 
このデモを確認するために、それが動作するかどうHTML5は、すでにあなたのタグを提供するよう id="footer" を与えるために、これを試してください

CSS

#wrapper { 
    display: block; 
    position: fixed; 
    text-align: center; 
    min-height: 100%; 
    width: 100%; 
    top: 0; 
    bottom: 0; 
    left: 0; 
    right: 0; 
} 

#header p { 
    font-size: 2em; 
    margin: 0; 
} 

#header ul { 
    list-style-type: none; 
} 

#header ul li { 
    display: inline; 
    padding: 20px 20px; 
    font-size: 1.5em; 
    margin: 0 30px; 

} 
footer { 
    position: fixed; 
    margin-top: 2%; 
    height: 50 width: 100%; 
    text-align: center; 
    font-size: 0.8em; 
    bottom: 0; 
} 
footer ul { 
    list-style-type: none; 
} 
footer ul li { 
    display: inline; 
    margin: 0 15px; 
} 
0
の外側の周りに小さな白い境界線を残し、画面全体をカバーしていない min-heightmin-width背景画像を使用します

これはあなたがrelativefixedにラッパーの位置とフッターの位置を設定しているため、問題が発生した

#wrapper { 
 
    display: block; 
 
    text-align: center; 
 
    min-height: 100%; 
 
    width: 100%; 
 
    margin-bottom: 10%// or some other value depending on your requirements 
 

 
} 
 
#header p { 
 
    font-size: 2em; 
 
    margin: 0; 
 
} 
 
#header ul { 
 
    list-style-type: none; 
 
} 
 
#header ul li { 
 
    display: inline; 
 
    padding: 20px 20px; 
 
    font-size: 1.5em; 
 
    margin: 0 30px; 
 
} 
 
#copyright { 
 
    position: relative; 
 
    height: 50px; 
 
    width: 100%; 
 
    text-align: center; 
 
    font-size: 0.8em; 
 
} 
 
#footer { 
 
    position: fixed; 
 
    margin-top: 15px; 
 
    height: 50 width: 100%; 
 
    text-align: center; 
 
    font-size: 0.8em; 
 
    bottom: 0; 
 
} 
 
#footer ul { 
 
    list-style-type: none; 
 
} 
 
#footer ul li { 
 
    display: inline; 
 
    margin: 0 15px; 
 
}
<div id="wrapper"> 
 
    <div id="header"> 
 
    <p>Pavel Design</p> 
 
    <ul> 
 
     <li><a href="index.html">Home</a> 
 
     </li> 
 
     <li><a href="about.html">About</a> 
 
     </li> 
 
     <li><a href="gallery.html">Gallery</a> 
 
     </li> 
 
     <li><a href="services.html">Services</a> 
 
     </li> 
 
     <li><a href="contact.html">Contact</a> 
 
     </li> 
 
    </ul> 
 
    </div> 
 
    <div id="contentwrapper"> 
 
    <div id="content"> 
 
     <h1>Lorem Ipsum</h1> 
 
     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam tempus imperdiet nulla scelerisque bibendum. Praesent eu tempus dolor, vel venenatis purus.</p> 
 
    </div> 
 
    </div> 
 
</div> 
 

 
<footer id="footer"> 
 
    <ul> 
 
    <li><a href="index.html">Home</a> 
 
    </li> 
 
    <li><a href="about.html">About</a> 
 
    </li> 
 
    <li><a href="gallery.html">Gallery</a> 
 
    </li> 
 
    <li><a href="services.html">Services</a> 
 
    </li> 
 
    <li><a href="contact.html">Contact</a> 
 
    </li> 
 
    <li><a href="mailto:[email protected]">[email protected]</a> 
 
    </li> 
 
    </ul> 
 
</footer> 
 

 
<footer id="copyright"> 
 
    <p>© Pavel Design 2016 | Photography, design and website construction by Pavel Design 2016</p> 
 
</footer>

に動作します。 「オーバーラップ」の問題については、margin-bottom:10%をラッパーに設定すると、ラッパーのすべてのコンテンツが表示されるまで、ラッパーがスクロールし続けることが確認されます。

+0

これで、フッターがコンテンツと重複するという当初の問題が発生しました。代わりの@onemanがそれを固定 – oneman

+0

ページの上部に立ち往生している –

+0

私はコードスニペット – oneman

関連する問題