2017-08-03 41 views
0

我想學習HTML 5,我想重現我當前最喜歡的遊戲Camel Up(或Camel Cup)的規則,並試圖成爲一個好人,而不僅僅是使用表,這就是我想實現 what i want to produce如何佈局使用DIV的HTML 5

這就是我得到 enter image description here

這裏是我的代碼:

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="UTF-8"> 
     <title>CamelCup Rules</title> 
     <style> 
      body {background-color:#f3d7a0; font-family:cursive} 
      #wrapper {width:1000px} 
      .float-left { float:left;width:40%;padding-right:5px;padding-left:5px;} 
      .float-right {float:right;width:40%;padding-right:5px;padding-left:5px;} 
      #banner-text{ font-size: smaller;} 
      .red-label {font-size:medium; color:red;vertical-align:top} 
      h1 {color:red; text-align: center; font-size:40px} 
      .full-width {width="100%";} 
     </style> 
    </head> 
    <body> 
     <div id="wrapper"> 
      <header> 
      <div class="full-width"> 
       <div id="logo" class="float-left"> 
        <img src="logo.PNG"> 
       </div> 
       <div id="banner-text" class="float-right"> 
        <p> 
        Witness the craziest camel race of all time, as things really go topsy-turvy when 
    camels stack up and entire pyramids turn upside down. 
    As members of Egyptian high society, you gather in the desert with one simple 
    goal: to gain the most money by backing the right camel to win a leg or even the 
    entire race. However, in this race, it’s not just the lucky ones who can beat the 
    odds. Reading the dynamics of the race and having a good sense of timing is just as 
    important when it comes to backing the right camels and taking the victory. 
        </p> 
       </div> 
       </div> 
      </header> 
      <section id="contents" class="full-width"> 
       <h1>Components</h1> 
       <div id="pyramid" class="float-left"> 
        <label class="red-label">1 Pyramid</label> 
        <img src="pyramid.png"> 
       </div> 
      </section> 

     </div> 
    </body> 
</html> 

,如果我讓可變寬度和擴大我的兄弟wser它看起來像這樣(這是針對一個答案告訴我,使其寬度可變,但我看不到的地方添加圖片評論) enter image description here

+0

那麼問題是什麼?它基於你的形象看起來是正確的?或不? – dbrree

+0

組件div位於徽標下方,而不是位於徽標和橫幅下面。徽標或橫幅都不是寬度的50%,三者之間大約有5釐米的差距。 – WendyG

回答

1

This is what you want?

進行這些更改:

  1. 從。全寬度

    。全寬度刪除 「」{寬度:100%;}

  2. 添加這種樣式

    #contents {明確:兩者;}

  3. 另外改變#wrappper的寬度從1000像素到100%

wrapper {width:100%;}

+0

包裝是在1000px,因爲我想要一個固定寬度的頁面,每次我調整窗口的大小時,一切都變得非常可怕。將必須閱讀{clear:both}做什麼,因爲它看起來很重要 – WendyG

+0

clear屬性指定元素浮動元素的哪一側不允許浮動。你可以給它的左,右和兩個值。 –

+0

我推測寬度爲100%會這樣做,並說我希望它佔據整個寬度,但它只是重疊文本。我添加了一張圖片來解釋可變寬度問題 – WendyG

2

此規則中有一個錯誤:

.full-width {width="100%";} 

應該

.full-width {width: 100%;} 
+0

謝謝,但不是這樣,但很高興能正確 – WendyG