The customized menu options do not have any functionality when clicked

I'm trying to achieve a menu design similar to iOS, but I'm facing two major issues. Firstly, clicking on the links is not possible due to the linear-gradient applied. Secondly, when I click on the down arrow to access more menu items, the gradient effect disappears. How can I resolve these issues and make the menu work correctly?

You can view my code on CodePen.

Answer №1

  1. To make the gradient interact with the underling elements, you can utilize pointer-events: none

  2. If your gradient is absolutely positioned with top: 0, it will move along with scrolling. To address this issue, you can set the position of the gradient to fixed (though it will then stretch to fit the viewport). Alternatively, wrapping the list of options with another container will prevent the scroll from affecting the gradient's position. Here's an example:

<div class="select-wrap">
  <div class="select">
    ...
  </div>
</div>
.larger .select-wrap {
  width: 240px;
  height: 270px;
}

.larger .select-wrap .select {
  height: 100%;
  display: flex;
  flex-direction: column;
  text-align: center;
  overflow-y: hidden;
  -ms-overflow-style: scroll;
  scrollbar-width: none;
  position: relative;
}

.larger .select-wrap::after {
  content: '';
  position: absolute;
  display: block;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-image: linear-gradient(#80acdc, transparent, #80acdc);
  pointer-events: none; /* allowing mouse clicks to pass through */
}

document.querySelectorAll('.slide').forEach(function(next) {
  next.addEventListener('click', function() {
    var container = this.parentElement.querySelector('.select');
    sideScroll(container, 'bottom', 20, 25, 15);
  });
});

document.querySelectorAll('.slideBack').forEach(function(back) {
  back.addEventListener('click', function() {
    var container = this.parentElement.querySelector('.select');
    sideScroll(container, 'top', 20, 25, 15);
  });
});

function sideScroll(element, direction, speed, distance, step) {
  scrollAmount = 0;
  var slideTimer = setInterval(function() {
    if (direction == 'top') {
      element.scrollTop -= step;
    } else {
      element.scrollTop += step;
    }
    scrollAmount += step;
    if (scrollAmount >= distance) {
      window.clearInterval(slideTimer);
    }
  }, speed);
}
* {
  background: #80acdc;
}

.larger {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.larger .select-wrap {
  width: 240px;
  height: 270px;
}

.larger .select-wrap .select {
  height: 100%;
  display: flex;
  flex-direction: column;
  text-align: center;
  overflow-y: hidden;
  -ms-overflow-style: scroll;
  scrollbar-width: none;
  position: relative;
}

.larger .select-wrap::after {
  content: '';
  position: absolute;
  display: block;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background-image: linear-gradient(#80acdc, transparent, #80acdc);
  pointer-events: none;
}

.larger .select a {
  color: white;
  margin: 3.5px 0;
}

.larger .select a:first-child {
  margin-top: 0;
}

.larger #slide {
  position: absolute;
  left: 47%;
  bottom: 38px;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.larger #slideBack {
  position: absolute;
  top: 38px;
  left: 47%;
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css">

<div class="container">
  <div class="row">
    <div class="col-lg-3">
      <div class="larger">
        <div class="select-wrap">
          <div class="select">
            <a href="#">Action Lorem </a>
            <a href="#">Test Text</a>
            <a href="#">Action Lorem</a>
            <a href="#">Test Text</a>
            <a href="#">Action Lorem</a>
            <a href="#">Test Text</a>
            <a href="#">Action Lorem</a>
            <a href="#">Test Text</a>
            <a href="#">Action Lorem</a>
            <a href="#">Test Text</a>
            <a href="#">Action Lorem</a>
            <a href="#">Test Text</a>
            <a href="#">Action Lorem</a>
            <a href="#">Test Text</a>
            <a href="#">Action Lorem</a>
            <a href="#">Test Text</a>
          </div>
        </div>
        <i id="slideBack" class="slideBack fas fa-chevron-up"></i>
        <i id="slide" class="slide fas fa-chevron-down"></i>
      </div>
    </div>
  </div>
</div>

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

I need help with customizing the progress bar in HTML and CSS

How can I create a progress bar like the one shown below: https://i.sstatic.net/BFv87.png .detail-load { height: 42px; border: 1px solid #A2B2C5; padding: 1px; border-radius: 10px; } .detail-load > .detail-loading { ...

unable to choose the element

Initially, I successfully selected an element using ng-repeat. However, the developers have now implemented virtual repeat, rendering the following code ineffective. expect(stores.listStores(0).getText()).toContain('Prahran'); expect(element.all ...

Utilize Node.js to dynamically load and utilize all modules within a designated folder

Within the MyModule directory, I have these two JavaScript files. SayHello.js module.exports.SayHello = function() { return('Greetings!'); } SayByeBye.js module.exports.SayByeBye = function() { return('Farewell!'); } When w ...

AngularJS - Directives cannot pass their class name into inner template

My goal is to create a directive that can apply a class name conditionally. However, I encountered an issue where the code only works if the class name is hardcoded into the class attribute. When I attempt to use it with any expression, it fails to work. ...

Is it possible to verify the accuracy of a Sizzle selector?

Can a Sizzle selector be validated (ensuring correct construction) without actually executing it? ...

Ajax-powered Datatables

I am a beginner to data tables and I am attempting to retrieve data from a JSON text file (test1.txt). Below is an excerpt of the data present in the file, which contains over 5000 entries: [{"0":"22352442","ID":"22352442","1":"22126303","PARENT":"2212630 ...

error encountered in quickSort algorithm

function customSort(arr) { let pivot = arr[arr.length - 1]; const rightArr = []; const leftArr = []; for (let i = 0; i < arr.length - 1 ; i++){ if (arr[i] > pivot){ rightArr.push(arr[i]); } else { ...

javascript managing conflicts within jQuery scripts

I am facing an issue with the list of js files I have in my header.php on my website. The scripts are using jquery and ajax and include: <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/ ...

How to Retrieve the Value of an ASP TextBox Element with an HTMLEditorExtendor Connected, Through JavaScript

I am encountering a peculiar issue. I have a textbox with an ajaxToolkit HtmlEditorExtender connected to it. I want to retrieve the text entered in this textbox using javascript. To test this, I set up a simple experiment: var element = document.getEleme ...

having trouble with if and else if statements functioning properly

After testing my code, an issue arises with the second else if statement. When both divs are active, only the class of #project-wrapper is removed. I suspect there may be an error in how I wrote the second else if condition. Can you help me spot any mist ...

JavaScript code for opening and closing buttons

I created a button that successfully opens, but I am struggling to figure out how to close it. Can someone assist me with this? Additionally, I have one more query: How can I remove the border when the button is clicked? document.getElementById("arrowb ...

What is the best way to implement slideToggle to switch between display:none and display:inline?

Having an issue with slideToggle() function for implementing a "less and more" behavior on a paragraph containing a ".more" class: Here is the HTML code: <p class="more"> Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do ...

Tips for designing a hyperlink insertion modal while preserving text selection

I am working on a React website that utilizes Slate-React () for creating a rich text input field. Currently, Slate uses the browser's prompt() function to add hyperlinks to selected text. However, I need to customize the styling of the prompt modal a ...

Challenge involving flexbox and several squares, along with a @media adjustment for screens under 600px wide

I'm feeling a bit overwhelmed with this flexbox assignment I need to complete. The desired outcome should resemble the image here: https://i.sstatic.net/XKvPk.jpg When the screen is at or below 600px, the two blue squares should move beneath the red ...

Troubleshooting Problems with jQuery's .remove() Function

I attempted to create a simple game using JS and jQuery, keeping in mind that I am new to both languages. My goal was to create a function that allows users to delete their save within the game. However, despite my efforts, I faced issues with the function ...

Iterate through the JSON response once the AJAX call is successful

Apologies for the duplication, this question was originally asked on Stack Overflow, but as a newcomer to this topic, I am seeking guidance on how to achieve it? Below is my AJAX call: $("#btnprocess").click(function () { $.ajax({ ...

What sets apart innerText from html?

Can you explain the distinctions among innerText, text(), and html() functions? ...

Navigating the web page and locating the appropriate Xpath element to extract

Here is the HTML that needs to be extracted: <input type="hidden" id="continueTo" name="continueTo" value="/oauth2/authz/?response_type=code&client_id=localoauth20&redirect_uri=http%3A%2F%2Fbg-sip-activemq%3A8080%2Fjbpm-console%2Foauth20Callbac ...

Steps for creating a node.js and ejs file to deploy on 000webhost

I have developed a simple todo-app using node.js and ejs templating. My goal is to host it using 000webhost, a free web-hosting service. I successfully hosted a react app for free on this platform by running "npm run build", which converted the ...

Is there a way to implement full-page scrolling in Vue?

Looking for a Vue equivalent of the fullpage.js library. Need a component that allows scrolling through elements similar to fullpage.js. ...