2016-02-15 31 views
0

如何居中放置此圖像以使其居中。我打算將按鈕放在圖像中,然後將它們放在容器的中心。但是,如果我嘗試修復它,菜單會繼續與綠色橫幅一起使用。這裏是我的HTML和CSS代碼至今: HTML如何將圖像置於引導中心

<div id="difficultyButton" class="col-lg-12 level mt" style="display:none; text-align:center;"> 
    <button type="button" class="myButton " id="btn_easy">Easy</button> 
    <br> 
    <button type="button" class="myButton " id="btn_medium">Medium</button> 
    <br> 
    <button type="button" class="myButton " id="btn_hard">Hard</button> 
    <br> 
    <button type="button" class="myButton mt " id="btn_exitStart">Exit</button> 
</div> 

CSS

.level{ 
    height: 530px; 
    width: 600px; 
    -webkit-flex-wrap: wrap; 
    flex-wrap: wrap; 
    -webkit-align-content: center; 
    background-image: url("../images/CYL/levels.png"); 
    background-repeat: no-repeat; 
} 

myButton { 
    -moz-box-shadow:inset 0px 0px 0px 0px #3e7327; 
    -webkit-box-shadow:inset 0px 0px 0px 0px #3e7327; 
    box-shadow:inset 0px 0px 0px 0px #3e7327; 
    background: -moz-linear-gradient(top, #33a6cc 50%, #0099cc 50%); 
    background: -webkit-gradient(linear, left top, left bottom, color-stop(50%,#33a6cc), color-stop(50%,#0099cc)); 
    background: -webkit-linear-gradient(top, #33a6cc 50%,#0099cc 50%); 
    background: -o-linear-gradient(top, #33a6cc 50%,#0099cc 50%); 
    background: -ms-linear-gradient(top, #33a6cc 50%,#0099cc 50%); 
    background: linear-gradient(to bottom, #33a6cc 50%,#0099cc 50%); 
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#33a6cc', endColorstr='#0099cc',GradientType=0); 
    background-color:#FFFFFF; 
    -moz-border-radius:3px; 
    -webkit-border-radius:3px; 
    border-radius:3px; 
    display:inline-block; 
    cursor:pointer; 
    color:#ffffff; 
    width: 30%; 
    font-family:Arial; 
    font-size:19px; 
    padding:11px 76px; 
    text-decoration:none; 
    text-shadow:0px 0px 0px #5b8a3c; 
    margin-bottom: 10px 
} 


這裏的東西現在的樣子: Image with green banner

+0

爲什麼你將600px寬度應用到'div#difficultyButton'?你有一些佈局問題。這裁剪按鈕的右側,使文本看起來未經審查 – IndieRok

+0

也在你的CSS中,你忘記了類'.myButton'中的點 – Joaquinglezsantos

+0

我已經通過添加一些位置屬性解決了我的問題 – KaelJasper

回答

0

嘗試此附加到你的等級

.level 
{ 
    margin: 0 auto; 
} 
0

添加background-position: top center;.level類,我認爲你需要移動的按鈕小了下來。

0

我只是增加了一些位置屬性.LEVEL和.myButton這樣按鈕將是對圖像的頂部。我分別添加了position: absolute;position: relative