CSS:“右”物业拒绝申请?
这让我发疯!
我有两个 div,就在 body 标签之后。它们的位置和大小都是绝对的。它们都有相同的“左”属性,但我后来声明了第二个 div 的“右”属性(因此“左”应该被忽略!)。
这是 HTML:
<body>
<div class="previousPageButton"></div>
<div class="nextPageButton"></div>
和 CSS:(还有更多代码,但已被注释掉,因此无关紧要。)
.previousPageButton, .nextPageButton {
position: absolute;
top: 0px; left: 0px;
display: block;
height: 500px;;
width: 100px;
background: transparent url(../images/buttons/arrow_previousPage.png) no-repeat center center;
z-index: 2;
opacity: .1;
}
.nextPageButton {
top: 0px; right: 150px;
background: transparent url(../images/buttons/arrow_nextPage.png) no-repeat center center;
}
如您所见,在我声明“left”的第一个 CSS 下面,我有另一个 CSS 块,我在其中专门声明.nextPageButton 的“正确”属性。像往常一样,身体处于相对位置,所以应该可以工作!在声明“右”属性之前,我是否需要“取消设置”“左”属性?这可能吗?
我知道我可以从第一个代码块中删除“左”属性,然后为每个 div 分配它自己的左/右属性..但这应该仍然有效!
有什么想法吗?
This is driving me crazy!
I have two divs, right after the body tag. They are both absolute positioned and sized. They both have the same "left" property, but i later declare the "right" property for the second div (so "left" should be ignored!).
Here's the HTML:
<body>
<div class="previousPageButton"></div>
<div class="nextPageButton"></div>
And the CSS: (There's more code to it but it's commented out so it's irrelevant.)
.previousPageButton, .nextPageButton {
position: absolute;
top: 0px; left: 0px;
display: block;
height: 500px;;
width: 100px;
background: transparent url(../images/buttons/arrow_previousPage.png) no-repeat center center;
z-index: 2;
opacity: .1;
}
.nextPageButton {
top: 0px; right: 150px;
background: transparent url(../images/buttons/arrow_nextPage.png) no-repeat center center;
}
As you can see, BELOW the first CSS where i declare the "left", i have another block of CSS where i specifically declare the "right" property for .nextPageButton. Body is relatively positioned, as usual, so it should work! Do i need to "unset" the "left" property before declaring the "right" property? Is that even possible?
I know i could rip the "left" property out of the first codeblock, and then assign each div it's own left/right property.. but this should still work!
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
左
和右
并不相互排斥。一个元素可以同时设置
left
和right
属性,像这样。如果您想“删除”/“重置”
left
,那么您应该应用left: auto
。您可以查找属性的“初始值”,例如这里是
left
。left
andright
are not mutually exclusive.An element can have both the
left
andright
properties set, like this.If you want to "remove"/"reset"
left
, then you should applyleft: auto
.You can lookup the "inital value" of properties, for example here's
left
.有一些继承导致了冲突。将
left: auto;
添加到.nextPageButton
类以防止。There is some inheritance that is causing a conflict. Add
left: auto;
to the.nextPageButton
class to prevent.