Slide the horizontal navigation menu to reveal additional options upon clicking the arrow

I currently have a horizontal sub-menu with 8 options, but I need to add more without it dropping to a second line. My goal is to create a specific effect where the last option acts as an arrow. When this arrow is clicked, I want the entire menu to slide horizontally to the left, revealing additional options. Clicking a left arrow would then slide the menu back.

After researching for several days, I've come across examples that are similar, but none have worked in my situation. Many solutions involve plugins or carousels, which I believe are not suitable for my website.

Although I have implemented a version of the functionality using .hide() and .show() in jQuery, it doesn't produce the desired effect. I've assigned the class "firstSide" to the initial visible portion of the menu and "slideSide" to the hidden part. I've also experimented with .slideToggle() and adjusting widths, but haven't achieved the desired outcome.

You can view my example on CodePen: CodePen

Despite its rough appearance, the codepen demonstrates the function I am trying to achieve:

$('#arrowRight').on('click', function () {
    $('.firstSide').hide(function () {
        $('.slideSide').show();
        $('#blankSub1').show();
    });
});

$('#arrowLeft').on('click', function () {
    $('.slideSide').hide(function () {
        $('.firstSide').show();
    });
});

To prevent the "slideSide" class from displaying alongside the first part of the menu, I have set it to be hidden. This prevents the menu from occupying two lines due to the width constraints of the 8 menu options.

.slideSide {
display: none;
}

The desired effect can be observed on Apple's iPhone store page:

Despite attempting to replicate this effect, I have been unsuccessful thus far. Below is a screenshot of the menu on the referenced page.

If anyone has any suggestions or advice, I would greatly appreciate it as I seem to be at an impasse.

Answer №1

Take a look at this demo.

Does this meet your requirements?

In order to achieve the desired effect, nest a ul inside a div and apply overflow:hidden to the div.

Using jQuery, you can then create the sliding motion using either margin-left or by adjusting the position with position:relative; left:-100%. Remember to hide the arrows once they are clicked to display the other one.

Feel free to experiment with the values to suit your specific needs.

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

Mastering the art of fetching data from a database for showcasing using a Chrome extension

Embarking on my first chrome extension development journey has been quite thrilling. The process involves an interesting workflow - once the extension is installed and activated, whenever a user hovers over a specific product/ID displayed on a webpage, the ...

Tips for vertically centering elements in the header using flexbox

Within the header of my website, I have structured 3 separate divs - one for a logo, one for a search input, and one for a cart link. My goal is to align these 3 .col-md-4 divs in a vertically centered position. While these divs currently have an align-it ...

How to retrieve the latest document from every sender within a JavaScript array using Mongoose/MongoDB queries

I recently created a schema: var messageSchema = mongoose.Schema({ sender:String, recipient:String, content:String, messageType: Number, timestamp: {type: Date, default: Date.now} }); Next, I defined a model for this schema: var Mess ...

Troubleshooting JavaScript in Internet Explorer 9

Currently, I am encountering an issue while attempting to debug JavaScript .js files in my Solution using Visual Studio 2010 and IE 9. Despite placing breakpoints in the files, I am unable to debug successfully. I have attempted various troubleshooting ste ...

Hidden Bootstrap 4 Layout: Utilizing 2 Columns

For my latest project, I'm designing a bootstrap webpage with a 4-column grid layout. The twist is that two of these columns will initially be hidden - one on the left and the other on the right. By clicking a toggle button on the left, the user can r ...

Stylize the selected item in a kendoui listview

I am utilizing a kendoui listview to showcase various signatures in an ASP.NET MVC 5 project. My goal is for the listview to allow selection and exhibit data based on a predefined template. Everything is functioning properly, except for an unwanted margi ...

Routing in Node.js does not navigate to every internal route within an Angular application

I am currently developing a frontend application using Angular 9. In order to run the application, I have set up a NodeJs server to handle all incoming requests and direct them to the Angular Dist (Build) files. Issue at Hand The main problem I am facing ...

When making an AJAX request, ensure the response is in JSON format with individual properties rather than as a single

Here's an example of an AJAX request with JSON dataType: JavaScript: function checkForNewPosts() { var lastCustomerNewsID = <?php echo $customers_news[0]['id']; ?>; $.ajax({ url: "https://www.example.com/check_for_n ...

Ways to reconfigure an array for storing as pairs

I want to transform an array from array(1,2,3,4,5,6); to display in pairs like this: array(1,2) array(3,4) array(5,6) I know I can achieve this using foreach loop, but I'm wondering if there is a built-in PHP function that can do this automatical ...

I need assistance in utilizing my PHP variable UserNameID to remove the specific user's row from the database

I want to give users the option to delete their account from the database with a simple button click on my php forum. See the code snippet below: <div class="btn-group"> <button style="width:200px" type="button" class="btn btn-primary"> ...

generate an abundance of results exceeding the set limits from a form submission

I'm currently working with a script that submits search terms into a form and pulls back results. Here's the code I'm using: import mechanize url = "http://www.taliesin-arlein.net/names/search.php" br = mechanize.Browser() br.set_handle_ro ...

What is the best way to enable an image to be moved on top of another image?

Is there a way to allow users to drag around an image that is positioned on top of another image in an HTML file? I want the superimposed image to stay within the boundaries of the underlying image. Any suggestions on how this can be achieved? <html& ...

The AJAX pagination feature is malfunctioning following the addition of a new entry

On my main page "landing.php", I have a div where I am using an ajax function to call another page named "fetch_pages.php". In fetch_pages.php, data is loaded from the database in sets of 5 records each time. When the user scrolls to the end of the page, t ...

Could Chrome be miscalculating em unit values in media queries?

I have defined my media query breakpoints as shown below: @media screen and (max-width:48em){ /* phone */ } @media screen and (min-width:48.063em){ /* tablet */ } After using a PX to EM calculator to get the 48.063em value (as I was advised to us ...

First, the image is reduced by width until it reaches its maximum width, then the height is adjusted proportion

I have an image with the dimensions of 1200 x 200px. In the center of this image, there is a space measuring 500 x 200px which represents the main content of the entire image. Flanking this main content are additional contents on each side. It is important ...

Steps for eliminating the chat value from an array tab in React

tabs: [ '/home', '/about', '/chat' ]; <ResponsiveNav ppearance="subtle" justified removable moreText={<Icon icon="more" />} moreProps={{ noCar ...

Shift the card and all associated elements downwards

My challenge lies in adjusting the placement of an image within a card, without it overlapping text or other images. How can I achieve a layout where the top half displays the bottom part of the image and the bottom half contains additional elements like t ...

Find the most accurate color name corresponding to a hexadecimal color code

When given a hex-value, I aim to find the closest matching color name. For instance, if the hex-color is #f00, the corresponding color name is red. '#ff0000' => 'red' '#000000' => 'black' '#ffff00' = ...

The basic jQuery script is failing to function properly in the Opera browser

I've encountered an issue with a simple jQuery script I wrote. It seems to work fine on most browsers, except for Opera. Can anyone help me figure out what the problem might be? jQuery(document).ready(function() { jQuery("input:radio[name=virtuem ...

Adding an item to a JSON array in Angular

I'm having trouble adding a new item to the roleList JSON array. I've tried using push/concat, but it doesn't seem to update the roleList array. Any suggestions on how to resolve this? // The javascript : function RoleListCtrl($scope) { ...