2017-11-29 7 views
0

私のページの右側に移動できないヘッダーの下にスペースが表示されています。私は右側のテキストボックスをほぼすべて右に向かって欲しいと思います。これは私が取っているHTMLクラスであり、実際の場所ではありません。どのようにクラスを作るための提案。ライトは、画面の右に完全に移動?HTMLとCSSで作成されたWebページ上の余分なスペース

ありがとうございました。

HTML

CSS 
 
/* site.css */ 
 
body { 
 
    background-color: #D4AD6A 
 
} 
 

 
html, body { 
 
    padding: 0 auto; 
 
    margin: 0 auto; 
 
    height: 100%; 
 
    width: 100%; 
 
} 
 

 
header{ 
 
\t color: #256E5D; 
 
\t background-color: #805815; 
 
\t height: 100px; 
 
} 
 

 
footer { 
 
    text-align: center; 
 
    margin-left: 40%; 
 
    padding: 15px; 
 
} 
 

 
nav { 
 
    float: right; 
 
    margin-right: 10px 
 
} 
 

 
nav li{ 
 
    display: inline; 
 
} 
 

 
td,th { 
 
    border: 1px solid black; 
 
} 
 

 
table { 
 
    border-spacing: 0px 
 
} 
 

 
.main { 
 
    font-family: times-new roman; 
 
    color: yellow; 
 
} 
 

 
.title { 
 
    color: #3B3176; 
 
    font-size: 48px; 
 
    font-family: 'Times New Roman', Times, serif; 
 
    text-align: center; 
 
    position: relative; 
 
    top: 50%; 
 
    transform: translateY(-50%); 
 
} 
 

 
.header-image { 
 
    margin-left: 20px; 
 
    margin-top: -50px; 
 
} 
 

 
ul.a { 
 
    list-style-type: none 
 
} 
 

 
.products_inline{ 
 
    font-size: 36px; 
 
    color: yellow; 
 
    width: 50px; 
 
    display: inline-block; 
 
    vertical-align: top; 
 
    width: 20%; 
 
} 
 

 
a.prod_inline:link{ 
 
\t color: yellow; 
 
\t font-size: 36px; 
 
} 
 

 
a.prod_inline:visited { 
 
    \t color: yellow; 
 
\t font-size: 36px; 
 
} 
 

 
.inline { 
 
    display: inline-block; 
 
    text-align: center; 
 
    margin: auto; 
 
    width: 60%; 
 
    /*border: 3px solid black;*/ 
 
} 
 

 
.right { 
 
    display: inline-block; 
 
    text-align: right; 
 
    width: 125px; 
 
    vertical-align: top; 
 
    margin-top: 15px; 
 
    border: 2px solid black; 
 
} 
 

 
.rightform { 
 
    float: right; 
 
} 
 
.flex{ 
 
    display: flex; 
 
} 
 

 
.centerform{ 
 
    display: flex; 
 
    flex-direction: column; 
 
    width: 320px; 
 
    font-family: Arial; 
 
    color: yellow; 
 
    /*border: solid black 3px;*/ 
 
} 
 

 
.page_grids{ 
 
    display: inline-block; 
 
    text-align: left; 
 
} 
 

 
table { 
 
    width: 700px; 
 
    margin-top: 25px; 
 
    border: solid black 1px; 
 
    border-spacing: 0px 
 

 
}
<!doctype html> 
 
<html lang="en"> 
 
<head> 
 
\t <title>Uncle's Bait and Tackle Shop Rods</title> 
 
\t <link rel="stylesheet" href="css/baitstyle.css"> 
 
</head> 
 

 
<body> 
 
\t <section class="main"> 
 
\t <div> 
 
\t \t <header> 
 
\t \t \t <div class="title">Uncle's bait and tackle shop</div> 
 
\t \t \t <!--<div style="margin-left: 94%"><a href="about_us.html">About Us</a></div>--> 
 
\t \t <nav> 
 
     \t \t <ul> 
 
      \t \t <li><a href="final.html">Home</a></li> 
 
      \t \t <li><a href="about_us.html">About Us</a></li> 
 
     \t \t </ul> 
 
     \t </nav> 
 
\t \t \t <img src="img/bass1.jpg" class="header-image" /> 
 
\t \t </header> 
 
\t </div> 
 
\t <div class="products_inline"> 
 
\t <ul class="a"> 
 
\t \t \t <li><a href="rods.html" class="prod_inline">Rods</a></li> 
 
\t \t \t <li><a href="lures.html" class="prod_inline">Lures</a></li> 
 
\t \t \t <li>Terminal <br>&nbsp;&nbsp;Tackle</li> 
 
\t \t \t <li>Clothing</li> 
 
\t </ul></div> 
 
\t </div> 
 
\t <div class="inline"> 
 
\t \t <table class="page_grids"> 
 
\t \t \t <thead> 
 
\t \t \t \t <th colspan="2" height: 25px>[MAKE LARGER, CENTER, USE CSS]Rods</th> 
 
\t \t \t \t <tr><td>Spinning Image</td><td>Our large selection of spinning rods</td></tr> 
 
\t \t \t \t <tr><td>Spin Casting Image</td><td>Our selection of spin casting rods are perfect 
 

 
for the novice angler and masters alike</td></tr> 
 
\t \t \t \t <tr><td>Baitcasting Image</td><td>Our selection of baitcasters are perfect for 
 

 
those that need precision casting</td></tr> 
 
\t \t \t \t <tr><td>Specialty Rods Image</td><td>Our selection of specialty rods will meet 
 

 
your needs for those species specific targets such as salmon or sturgeon</td></tr> 
 
\t \t \t </thead> 
 
\t \t </table> 
 
\t </div> 
 
\t <div class="right">Right side text will this wrap or keep going Right side text will this wrap or keep 
 

 
going Right side text will this wrap or keep going </div> 
 
\t </section> 
 
\t </body> 
 
</html>

+0

、画面の右側に何かスティックを作るために、あなたは 'floatを使用することができます。しかし、仕様を読むことを確認してください。それはうんざりです!とにかく、配置の理由は、それが60%幅の別のインラインブロックの右にあるインラインブロックであるため、右のスペースはウィンドウによって異なります。ああ、画面が狭いときは、表が "インライン" divからオーバーフローし、 "right" divが表の上に表示されます。 –

+0

ありがとうございます。それは理にかなっている。オーバーフローを許さないという提案はありますか? – edpietrzak

+0

確かに、[overflow](https://developer.mozilla.org/en-US/docs/Web/CSS/overflow)プロパティ! –

答えて

0

あなたのマークアップは悪いですが、それは正しく実行(しかし、そのまだことはできませんのでit.I'veは、あなたのHTMLを少しリファクタリングについて、あなたは悪い感じてはいけません良い見て)。

HTML:

<header> 
     <div class="title">Uncle's bait and tackle shop</div> 
     <nav> 
      <ul> 
       <li><a href="final.html">Home</a></li> 
       <li><a href="about_us.html">About Us</a></li> 
      </ul> 
     </nav> 
     <img src="img/bass1.jpg" class="header-image"> 
    </header> 

    <section class="main" style="clear: both;"> 
     <div class="products_inline"> 
      <ul class="a"> 
       <li><a href="rods.html" class="prod_inline">Rods</a></li> 
       <li><a href="lures.html" class="prod_inline">Lures</a></li> 
       <li>Terminal <br>&nbsp;&nbsp;Tackle</li> 
       <li>Clothing</li> 
      </ul> 
     </div> 

     <div class="inline"> 
      <table class="page_grids"> 
      </table> 
     </div> 
     <div class="right"> 
      Right side text will this wrap or keep going Right side 
     </div> 

    </section> 

CSS:right`:

.main { 
    clear: both; 
} 

.right { 
    float: right; 
} 

enter image description here

+0

ありがとうございます。私はあなたがしたことを見ますが、私はそれを本当に理解していません。あなたは明確で両方が何を要約することができますか? – edpietrzak

+0

https://css-tricks.com/snippets/css/clear-fix/ - フローティングdivsは、DOM内の要素を配置するための古い学校のハックです。フレックスボックスやグリッド(広くはサポートされていません)を使用する方が良いでしょう.HTML構造の詳細については、BEMがクラスの命名に役立つhttp://getbem.com/をご覧ください。マークアップはhttps://codepen.io/dakata911/pen/QOzPOx(読みやすく、すべてのセクションで何をしているかを知っている)のようにしてみてください。 –

関連する問題