3

I would like to use visibility along with translate to control which content to show to the user.

As the user tabs through the navigation, therefore, the content below is transitioned via translateX() to show the proper information. Then, the containers in the viewport are shown to the user using visibility: visible and the containers outside of the viewport are hidden using visibility: hidden.

The CSS content for both containers looks something like:

.visible {
  position: absolute;
  width: 100vw;
  transform: translateX(0px);
  visibility: visible;
}

.hidden {
  position: absolute;
  width: 100vw;
  transform: translateX(-100vw);
  visibility: hidden;
}

This works as expected in Chrome and Firefox, but for some reason in Safari these properties don't perform as expected and the browser scrolls horizontally. You can see this behavior yourself by testing using this link (scroll below the fold and toggle between the tabs to observe the behavior).

I did see this Stack Overflow question, but the solution does not seem to work for me in this instance. I would like to keep the structure of the site as is and am hoping that a workaround could solve for this Safari bug.

5
  • nice page :D ...
    – mario ruiz
    Commented Oct 9, 2023 at 18:21
  • It seems to work fine on my end. Which version of Safari are you using? Commented Oct 10, 2023 at 6:02
  • Raised as WebKit bug: bugs.webkit.org/show_bug.cgi?id=262985 Commented Oct 10, 2023 at 23:44
  • Have you tried using vendor prefix -webkit-transform: translateX(0px); & -webkit-transform: translateX(-100vw); for browser compatibility?
    – Richard
    Commented Oct 11, 2023 at 15:25
  • @EreMännistö the issue is apparent on Safari 16.5.2 for example. None of the provided answers work.
    – Nick
    Commented Oct 16, 2023 at 21:16

0