【问题标题】:CSS position fixed property errorCSS位置固定属性错误
【发布时间】:2012-12-30 16:31:45
【问题描述】:

这是我的网站:http://www.kursatkarabulut.com/dersler/

我正在尝试让点赞按钮停留在浏览器左上角的固定位置。 每个赞按钮都在另一个 .likebuttons 子类中。这个 CSS 有什么问题?

我的 CSS 是:

.likebuttons {
    position:fixed;
    left:5px;
    top:5px;
    margin:20px 25px 0;
} 

我还有一个问题。页面宽度为 800 像素。当我在 Explorer/Opera/Safari/Mozilla 中打开此页面时,一切似乎都很正常。但是当我在 Chrome 中打开它时,它会忽略 width:800px;和保证金:0自动;变成全屏宽。我该如何解决这个问题?

我的 HTML 是:

body {
    width:800px;
    margin:0 auto;
    height:100%;
    text-align:justify;
    padding: auto;
    background:#CCCCCC;
    margin-bottom:15px;
}

【问题讨论】:

  • 有什么问题吗?这些按钮确实固定在我的 Firefox 浏览器的左上角,并且我的 chrome 中的页面为 800 像素。您更新了您的网站吗?
  • 我已经更新了网站,但我不知道为什么它仍然会发生。无论我使用哪种浏览器,按钮都会随页面滚动。我在使用 Cloudflare 并禁用它,认为它可能会导致问题。
  • 这很奇怪。它们在我的 Firefox 和 google-chrome 中都静止不动。您是否在移动设备上进行测试?移动浏览器似乎处理位置:固定与其他网站完全不同。

标签: css position width fixed


【解决方案1】:

这就是你所拥有的:

.likebuttons {
    display: block;
    position: absolute;
    left: 0px;
    top: 100px;
    width: 300px;
    height: 200px;
    margin: 20px 25px 0;
    clear: right;
}

top: 100px; 更改为top: 0px;

在 chrome 中正常工作。

【讨论】:

    猜你喜欢
    • 2022-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-23
    • 1970-01-01
    相关资源
    最近更新 更多