2016-01-13 107 views
0

正如您從我的代碼中看到的那樣,4個部分堆積如山。如果有人能夠幫助我在頁面上均勻分佈,這將是非常好的。這四個部分是:遊戲史,雅達利,其他遊戲,未來的遊戲。重新排列HTML頁面

.jumbotron h1 { 
 
    color: #ffffff; 
 
    font-size: 150px; 
 
    font-family: Sans-serif; 
 
    font-weight: bold; 
 
    text-align: center; 
 
    margin-top: 0px; 
 
} 
 
.jumbotron { 
 
    background-image: url('http://i118.photobucket.com/albums/o117/Shawnthebro/bandicam2014-03-2311-20-03-210_zpse7f7712f.jpg'); 
 
    position: absolute; 
 
    left: 0px; 
 
    top: 100px; 
 
    height: 350px; 
 
    display: block; 
 
} 
 
.nav li { 
 
    display: inline; 
 
    text-align: center; 
 
    color: #ff0000; 
 
    font-size: 50px; 
 
    bottom: 350px; 
 
    padding-left: 35px; 
 
    font-family: Sans-serif; 
 
} 
 
.page ul { 
 
    color: #000000; 
 
    font-size: 20px; 
 
    font-family: Calibri; 
 
    padding-left: 75px; 
 
    .page ul li { 
 
    display: inline; 
 
    } 
 
    .page a { 
 
    color: #000000; 
 
    font-size: 15px; 
 
    font-family: Calibri; 
 
    padding-left: 70px; 
 
    }
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <link rel="stylesheet" href="home.css"> 
 
    <title>Gaming T,N & B</title> 
 
</head> 
 

 
<div class="jumbotron"> 
 
    <div class="container"> 
 
    <h1>Gaming: Then, Now & Beyond</h1> 
 
    </div> 
 
</div> 
 

 

 
<body> 
 

 

 
    <div class="nav"> 
 
    <div class="container"> 
 
     <ul> 
 
     <li><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/hog.html">History of Gaming</a> 
 
     </li> 
 
     <li><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/atari.html">Atari</a> 
 
     </li> 
 
     <li><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/othergames.html">Other Games</a> 
 
     </li> 
 
     <li><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/future.html">Future</a> 
 
     </li> 
 
     </ul> 
 
    </div> 
 
    </div> 
 

 

 
    <style> 
 
    div.img { 
 
     margin: 5px; 
 
     border: 1px solid #ccc; 
 
     float: left; 
 
     width: 180px; 
 
    } 
 
    div.img:hover { 
 
     border: 1px solid #777; 
 
    } 
 
    div.img img { 
 
     width: 100%; 
 
     height: auto; 
 
    } 
 
    div.desc { 
 
     padding: 15px; 
 
     text-align: center; 
 
    } 
 
    </style> 
 
    </head> 
 

 
    <body> 
 

 
    <div class="img"> 
 
     <a target="_blank" href="history.png"> 
 
     <img src="history.png" alt="The History of Gaming" width="300" height="200"> 
 
     </a> 
 
     <div class="desc"> 
 
     <div class="page"> 
 
      <div class="container"> 
 
      <div> 
 
       <div> 
 
       <div> 
 
        <h3>History of Gaming</h3> 
 
        <ul> 
 
        <li>What is gaming?</li> 
 
        <li>Pong</li> 
 
        <li>Technology Boom</li> 
 
        </ul> 
 
        <p><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/hog.html">Learn more about the history of gaming</a> 
 
        </p> 
 
       </div> 
 
       </div> 
 
      </div> 
 

 
      <div class="img"> 
 
       <a target="_blank" href="atari.jpg"> 
 
       <img src="atari.jpg" alt="Atari" width="600" height="400"> 
 
       </a> 
 
       <div class="desc"> 
 
       <div> 
 
        <h3>Atari</h3> 
 
        <ul> 
 
        <li>40 years of fun</li> 
 
        <li>Who is Nolan Bushnell</li> 
 
        <li>Bought & Sold</li> 
 
        </ul> 
 
        <p><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/atari.html">Learn more about Atari</a> 
 
        </p> 
 
       </div> 
 
       </div> 
 
      </div> 
 

 
      <div class="img"> 
 
       <a target="_blank" href="xbox_ps1.jpg"> 
 
       <img src="xbox_ps1.jpg" alt="Other Games" width="600" height="400"> 
 
       </a> 
 
       <div class="desc"> 
 
       <div> 
 
        <h3>Other Games</h3> 
 
        <ul> 
 
        <li>PC</li> 
 
        <li>Xbox</li> 
 
        <li>PlayStation</li> 
 
        </ul> 
 
        <p><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/othergames.html">Learn more about other games</a> 
 
        </p> 
 
       </div> 
 
       </div> 
 
      </div> 
 

 
      <div class="img"> 
 
       <a target="_blank" href="future_ocu.jpg"> 
 
       <img src="future_ocu.jpg" alt="Future Gaming" width="600" height="400"> 
 
       </a> 
 
       <div class="desc"> 
 
       <div> 
 
        <h3>Future</h3> 
 
        <ul> 
 
        <li>Gaming in society</li> 
 
        <li>Who is driving who?</li> 
 
        <li>CrowdFunding</li> 
 
        </ul> 
 
        <p><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/future.html">Learn about future gaming</a> 
 
        </p> 
 
       </div> 
 
       </div> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div> 
 

 
     <iframe width="1150" height="315" src="http://www.youtube.com/embed/X1tBEKFYKJg?autoplay=1" style="border:5px dotted red"> 
 
     </iframe> 
 

 

 
    </body> 
 

 
</html>

非常感謝

亞當

+0

我找不到你聲明容器風格的地方。我會說創造它,並給它足夠的高度。 ...如果這不起作用,請製作一個jsfiddle - 讓我們更容易編輯和操作。 –

回答

0

你的HTML代碼結構是無效的。我只是修改了它。 head標籤打開兩次,style被放置在體內。 body標籤也被多次打開,並且一些div標籤未關閉。

.jumbotron h1 { 
 
color: #ffffff; 
 
font-size: 150px; 
 
font-family: Sans-serif; 
 
font-weight: bold; 
 
text-align: center; 
 
margin-top: 0px; 
 
} 
 
.jumbotron { 
 
background-image: url('http://i118.photobucket.com/albums/o117/Shawnthebro/bandicam2014-03-2311-20-03-210_zpse7f7712f.jpg'); 
 
position: absolute; 
 
left: 0px; 
 
top: 100px; 
 
height: 350px; 
 
display: block; 
 
} 
 
.nav li { 
 
display: inline; 
 
text-align: center; 
 
color: #ff0000; 
 
font-size: 50px; 
 
bottom: 350px; 
 
padding-left: 35px; 
 
font-family: Sans-serif; 
 
} 
 
.page ul { 
 
color: #000000; 
 
font-size: 20px; 
 
font-family: Calibri; 
 
padding-left: 75px; 
 
.page ul li { 
 
display: inline; 
 
} 
 
.page a { 
 
color: #000000; 
 
font-size: 15px; 
 
font-family: Calibri; 
 
padding-left: 70px; 
 
}
<!DOCTYPE html> 
 
<html> 
 
    <head> 
 
     <link rel="stylesheet" href="home.css"> 
 
     <title>Gaming T,N & B</title> 
 
     <style> 
 
     div.img { 
 
     margin: 5px; 
 
     border: 1px solid #ccc; 
 
     float: left; 
 
     width: 180px; 
 
     } 
 
     div.img:hover { 
 
     border: 1px solid #777; 
 
     } 
 
     div.img img { 
 
     width: 100%; 
 
     height: auto; 
 
     } 
 
     div.desc { 
 
     padding: 15px; 
 
     text-align: center; 
 
     } 
 
     </style> 
 
    </head> 
 
    <body> 
 
     <div class="jumbotron"> 
 
     <div class="container"> 
 
      <h1>Gaming: Then, Now & Beyond</h1> 
 
     </div> 
 
     </div> 
 
     <div class="nav"> 
 
     <div class="container"> 
 
      <ul> 
 
       <li><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/hog.html">History of Gaming</a> 
 
       </li> 
 
       <li><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/atari.html">Atari</a> 
 
       </li> 
 
       <li><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/othergames.html">Other Games</a> 
 
       </li> 
 
       <li><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/future.html">Future</a> 
 
       </li> 
 
      </ul> 
 
     </div> 
 
     </div> 
 
     <div class="img"> 
 
     <a target="_blank" href="history.png"> 
 
     <img src="history.png" alt="The History of Gaming" width="300" height="200"> 
 
     </a> 
 
     </div> 
 
     <div class="desc"> 
 
     <div class="page"> 
 
      <div class="container"> 
 
       <div> 
 
        <div> 
 
        <div> 
 
         <h3>History of Gaming</h3> 
 
         <ul> 
 
          <li>What is gaming?</li> 
 
          <li>Pong</li> 
 
          <li>Technology Boom</li> 
 
         </ul> 
 
         <p><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/hog.html">Learn more about the history of gaming</a> 
 
         </p> 
 
        </div> 
 
        </div> 
 
       </div> 
 
       <div class="img"> 
 
        <a target="_blank" href="atari.jpg"> 
 
        <img src="atari.jpg" alt="Atari" width="600" height="400"> 
 
        </a> 
 
        <div class="desc"> 
 
        <div> 
 
         <h3>Atari</h3> 
 
         <ul> 
 
          <li>40 years of fun</li> 
 
          <li>Who is Nolan Bushnell</li> 
 
          <li>Bought & Sold</li> 
 
         </ul> 
 
         <p><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/atari.html">Learn more about Atari</a> 
 
         </p> 
 
        </div> 
 
        </div> 
 
       </div> 
 
       <div class="img"> 
 
        <a target="_blank" href="xbox_ps1.jpg"> 
 
        <img src="xbox_ps1.jpg" alt="Other Games" width="600" height="400"> 
 
        </a> 
 
        <div class="desc"> 
 
        <div> 
 
         <h3>Other Games</h3> 
 
         <ul> 
 
          <li>PC</li> 
 
          <li>Xbox</li> 
 
          <li>PlayStation</li> 
 
         </ul> 
 
         <p><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/othergames.html">Learn more about other games</a> 
 
         </p> 
 
        </div> 
 
        </div> 
 
       </div> 
 
       <div class="img"> 
 
        <a target="_blank" href="future_ocu.jpg"> 
 
        <img src="future_ocu.jpg" alt="Future Gaming" width="600" height="400"> 
 
        </a> 
 
        <div class="desc"> 
 
        <div> 
 
         <h3>Future</h3> 
 
         <ul> 
 
          <li>Gaming in society</li> 
 
          <li>Who is driving who?</li> 
 
          <li>CrowdFunding</li> 
 
         </ul> 
 
         <p><a href="file:///Users/AdamMahmoud/Documents/School/Year%2010/IT/website_name/future.html">Learn about future gaming</a> 
 
         </p> 
 
        </div> 
 
        </div> 
 
       </div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
     <iframe width="1150" height="315" src="http://www.youtube.com/embed/X1tBEKFYKJg?autoplay=1" style="border:5px dotted red"> 
 
     </iframe> 
 
    </body> 
 
</html>

的CSS代碼是不是因爲無效結構的工作,現在就來試試您的佈局文件,現在應該工作。

+0

我的錯誤,當我說我的意思是介於YouTube視頻和圖像之間的4個部分!不是導航欄! @maihannijat – JamesM

+0

@JamesM請提供更多信息。目前尚不清楚。 –

+0

@JamesM我更新了我的答案。 –

0

如果您將相同的技術應用於該部分,James的答案可能仍然有效。既然這在技術上是他的答案,我會提供一個替代解決方案。你可以添加到您的CSS:

ul {text-align-justify} 

或者,如果你只希望該規則適用於部分中,您可以給UL的ID,並將其應用在CSS的ID。

我還建議將h1部分向下移動到身體中。