2017-02-15 5 views
0

以下は、すべてが1つのコード、つまりhtmlとスタイルです。質問は、 "Box" divが "Footer" divに重なっている理由です。コードをコピーして貼り付けると、ブラウザーで自分自身で見ることができます。私はスタイルとdivのチェックを開始し、これまでのところ成功して自分自身を終了します。何か不足していますか?1つのdivの内容が別のdivに重なっていますか?

.shell { width:950px; margin:0; position:relative; } 
 
#main { background:#f8f8f8 url(images/main.jpg) left top repeat-x; } 
 
#main .box { float:left; width:306px; padding:0 19px 0 0; } 
 
#main .shell { padding:25px 0; } 
 
#footer { background:url(images/footer.jpg) left top repeat-x; color:#b3adad; padding:24px 4px; font-size:10px; } 
 
#footer a { color:#b3adad; text-decoration:none; } 
 
#footer a:hover { text-decoration:underline; } 
 
#footer .footer-navigation { } 
 
#footer .footer-navigation ul { list-style:none; } 
 
#footer .footer-navigation ul li { float:left; padding-right:8px; margin-right:8px; border-right:1px solid #b3adad; height:10px; line-height:10px; } 
 
#footer .footer-navigation ul li.last { padding-right:0; margin-right:0; border-right:0; } 
 
#footer .footer-navigation ul li a { } 
 
#footer .right { float:right; font-family:Verdana, Arial, Sans-Serif; } 
 
#footer .right a { color:#dad7d7; font-weight:bold; text-decoration:underline; } 
 
#footer .right a:hover { text-decoration:none; } 
 
.box { float:left; width:306px; padding:0 19px 0 0; } 
 
.last-box { padding-right:0; } 
 
.box .entry { height:217px; padding-left:2px; } 
 
.box .big-image { padding:4px 0 10px 0; } 
 
.box .big-image img { border:2px solid #fff; } 
 
.box .buttons .button, 
 
.box .buttons .button span { background:url(images/main-button.jpg) repeat-x; height:29px; line-height:29px; float:right; display:inline; border:1px solid #bfbebe; padding:0 8px; } 
 
.box .buttons .button span { float:left; border:0; background:url(images/main-button-span.jpg) left top no-repeat; padding:0 0 0 7px; } \t \t \t
<div id="main"> 
 
    <div class="shell"> 
 
\t <div class="box"> 
 
\t <h2 style="color:#565656;">Latest News</h2> \t \t \t 
 
\t <div class="entry"> 
 
\t \t <div class="news"> 
 
\t \t newsstring; 
 
\t \t </div> 
 
\t </div> 
 
\t </div> \t \t 
 
\t <div class="box"> 
 
\t </div> 
 
    </div> \t 
 
</div> 
 
<!-- End of Main --> 
 
<!-- Footer --> 
 
<div id="footer"> 
 
    <div class="shell"> 
 
\t <div class="footer-navigation"> 
 
\t <ul> 
 
\t \t <li><a href="index.php">Home</a></li> 
 
\t \t <li><a href="about.html">About</a></li> 
 
\t \t <li><a href="Gallery.html">Gallery</a></li> 
 
\t \t <li><a href="location.html">Location</a></li> 
 
\t \t <li class="last"><a href="contact.html">Contact</a></li> 
 
\t </ul> 
 
\t </div> 
 
\t <div class="container"> 
 
\t <table align="center" border="0" cellpadding="0" cellspacing="0" style="height:10px; width:1000px"> 
 
\t \t <tbody> 
 
\t \t <tr> 
 
\t \t \t <td style="height:75px; text-align:center; vertical-align:middle; width:560px"> 
 
\t \t \t <p><a href="#" target="_blank"><img alt="Seertech Solutions Pvt. Ltd" src="./css/images/seertechbanner.jpg" style="height:55px; width:660px" /></a></p> 
 
\t \t \t </td> 
 
\t \t </tr> 
 
\t \t </tbody> 
 
\t </table> 
 
\t </div> 
 
    </div> 
 
</div>

+0

単なる浮動小数点問題です。 google "clearfix"を使って、それを使ってフローティング要素を含む親コンテナにclearfixクラスを追加することができます。以下の短い答え。 – Gezzasa

答えて

0

単に "表示:インラインブロック" を追加し、 "幅:100%" あなたのメインのdivやフッターにを。

CSS:

#footer, #main { 
    display: inline-block; 
    width: 100%; 
} 
0

要素にクラス.clrを追加しますが、クラス.shell以下のようにしています

CSS

.clr:after { 
    content: ""; 
    display: block; 
    clear: both; 
    height: 0; 
    margin: 0; 
    padding: 0; 
} 

HTML

... 
<div class="shell clr"> 
... 

Jsfiddle:

https://jsfiddle.net/merLdd2y/

0

.shell { width:950px; margin:0; position:relative; } 
 
#main { background:#f8f8f8 url(images/main.jpg) left top repeat-x; } 
 
#main .box { float:left; width:306px; padding:0 19px 0 0; } 
 
#main .shell { padding:25px 0; } 
 
#footer { background:url(images/footer.jpg) left top repeat-x; color:#b3adad; padding:24px 4px; font-size:10px; } 
 
#footer a { color:#b3adad; text-decoration:none; } 
 
#footer a:hover { text-decoration:underline; } 
 
#footer .footer-navigation { } 
 
#footer .footer-navigation ul { list-style:none; } 
 
#footer .footer-navigation ul li { float:left; padding-right:8px; margin-right:8px; border-right:1px solid #b3adad; height:10px; line-height:10px; } 
 
#footer .footer-navigation ul li.last { padding-right:0; margin-right:0; border-right:0; } 
 
#footer .footer-navigation ul li a { } 
 
#footer .right { float:right; font-family:Verdana, Arial, Sans-Serif; } 
 
#footer .right a { color:#dad7d7; font-weight:bold; text-decoration:underline; } 
 
#footer .right a:hover { text-decoration:none; } 
 
.box { float:left; width:306px; padding:0 19px 0 0; } 
 
.last-box { padding-right:0; } 
 
.box .entry { height:217px; padding-left:2px; } 
 
.box .big-image { padding:4px 0 10px 0; } 
 
.box .big-image img { border:2px solid #fff; } 
 
.box .buttons .button, 
 
.box .buttons .button span { background:url(images/main-button.jpg) repeat-x; height:29px; line-height:29px; float:right; display:inline; border:1px solid #bfbebe; padding:0 8px; } 
 
.box .buttons .button span { float:left; border:0; background:url(images/main-button-span.jpg) left top no-repeat; padding:0 0 0 7px; } \t \t \t
<div id="main" style="display:inline; width:100%"> 
 
    <div class="shell"> 
 
\t <div class="box"> 
 
\t <h2 style="color:#565656;">Latest News</h2> \t \t \t 
 
\t <div class="entry"> 
 
\t \t <div class="news"> 
 
\t \t newsstring; 
 
\t \t </div> 
 
\t </div> 
 
\t </div> \t \t 
 
\t <div class="box"> 
 
\t </div> 
 
    </div> \t 
 
</div> 
 
<!-- End of Main --> 
 
<!-- Footer --> 
 
<div id="footer"> 
 
    <div class="shell"> 
 
\t <div class="footer-navigation"> 
 
\t <ul> 
 
\t \t <li><a href="index.php">Home</a></li> 
 
\t \t <li><a href="about.html">About</a></li> 
 
\t \t <li><a href="Gallery.html">Gallery</a></li> 
 
\t \t <li><a href="location.html">Location</a></li> 
 
\t \t <li class="last"><a href="contact.html">Contact</a></li> 
 
\t </ul> 
 
\t </div> 
 
\t <div class="container"> 
 
\t <table align="center" border="0" cellpadding="0" cellspacing="0" style="height:10px; width:1000px"> 
 
\t \t <tbody> 
 
\t \t <tr> 
 
\t \t \t <td style="height:75px; text-align:center; vertical-align:middle; width:560px"> 
 
\t \t \t <p><a href="#" target="_blank"><img alt="Seertech Solutions Pvt. Ltd" src="./css/images/seertechbanner.jpg" style="height:55px; width:660px" /></a></p> 
 
\t \t \t </td> 
 
\t \t </tr> 
 
\t \t </tbody> 
 
\t </table> 
 
\t </div> 
 
    </div> 
 
</div>

0

あなたが適切にあなたのフロートをクリアしていません。

#footer { 
    background: url(images/footer.jpg) left top repeat-x; 
    color: #b3adad; 
    padding: 24px 4px; 
    font-size: 10px; 
    clear: both; 
} 

これにより、ヘッダーの浮動小数点がクリアされます。

次のクラスを作成し、浮動要素を含むコンテナの親に追加することもできます。

.clearFix:after {display: table; clear: both; content: "";} 
0

フロートされた子供(.box)をお持ちの場合、親のブロックは、あなたが彼に話すまでそれについて知りません。親ブロック(.shell)スタイルのオーバーフロー:隠しに追加するだけです。

#main .shell { overflow :hidden; }

+0

これで問題は解決しません。 – Gezzasa

+0

なぜですか?これは、 "フッタ"の重複を避ける.box – Ruslana

+0

フッタにない#mainブロックの.shellを意味する – Ruslana

0

要素は、この場合には、流れの中で見つかった次のコンテンツを中心にフッターのテキストをフロートします。

.shell:after { 
    content: ' '; 
    display: table; 
    clear: both; 
} 

.shell { width:950px; margin:0; position:relative; } 
 
.shell:after {content: ' '; display: table; clear: both;} 
 
#main { background:#f8f8f8 url(images/main.jpg) left top repeat-x; } 
 
#main .box { float:left; width:306px; padding:0 19px 0 0; } 
 
#main .shell { padding:25px 0; } 
 
#footer { background:url(images/footer.jpg) left top repeat-x; color:#b3adad; padding:24px 4px; font-size:10px; } 
 
#footer a { color:#b3adad; text-decoration:none; } 
 
#footer a:hover { text-decoration:underline; } 
 
#footer .footer-navigation { } 
 
#footer .footer-navigation ul { list-style:none; } 
 
#footer .footer-navigation ul li { float:left; padding-right:8px; margin-right:8px; border-right:1px solid #b3adad; height:10px; line-height:10px; } 
 
#footer .footer-navigation ul li.last { padding-right:0; margin-right:0; border-right:0; } 
 
#footer .footer-navigation ul li a { } 
 
#footer .right { float:right; font-family:Verdana, Arial, Sans-Serif; } 
 
#footer .right a { color:#dad7d7; font-weight:bold; text-decoration:underline; } 
 
#footer .right a:hover { text-decoration:none; } 
 
.box { float:left; width:306px; padding:0 19px 0 0; } 
 
.last-box { padding-right:0; } 
 
.box .entry { height:217px; padding-left:2px; } 
 
.box .big-image { padding:4px 0 10px 0; } 
 
.box .big-image img { border:2px solid #fff; } 
 
.box .buttons .button, 
 
.box .buttons .button span { background:url(images/main-button.jpg) repeat-x; height:29px; line-height:29px; float:right; display:inline; border:1px solid #bfbebe; padding:0 8px; } 
 
.box .buttons .button span { float:left; border:0; background:url(images/main-button-span.jpg) left top no-repeat; padding:0 0 0 7px; } \t \t \t
<div id="main"> 
 
    <div class="shell"> 
 
\t <div class="box"> 
 
\t <h2 style="color:#565656;">Latest News</h2> \t \t \t 
 
\t <div class="entry"> 
 
\t \t <div class="news"> 
 
\t \t newsstring; 
 
\t \t </div> 
 
\t </div> 
 
\t </div> \t \t 
 
\t <div class="box"> 
 
\t </div> 
 
    </div> \t 
 
</div> 
 
<!-- End of Main --> 
 
<!-- Footer --> 
 
<div id="footer"> 
 
    <div class="shell"> 
 
\t <div class="footer-navigation"> 
 
\t <ul> 
 
\t \t <li><a href="index.php">Home</a></li> 
 
\t \t <li><a href="about.html">About</a></li> 
 
\t \t <li><a href="Gallery.html">Gallery</a></li> 
 
\t \t <li><a href="location.html">Location</a></li> 
 
\t \t <li class="last"><a href="contact.html">Contact</a></li> 
 
\t </ul> 
 
\t </div> 
 
\t <div class="container"> 
 
\t <table align="center" border="0" cellpadding="0" cellspacing="0" style="height:10px; width:1000px"> 
 
\t \t <tbody> 
 
\t \t <tr> 
 
\t \t \t <td style="height:75px; text-align:center; vertical-align:middle; width:560px"> 
 
\t \t \t <p><a href="#" target="_blank"><img alt="Seertech Solutions Pvt. Ltd" src="./css/images/seertechbanner.jpg" style="height:55px; width:660px" /></a></p> 
 
\t \t \t </td> 
 
\t \t </tr> 
 
\t \t </tbody> 
 
\t </table> 
 
\t </div> 
 
    </div> 
 
</div>

キープ:あなたは、私は次のスタイルを追加することになり、あなたの.shellを計画内容に応じて、この場合https://css-tricks.com/all-about-floats/

:山車についての詳細は、このリンクをチェックしてくださいより多くの解決策があることに留意してください。あなたフレックスボックスのアプローチを使用することができます、あなたはディスプレイを使用することができます:インラインブロックのアプローチ、あなたもクールなグリッドアプローチを使用します。それは、達成したいこととサポートしたいブラウザに依存します。

関連する問題