angularjs - 如何在 css 中使用响应式设置中心图像的位置?

标签 angularjs html 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%;}

我的预期输出是

enter image description here

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

最佳答案

你的 HTML 元素叫做 id="centerbutton"

但是你的 CSS 是针对#buttoncenter

.....或者至少在你编辑它之前是这样

关于angularjs - 如何在 css 中使用响应式设置中心图像的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31965228/

相关文章:

javascript - 如何在 AngularJS 中跳过 ui-router 的 ui-view 并重定向不带 .html 扩展名的部分 url

javascript - 能否在使用它的 block 内修改 ng-if 变量?

javascript - 从文本文件中获取随机行

javascript - 通过包含 AngularJS 中的子字符串的属性过滤对象数组

css - 为什么这个 css "transition"值是 "invalid property value"

JavaScript/css 在 Sharepoint WebPart 中不起作用

javascript - Jquery 可使用动态 div 上的上下箭头进行排序

javascript - EasySlider1.7 - 如何让第二个 slider 上的箭头起作用?

javascript - 自定义 css 属性或部分 css 变量 shim

javascript - 类似Medium.com的两栏“粘性”滚动