如何在css中设置响应中心图像的位置?

时间:2015-08-12 12:27:20

标签: html css angularjs html5 css3

请看我的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%;}

我的预期结果是

enter image description here

我已经尝试过中心按钮的绝对位置,但是在调整窗口大小时会产生问题

1 个答案:

答案 0 :(得分:1)

您的HTML元素名为id =“centerbutton”

但您的CSS定位于#buttoncenter

.....或者至少直到你编辑它