簡體   English   中英

如何在css中設置響應中心圖像的位置?

[英]how to set position of center image with responsive in css?

請看看我的HTML:

                    <div class="row">
                <div  class="row-fluid ">
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 SetPadding">
                        <a href="#" id="button1" "></a>
                    </div>
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 SetPadding">
                        <a href="#" id="button2" ></a>
                    </div>
                </div>
                <div  class="row-fluid ">

                    <div class="col-md-12 col-xs-12 col-sm-12 col-lg-12 SetPadding textaligncenter">
                        <a href="#" id="centerbutton" ></a>
                    </div>
                </div>
                <div  class="row-fluid ">
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 SetPadding">
                         <a href="#" id="button3" ></a>
                    </div>
                    <div class="col-md-6 col-xs-6 col-sm-6 col-lg-6 SetPadding">
                         <a href="#" id="button4" ></a>
                    </div>
                </div>
                </div>

的CSS

#button1 {background: url('../img/button1.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}
                #button2 {background: url('../img/button2.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}
                **#centerbutton{background: url('../img/buttoncenter.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}**
                #button3 {background: url('../img/button3.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}
                #button4 {background: url('../img/button4.png');background-repeat: no-repeat;background-size: 100% 100%;display: inline-block;width:100%;padding-bottom:45%;}

我預期的結果是

在此處輸入圖片說明

我已經嘗試過中心按鈕的絕對位置,但是在調整窗口大小時會產生問題

您的HTML元素稱為id =“ centerbutton”

但您的CSS定位為#buttoncenter

.....或者至少直到您對其進行編輯

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM