CSS:“右”物业拒绝申请?

发布于 2024-11-06 04:06:39 字数 965 浏览 1 评论 0原文

这让我发疯!

我有两个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

披肩女神 2024-11-13 04:06:39

并不相互排斥。

一个元素可以同时设置 leftright 属性,像这样

如果您想“删除”/“重置”left,那么您应该应用left: auto

您可以查找属性的“初始值”,例如这里是left

left and right are not mutually exclusive.

An element can have both the left and right properties set, like this.

If you want to "remove"/"reset" left, then you should apply left: auto.

You can lookup the "inital value" of properties, for example here's left.

薄情伤 2024-11-13 04:06:39

有一些继承导致了冲突。将 left: auto; 添加到 .nextPageButton 类以防止。

There is some inheritance that is causing a conflict. Add left: auto; to the .nextPageButton class to prevent.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文