【问题标题】:CSS position fixed and absolute not working in chromeCSS位置固定和绝对不能在chrome中工作
【发布时间】:2013-05-10 06:17:55
【问题描述】:

你好,这真的很奇怪,除非我错过了什么。在我的网站上,我有一个静态标题栏,它设置为固定位置,除了在 1 页上之外,其他地方都可以正常工作,我不知道为什么。这也仅在 chrome 中发生。具有“顶栏定位:固定”类的 div

<header>
    <div class="top-bar">
        <div class="top-wrapper">
            <a href="/" style="display:block !important;"><div class="logo"></div></a>
            <a href="/add-event" style="display:block !important;"><div class="add-event button"></div></a>
            <a href="/events" style="display:block !important;"><div class="all-events button"></div></a>
            <div class="search-wrapper">
                <form class="searchform" action="" method="post" onsubmit="window.location.href = '/search/'+$('.searchfield').val()+'/1';return false;">
                    <input class="searchfield" type="text" name="search" placeholder="search...">
                    <input class="searchbutton" type="submit" name="search-submit" value="Go">
                </form>
            </div>
        </div>
    </div>
</header>

这里是css:

-webkit-transform: translate(0) !important;
background: url(../gfx/field_bg.png) repeat-x left top;
height: 40px;
width: 100%;
position: absolute !important;
top: 0px;
left: 0px;
-moz-box-shadow: 0 0 20px #000;
-webkit-box-shadow: 0 0 20px black;
box-shadow: 0 0 20px black;
border-bottom: 1px solid lightgray;
z-index: 998;

【问题讨论】:

  • 此 CSS 与哪些标签相关联?否则这是没用的。
  • top-bar class sry 忘了说清楚

标签: html css css-position


【解决方案1】:

在检查器中,在 &lt;header&gt; 上切换 -webkit-transform: translate(0) !important 为我解决了这个问题。

【讨论】:

    猜你喜欢
    • 2014-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-30
    • 1970-01-01
    相关资源
    最近更新 更多