CSS嵌套固定位置

时间:2016-06-28 12:23:30

标签: html css css3

我只是想创建一个具有固定标题的布局。我需要在标题中有一个掩码,所以我再添加一个div。以下是我的代码;

HTML

<div>
  <div class="fixed-parent">
    <div class="fixed-child">
    </div>
  </div>

  <div class="content">
    <p>Lorem Ipsum is..</p>
    <p>Contrary to popular belief...</p>
    <p>The standard chunk...</p>
  </div>

CSS:

.fixed-parent {
    position: fixed;
    width: 100%;
    height: 100px;
    background: red;
    z-index:1;
}
.fixed-child {
    position: fixed;
    width: 100%;
    height: 100px;
    background: white;
    opacity: 0.6;
}

.content
{
    position: absolute;
    top:105px;
    width: 100%;
    z-index:0;

}

在桌面设备中,它运作完美。当我在移动浏览器/ webview中检查时,标题部分在滚动时闪烁(子div正在移动)。这是在我检查锐利手机时发生的。

当我将子div作为单独的div时,没有问题。

请确认,这是预期的行为或类似的行为。

2 个答案:

答案 0 :(得分:0)

您只需将父DIV位置指定为固定。尝试删除子DIV,并检查它是否适用于您的手机。

&#13;
&#13;
.fixed-parent {
  position: fixed;
  width: 100%;
  height: 100px;
  background: red;
  z-index: 1;
  margin: 0;
}
.fixed-child {
  width: 100%;
  height: 100px;
  background: white;
  opacity: 0.6;
}
.content {
  position: absolute;
  top: 105px;
  width: 100%;
  z-index: 0;
}
&#13;
<div class="fixed-parent">
  <div class="fixed-child">
  </div>
</div>

<div class="content">
  <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
    has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
  <p>Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up
    one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum
    et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section
    1.10.32.</p>
  <p>The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions
    from the 1914 translation by H. Rackham.</p>
</div>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

Object -> Localized fields -> Product name -> Product description -> Technical data (field collection) -> Localized Fields -> Value -> Unit 添加到标题标题,它不会在移动设备中闪烁,

top:0