HTML:滚动时粘性标头跳了一点

时间:2019-07-13 15:28:17

标签: css scroll header center

问题是,当滚动到其他页面(内部)以及选择其他一些页面(带有大量文本)时,我试图将标题保持在顶部->出现,标题跳了一点,这很烦人。

尝试将文本对齐到父div并显示:inline-block;进入中学。试图做div相对和左px等,但这使其非常无响应。

.header {
text-align: center;
}
.header h1 {
  display: inline-block;
  font-size: 77.2px;
  font-style: normal;
  font-weight: normal;
  letter-spacing: normal;
  line-height: 76px;
  text-transform: none;
  font-family: "Great Vibes", cursive;
}
.content {
  margin: 0 auto;
  width: 960px;
  top: 20px;
  z-index: 0;
  padding: 20px;
}

1 个答案:

答案 0 :(得分:0)

我真正想要得到它的唯一方法是用display设置包装器:inline-block;和text-align:居中,左侧:右侧50%,相对位置为positio;看起来如下,问题是它并没有真正居中并且对于更大的屏幕等也没有响应:

.header {
  display: inline-block;
}
.header h1 {
  text-align: center;
  left: 50%;
  right: 50%;
  position: relative;
  font-size: 77.2px;
  font-style: normal;
  font-weight: normal;
  letter-spacing: normal;
  line-height: 76px;
  text-transform: none;
  font-family: "Great Vibes", cursive;
}
相关问题