2012-01-07 70 views
-1

簡單的html高度問題,我basicaly只是想將3個按鈕的高度設置爲身高的25%,對於width屬性可以正常工作,但不是因爲某些原因,heigth沒有在javascript中加載本地XML

div.mainMenuButton {

height:25%; 
text-align:center; 

width:100%; 
background:green; 

}

<body> 
    <div id="menuContainer"> 
     <div id = "playButton" class = "mainMenuButton" onClick="loadGame()"> 
      Play 
     </button> 
     </div> 
     <div id = "optionsButton" class = "mainMenuButton"> 
      Options 
     </div> 
     <div id = "aboutButton" class = "mainMenuButton"> 
      About 
     </div> 

    </div> 

</body> 

謝謝。

+0

您的標題和問題似乎不符合所有。 – 2012-01-08 01:16:16

回答

0

這裏是CSS:

CSS

.mainMenuButton { 
    height:25%; 
    text-align:center; 
    width:100%; 
    background:green; 
} 

#menuContainer { 
    height: 100%; 
} 

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

和HTML:

HTML

<div id="menuContainer"> 
    <div id = "playButton" class = "mainMenuButton" onClick="loadGame()"> 
     Play 
    </div> 
    <div id = "optionsButton" class = "mainMenuButton"> 
     Options 
    </div> 
    <div id = "aboutButton" class = "mainMenuButton"> 
     About 
    </div> 

</div> 

和提琴:http://jsfiddle.net/QPYML/