Позиция липкого странного рендеринга - PullRequest
0 голосов
/ 16 февраля 2019

У меня есть простая навигационная панель с position:sticky, которая отображается нечетко при прокрутке, и все, кажется, работает нормально, то есть в верхней части.When not scrolled When scrolled Close view of not scrolled Close of view of the same nav bar scrolled

Как видно из изображений вышеКажется, есть некоторая проблема рендеринга.Вот ксс:

body{
/*For demo purpose*/
height:300vh;
}
* {
    font-family: RobotoThin;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    outline: none;
    -webkit-transition: 1s;
    transition: 1s;
    box-sizing: border-box;
    background-repeat: no-repeat;
    transition: 0.5s !important;
   scroll-behavior: smooth;
}
div.window {

    display: -webkit-box;
    display: -ms-flexbox;
    display: -webkit-flex;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    -webkit-align-items: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    -webkit-justify-content: center;
    justify-content: center;
    box-sizing: border-box;
    padding: calc(2vh + 2vw);
    height: 100vh;
    width: 95vw;
    position: absolute;
    right: 0;
    top: 0;
    display: none;
    white-space: nowrap;
    display: flex;
    -ms-flex-wrap: wrap;
    -webkit-flex-wrap: wrap;
    flex-wrap: wrap;
    background-color: #ecf0f1;
    margin-left: 5vw;
}
#help{
    display:block;
    transition:0s !important;
}
div#help{
height:200vh;
    white-space: normal;
}
div#help  a{
    color:red;
    text-decoration: none;
}
div#nav {
  top: 0;
  position: sticky;
  display: flex;
  justify-content: space-between;
  color: black;
  background-color: white;
  padding-top: 1vmax;
  padding-bottom: 1vmax;
  font-size: 1.2vmax;
  flex-wrap: wrap;
  border-radius: 10em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

div#nav>a {
  color: black;
}

div#nav>*:hover {
  color: gold;
  letter-spacing: 0.3vw;
}

div#nav> :first-child {
  margin-left: 1vw;
}

div#nav> :last-child {
  margin-right: 1vw;
}
<body>
<div class='windows' id='help'>
<div id='nav'> <a>General important info</a> <a>Desktop</a> <a>Math calculators</a> <a>Notes</a> <a>Battery</a> <a>Quotes</a> <a>Settings</a> <a>Passwords and Data</a> </div>
</div>
</body>
Не обращайте внимания на цвет.Я использую плагин, чтобы вы видели все в белом, а не в черном.Странно, я не мог заставить пример работать должным образом, и я не могу представить проблему.Надеюсь, вы можете взглянуть на мой код и сказать, что может вызвать эту проблему.

1 Ответ

0 голосов
/ 16 февраля 2019

После долгих поворотов виновник:

  overflow-x: hidden;

body {
  /*For demo purpose*/
  height: 300vh;
}

* {
  font-family: RobotoThin;
  margin: 0;
  padding: 0;
  /* overflow-x: hidden;     <-- The problem */
  outline: none;
  -webkit-transition: 1s;
  transition: 1s;
  box-sizing: border-box;
  background-repeat: no-repeat;
  transition: 0.5s !important;
  scroll-behavior: smooth;
}

div.window {
  display: -webkit-box;
  display: -ms-flexbox;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -ms-flex-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: center;
  -ms-flex-pack: center;
  -webkit-justify-content: center;
  justify-content: center;
  box-sizing: border-box;
  padding: calc(2vh + 2vw);
  height: 100vh;
  width: 95vw;
  position: absolute;
  right: 0;
  top: 0;
  display: none;
  white-space: nowrap;
  display: flex;
  -ms-flex-wrap: wrap;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  background-color: #ecf0f1;
  margin-left: 5vw;
}

#help {
  display: block;
  transition: 0s !important;
}

div#help {
  height: 200vh;
  white-space: normal;
}

div#help a {
  color: red;
  text-decoration: none;
}

div#nav {
  top: 0;
  position: sticky;
  display: flex;
  justify-content: space-between;
  color: black;
  background-color: white;
  padding-top: 1vmax;
  padding-bottom: 1vmax;
  font-size: 1.2vmax;
  flex-wrap: wrap;
  border-radius: 10em;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

div#nav>a {
  color: black;
}

div#nav>*:hover {
  color: gold;
  letter-spacing: 0.3vw;
}

div#nav> :first-child {
  margin-left: 1vw;
}

div#nav> :last-child {
  margin-right: 1vw;
}
<body>
  <div class='windows' id='help'>
    <div id='nav'> <a>General important info</a> <a>Desktop</a> <a>Math calculators</a> <a>Notes</a> <a>Battery</a> <a>Quotes</a> <a>Settings</a> <a>Passwords and Data</a> </div>
  </div>
</body>
...