iPhone navigation glitch caused by jQuery and CSS

I have implemented a navigation that slides out from the right-hand side of my website when the menu button is clicked. However, there seems to be an issue with the transition on the navigation not working properly on iPhones. Here's how I've set it up:

The HTML:

<nav id="main_nav">
    <ul class="nav">
        <li class="services"><a href="#services" class="anchor-animate"><span>services</span></a></li>
        <li class="portfolio"><a href="#portfolio" class="anchor-animate"><span>portfolio</span></a></li>
        <li class="contact"><a href="#contact" class="anchor-animate"><span>contact</span></a></li>
    </ul>
    <div class="social_wrapper">
        <ul class="social">
            <li class="linkedin"><a href="http://linkedin.com/in/jaredtomeck" target="_blank">Let's Connect on Linkedin</a></li>
            <li class="twitter"><a href="http://twitter.com/jaredtomeck" target="_blank">Follow me on Twitter</a></li>
            <li class="dribbble"><a href="http://dribbble.com/jaredtomeck" target="_blank">View my shots on Dribbble</a></li>
        </ul>
    </div>
</nav>

<!-- start #wrapper -->
<div id="wrapper">
    <!-- start Header -->
<header id="main_header">
    <h1 id="logo"><a href="#home" class="anchor-animate">jtwebfolio</a></h1>
    <a href="#main_nav" class="menu-link"></a>
        <a href="#" class="close-menu"></a>
</header>
    <!-- end Header -->
</div>
<!-- end #wrapper -->

The jQuery:

// Add a class that determines whether the navigation hides or shows when menu-link is clicked
$('.menu-link').click(function(event){
    event.preventDefault();
if($('#main_nav').hasClass('open')){
    $('#main_nav').removeClass('open');
}else{
    $('#main_nav').addClass('open');
}
});

The CSS:

#main_nav {
    background: #3B3B3B;
    height: 100%;
    overflow: hidden;
    position: fixed;
    right: 0;
    top: 0;
    width: 7px;
    z-index: 99;
    -webkit-transition: width 0.4s ease;
    -moz-transition: width 0.4s ease;
    transition: width 0.4s ease;
}

#main_nav .nav {
    height: 100%;
    margin: 0;
    padding: 0;
    width: 100%;
}

#main_nav .nav li {
    height: 33.333333333%;
    padding: 0 7px 0 10px;
    text-align: center;
}

#main_nav .nav li a {
    color: white;
    font-family: "Panefresco400wtRegular", sans-serif, sans-serif;
    font-weight: normal;
    display: block;
    font-size: .875em;
    height: 100%;
    letter-spacing: 3px;
    margin: 0 auto;
    position: relative;
    text-decoration: none;
    width: 90%;
}

#main_nav .nav li a span {
    display: block;
    position: absolute;
    top: 52%;
    width: 100%;
}

#main_nav .nav li.services {
    background: #ff8772;
    text-shadow: 0 1px 0 #ba5f4f;
}

#main_nav .nav li.services a {
      background: url(../img/navicon_services.svg) no-repeat center 41%;
}

#main_nav .nav li.portfolio {
    background: #009491;
    text-shadow: 0 1px 0 #005a58;
}

#main_nav .nav li.portfolio a {
    background: url(../img/navicon_portfolio.svg) no-repeat center 40%;
}

#main_nav .nav li.contact {
    background: #ffc845;
    text-shadow: 0 1px 0 #a7832c;
}

#main_nav .nav li.contact a {
    background: url(../img/navicon_contact.svg) no-repeat center 43%;
}

#main_nav.open {
    width: 50%;
}

#main_nav.open + #wrapper {
    width: 100%;
}

#main_nav.open + #wrapper #main_header {
    width: 70%;
}

When the menu button is clicked, jQuery adds a class called "open" to the menu and removes the class if the menu has already been clicked. The CSS defines the styles for displaying the navigation when clicked, including CSS3 transitions.

The transition does not seem to work as expected on iPhone devices, although it worked fine on a friend's Nexus 7. If anyone could help me figure out why the menu's transition doesn't work on iPhones, I would greatly appreciate it. I've tried various solutions but haven't had any luck yet.

Thank you in advance!

Answer №1

Perhaps experimenting with the

-webkit-transform: translate3d(0, 0, 0);
function could yield interesting results instead?

Take a look at this demonstration on jsfiddle. While it does have its drawbacks, it appears to work well on the iPhone.

CSS

#main_nav {
    background: #3B3B3B;
    height: 100%;
    overflow: hidden;
    position: fixed;
    right: 0;
    top: 0;
    width: 200px;
    z-index: 99;
    -webkit-transition:all 0.5s ease;
    transition:all 0.5s ease;
    -webkit-transform: translate3d(193px, 0, 0);
    -moz-transform: translate3d(193px, 0, 0);
}

#main_nav.open {
    -webkit-transform: translate3d(0, 0, 0);
    -moz-transform: translate3d(0, 0, 0);
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Populate an HTML select with data as users click the create button

Encountering an issue when loading data into an HTML select after users press or click a button. The situation is as follows: A button is available to create another button dynamically Upon clicking the created button, a form is displayed Once the form i ...

How to stop a div from shifting downwards with CSS

Within my Web Application, I have implemented HTML code that displays different texts above input fields based on certain conditions. However, the issue I am facing is that the input fields are being shifted down by the text. I want the input fields to al ...

Is there a way to keep this function running endlessly when hovering?

Is there a way to modify this function so that the classes of my links continuously change colors while I hover over them, rather than changing only once? <script type="text/javascript"> $(".nav a").hover(function(e){ var randomC ...

The CSS-styled button I created is designed to display a list and has the functionality of submitting

Whenever I click on a button, it's supposed to show a list of choices. But instead, it tries to submit the values in the text input field. Css .dropbtn { background-color: #3498DB; color: white; padding: 16px; font-size: 16px; border: none; cursor ...

Expand the div to fit the rest of the screen following the fixed-size navigation bar

I am looking to create a webpage layout that includes a header, mid section, and footer. In the mid section, I want to have a fixed width navigation bar of 250px, with another div holding the content that stretches to fill the remaining space in the browse ...

Saving iFrame as Image using Codemirror and html2canvas

Here are a few experiments I conducted with html2canvas: Fiddle 1 (Using html2canvas): Fiddle 2 (Using html2canvas without Codemirror): Fiddle 3 (Using html2canvas with Codemirror): Fiddle 4 (Using html2canvas with Codemirror): I recently wante ...

Finding the offsetWidth (or similar measurement) for a list item (LI) element

Can jQuery be used to determine the width of an element? alert($("#theList li:eq(0)").offsetWidth); <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <ol id="theList"> <li>The quick brown ...

Chrome by Google is experiencing issues with displaying stylesheets

Here is a script I have been using: <?PHP $Document = $_GET["Name"]; Switch($Document) { Default: Echo "Incorrect document name! Please check if it exists."; Exit; Case "Style": $Document = "Folder/Styles/MainS ...

Creating a dropdown navigation menu using CSS from href divs

I am working on a script that includes divs with images and href functions for clicking on them. <div class="home"><a href="index.php?pagina=home"></a></div> <div class="events"><a href="index.php?pagina=events"></a& ...

What is the best way to select the child of the second-to-last child?

In the structure of my HTML code, I have an unordered list with a class "menu" containing several list items and corresponding anchor tags like this <ul class="menu"> <li> <a href="#1"></a> </li> <div&g ...

Customizing hover color with tailwind CSS

How can I change the color of an icon on mouseover using Tailwind CSS? I have tried to go from this https://i.sstatic.net/ObW6C.png to this https://i.sstatic.net/Tagp3.png, but it's not working. .btn { @apply agt-h-10 agt-w-10 agt-bg-zinc-100 agt- ...

Retrieving the clicked element in React JS

https://jsbin.com/diyenakife/edit?html,js,output JSX let MY = React.createClass({ sendMsg : function(e){ alert($(e.target).attr('data-id')); //sendMsgButton = ?? }, render: function() { return ( <button is class = ...

"Any tips on maintaining the blue color of my dropdown link when it is selected as active

I'm struggling to keep the bootstrap accordion dropdown link blue when it's active. I've tried different methods but none seem to work. What am I missing? Here's my code: <div class="visible-sm visible-xs" id="accordion" role="t ...

Creating a polished and stylish centered responsive image with Bootstrap 3

I am facing an issue with centering a styled responsive image on my website. Upon debugging, I discovered that the class "portimage" is causing the responsiveness to break. My requirement is to ensure that the images do not exceed 700px in size and have a ...

Resizing Your WordPress Header Logo

Hi there! I am struggling to resize the logo in the header of my website www.cookingvinyls.com. Despite my efforts, I can't seem to override the hardcoded version. I attempted to modify the width and height lines in header.php, but unfortunately, it ...

I currently have a CSS menu styled with the code below. Can you recommend the most effective method for centering the entire menu in the middle of the page

I am currently using CSS for a menu on my website. What is the best way to center the entire menu on the page? How can I adjust the menu items to appear in the center instead of on the left side? ul#css3menu1{ margin:0;list-style:none;padding:0;backgro ...

Unable to upload the file using AJAX

Here is my AJAX request where I am attempting to send form data to a PHP page and display messages accordingly. The problem I'm encountering is that when using serialize() method in AJAX, my file data is not being posted. As a result, the send.php scr ...

Having trouble displaying information in JavaScript after using getScript() to retrieve data from an API containing a JSON block database

I'm a newcomer to the world of Ajax/json/jquery and I find myself with a few inquiries. Currently, I am working with an API located at which contains a JSON block that looks something like this [{"id":"1","FirstName":"Micheal","LastName":"Kooling"}, ...

A guide to combining JSON arrays with identical values in JavaScript

I have a scenario where I need to merge data from two arrays based on the same value of "calleridnum":"0090000163", "uid":"0090000163", Here is the first array: [ { "_id":"55d44fe38879f12e6431c23c", "event":"ConfbridgeJoin", "channel":"SIP/peer_voip301 ...

Is there a way for me to showcase the latitude and longitude retrieved from JSON data on a Google Map using modals for each search result in Vue.js?

After receiving JSON data with search results, each containing latitude and longitude coordinates, I am attempting to display markers on a Google map modal when clicking "View Map". However, the code I'm using is not producing the desired outcome. Th ...