定位固定CSS不能正常工作

时间:2017-05-24 06:36:09

标签: html css

很抱歉,如果我要求愚蠢的问题,但我尝试了几个小时没有找到解决方案。 在我的网站上,我想在标题中显示MOBILE宽度搜索按钮以确定位置。

.searchfixed {
  display: block;
  top: 0px;
  width: 100%;
  position: fixed;
}
<div style="position:static;height:50px">
  <div class="searchfixed">My Button Search</div>
</div>

为什么固定职位不起作用?

2 个答案:

答案 0 :(得分:0)

删除 private async void PlayNextFile() { while (true) { if (currentState == PlayerState.Started) { //if we find the next slide then play it AudioSlide slideToPlay = FindNextSlide(); if (slideToPlay != null) { PlaySlide(slideToPlay); return; } MedianLog.Log.Instance.LogDebug("Did not find a slide to play now, will check again in a second"); await Task.Delay(1000); } else { return; } } } ,因为默认为position:static;位置,我添加了高度500px;要检查固定的位置,您可以根据需要进行更改。

static
.searchfixed {
    display:block;
    top:0px;
    width:100%;
    position:fixed;
}

答案 1 :(得分:0)

我在你的网站上,css是这样的:

enter image description here

因此,position:fixed由于某种原因未被应用。如果我手动添加

position: fixed;
left: 0;
right: 0;
z-index: 99999; // without that it would be onder the content

然后它有效。enter image description here