Parallax background image changing size on mobile upon passing mobile address bar

Viewed 132

I have been hitting a wall with my parallax element for a week now. Asking for help is a last resort for me. I have looked into the various forums for solutions to these issues, but nothing I have tried has worked.

(only on mobile (chrome) ) -If you are holding the touch screen, and continuing to scroll down, after the initial screen image, a white bar comes up (the end of the .parallax-container, but the text comes up over that. Later iterations of this project reveal that the rest of the page - past the parallax container and this white bar - will not scroll onto the screen until this writing is in the position that it should have been in.

-If you are scrolling down from the original screen a little at a time, the .parallax-background image resizes (looks slightly more expanded/zoomed in) after passing the browser's address bar. The rest of the page works normally. No issue with the white bar, writing, or the rest of the page.

I know these two issues are somehow connected.

What do I need to do so that the scrolling is going to be smooth on mobile like it is on desktop with no .parallax-background image resizing, or issues with going outside of my parallax container like I currently am?

Only potential code fixes/solutions please.

*I have continued to work on this, and have solved the nav bar issue ( not lining up), but still am having issues with the mobile scrolling.

/*Navbar*/

.navbar {
  background-image: linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3)), url('https://images.unsplash.com/photo-1501924497965-792fefaea3dc?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1189&q=80');
  background-attachment: fixed;
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
  object-fit: cover;
  object-position: 0, -200%;
}


/*Hamburger Icon Transition*/

.container {
  display: inline-block;
  cursor: pointer;
}

.bar1,
.bar2,
.bar3 {
  align-self: right;
  width: 35px;
  height: 5px;
  background-color: #333;
  margin: 6px 0;
  transition: 0.5s;
}

.change .bar1 {
  -webkit-transform: rotate(-45deg) translate(-9px, 6px);
  transform: rotate(-45deg) translate(-9px, 6px);
  opacity: 0;
}

.change .bar2 {
  opacity: 0;
}

.change .bar3 {
  -webkit-transform: rotate(45deg) translate(-8px, -8px);
  transform: rotate(45deg) translate(-8px, -8px);
  opacity: 0;
}

.fork {
  position: absolute;
  top: -58px;
  left: -35px;
  opacity: 0;
  transition: 0.4s;
}

.knife {
  position: absolute;
  top: -35px;
  left: -34px;
  opacity: 0;
  transition: 0.4s;
}

.change .fork {
  opacity: 1;
  transition-delay: 0.4s;
}

.change .knife {
  opacity: 1;
  transition-delay: 0.4s;
}


/*Hamburger Icon Transition Ends*/


/*Navbar Ends*/


/*Main Page Top Parallax Element*/

.parallax-container {
  perspective: 1px;
  height: 0fr;
  overflow-x: hidden;
  overflow-y: hidden;
}

.parallax-background {
  background-image: url("https://images.unsplash.com/photo-1501924497965-792fefaea3dc?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1189&q=80");
  /* Set a specific height */
  /*min-height: 700px;*/
  /*Parallax Scrolling Effect */
  background-attachment: fixed;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}


/*.layer1 {
                position: absolute;
                left: 0;
                top: 50%;
                width: 100%;
                position: center;
            }

            .layer1 .logo {
                transform: translateZ(0px);
                position: relative;
                background-size: cover;
                top: -100px;
                max-height: fit-content;                
            }*/

.layer-1 {
  transform: translateZ(0px);
  position: relative;
  background-size: cover;
  top: -100px;
  max-height: fit-content;
}

.logo {
  object-position: center;
  background-repeat: no-repeat;
  opacity: .2;
}


/*Main Page Top Parallax Element Ends*/

@media(max-width: 768px) {
  .parallax-container .parallax-background,
  .parallax-container .parallax-background {
    background-attachment: scroll !important;
    background-size: cover;
  }
}

@media screen and (max-width: 768px) {
  .logo img {
    position: relative;
    left: 50%;
    transform: translateX(-50%);
  }
}
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=no">
<!-- CSS only -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
        <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
<script src='https://kit.fontawesome.com/a076d05399.js' crossorigin='anonymous'></script>


<!--Navbar-->

<nav class="navbar navbar-toggleable-md navbar-light bg-faded">

  <!--Hamburger Button-->

  <button class="navbar-toggler navbar-toggler-left" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="container" onclick="myFunction(this)">
                    <div class="bar1"></div>
                    <div class="fork">
                        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="189" height="189" viewBox="1.886 -234.614 1886.228 1886.228">
                            <defs>
                                <clipPath id="clip-path">
                                    <rect width="1890" height="1417"/>
                                </clipPath>
                            </defs>
                            <g clip-path="url(#clip-path)">
                                <image x="805" y="568" width="280" height="280" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAFC0lEQVRIia1WW0hjVxQ9iYkao1FjjI8PHwT7I/kSgs5YrWJFHT+qYFESWqs/dizSqiB+dEZbFAvjx1CmhaGlijRFW50PLUPrCD4rSjFBTFI1xsfVRCUkCtGYqLllHeaKo2OTjrPgcsO555y199p7L+V1dHSQN0VISAg5OjoiQ0ND9IawsDAikUhIcHAwYVmW8Pn8uzabrUYmk30RHx9/4na7vfw3ZrsBPp+PxMTEEKvVWsIwTLvFYvnH5XK1iEQiPsuywW+VEGRRUVHk4ODgE71e32A0Gh/J5XJpQUGBfWJioslkMgkE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6dnp6+mE8uwMjISEqIuQuIkMsKB3Z3d788Ozv7itugUqnul5WV/Qq/xZzBW68CQcKJApIUmcH9cVFvb+8Tk8l0n/uYlZX1oL6+/nt4IQK6CRgL2B3MwS8hOgxeubCw8JPJZKrmPmRnZz9ubW39GhaFoG5yDgBNg6AD+WMuQHRarXbQ4XCUc4uFhYXa7u7uz/EbUmHPfyExMZGSQnK/hP39/TMOh+MOtyCVSp91dnaq8R/Y+vo6HXx/gBO9dCP/hAzDXJClp6dPNjY2lm9ubpLl5WW/hzmgJHgwFv5IBUqlslyn033r8/nMKpXqPYVCQTODRwbiHABGAg3jdz8h5F8d0I6SNh1HXwAAAABJRU5ErkJggg=="/>
                            </g>
                        </svg>
                    </div>
                    <div class="bar2"></div>
                    <div class="bar3"></div>
                    <div class="knife">  
                        <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="189" height="141.7" viewBox="0 0 1890 1417">
                            <image x="805" y="568" width="280" height="280" xlink:href="data:img/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAAEeklEQVRIibVWW0gjZxQ+GRNN1GjiJTUXEU2MqAVTcRPxihC1qw+FFkUxiGJforRI8aErVemDxSIVbWn70lLs4j6JmIdaSqVgpVC3xepqpIQQNWlMzRhjrs3FJOVMHUnXbc2u+sHAzJwz88053/eff0AsFuuLiooeJCUlgUKhgLy8PKitrQWlUgmIyspKYDAYIJVKITs7G+RyOTQ0NFCxlJQUqKqqgvX1dYjFYtQRiUTAbrfD8fExdT05OQlCoRC4XC7k5OQA02q1lgHABwwG4w82m/2QIAgq8a5ACIXC3/DdsVjsa5/PNxiNRqmK7oxQJpN9QV/s7u5+SpLkCJ/PB2zxnRBqNJrPBQLBKfxTJWowTZLk+3dVKYE8arX69fibGxsb43q9fprD4dw6KeHz+aCzs3Otvb19Mj7g9XpHAGA6OTmZIr0tIxG5ubnUycDAwHtlZWUP44OBQGDk8PDwKyRE994KocvlAqvV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>
                        </svg>
                    </div>
               
    
                    <script>
                        function myFunction(x) {
                            x.classList.toggle("change");
                        }
                    </script>
                </span>
            </button>

  <!--Hamburger Button Ends-->

  <!--Cart-->

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item">
        <a class="nav-link" href="#">Home</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">Menu</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="#">About Us</a>
      </li>
    </ul>
  </div>
</nav>

<!--Navbar Ends-->

<!--Main Page Top Parallax Element-->
<div class="content parallax-container parallax-background">
      <div class="logo">
        <img src="https://images.unsplash.com/photo-1604262589890-fa778eb21216?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1166&q=80">
      </div>
      <div style="color: #777;background-color:rgba (255,255,255,.2);padding:50px 80px;text-align: justify;">
            <h2 style="text-align:center !important;">Spicy Dishes<h2>
            <hr class="parallax" style="background-position-x: center; width: 25%;"> 
            <h2 style="text-align:center !important;">Home cooked feel<br>By award winning<br>Chef</h2>
        </div>
   </div>
<div style="height:1000px;background-color: #FEFDFF;font-size:px">
  next element
</div>
</body>

0 Answers
Related