Menu design with child element creatively integrated into parent element

For my mobile project, I am working on creating a window blind effect menu. The process is quite simple:

  1. Clicking on the menu icon moves the bar to the top while the menu drops down
  2. Upon selecting an item, the menu smoothly "rolls" up in a window blind style, revealing the content in a similar manner

Here are the sections of CSS that I believe may be causing the issue:

#menu_wrapper ul {
display: none;
top: 100px;
right: 0;
bottom: auto;
left: auto;
position: absolute;
height: auto;
width: 100vw;
margin: 0;
padding: 1em;
color: #f5f5f5;
font-size: 2.5rem;
background-color: rgba(0, 0, 0, 0.8); }

#menu_wrapper ul a {
color: #f5f5f5; }

#menu_wrapper ul a:hover {
color: #00a8b0;
text-decoration: none; }

#menu_wrapper address {
margin-top: 1.5rem;
font-size: 1.5rem; }


#menu_wrapper .item-content {
display: none;
top: 50%;
right: 0;
bottom: auto;
left: auto;
position: absolute;
height: auto;
width: 100vw;
margin: 0;
padding: 1em;
z-index: 3; }

The challenge I am facing is that the "item-content" remains within the parent "menu_wrapper". This could be due to the absolute positioning of "menu_wrapper," but I am struggling to resolve these specific cases. It may also involve my jQuery code, though I am uncertain (any suggestions are appreciated)!

Here is a link to a jsFiddle for you to examine: http://jsfiddle.net/smpte11/5s6qxntt/

Thank you.

EDIT: I want to clarify the effect I aim to achieve. Upon clicking the menu, it drops down, and when closed, it rises until it disappears in a window blind manner. Additionally, clicking on a menu item causes the menu to roll up and disappear (similar to closing it), with the content appearing below. Naturally, the same effect occurs when navigating back to the previous level.

Answer №1

It's possible that this may not be exactly what you're aiming for - I've made some adjustments to your Fiddle with the following modifications:

CSS:

 #menu_wrapper .item-content {
   position:relative;
 }

Now, each submenu is positioned next to the submenu headline.

jQuery:

function showPageContentPhone() {
 menu.on('click', 'li:not(:last-child) a', function () {
    console.log("click");
    var that = $(this);
    that.next('div').slideToggle();

  });
}

Previously, the main navigation would slide up every time a submenu item was clicked. Now, the submenus function as intended (but the previous effect may have been intentional).

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

employing variable in front of json notation

For my github-gist project, I am using JavaScript and AJAX to customize the file name. Here is the JSON data I am working with: var data = { "description": gist_description, "public": true, "files": { "file.txt" : { "content": gist_conten ...

JavaScript - Verify if all properties belonging to an object are set to true

I'm facing a challenge with an object that contains various fields which could potentially be set to true for a user, similar to a list of achievements. If I have an object like {one: true, two: false, three: true}, how can I prevent the function from ...

Ways to determine the total amount of days in a given month

As I create a countdown timer, the process involves determining the remaining days in a given month by subtracting the current date from the total number of days in that month. For instance, if there are 30 days in September and 8 days have already passe ...

Numerous social media sharing buttons conveniently located on a single webpage

Currently, I am working on a research database project where the goal is to allow users to share articles from the site on various social networks such as Facebook, Twitter, LinkedIn, and Google+. To achieve this, I successfully implemented share buttons ...

The auto search feature seems to be malfunctioning after clicking the button

Despite my best efforts, I am still unable to resolve this issue. I have tried numerous links and code snippets, but I am encountering some difficulty in finding a solution. THE ISSUE: I have an input field with type 'Text' for searching employ ...

Solving the Dilemma of Ordering Table Rows by Value in JavaScript

I am currently working on a table and my goal is to display rows in an orderly manner based on the sum of their columns. Essentially, I want the rows with the highest values to be displayed first, followed by rows with second highest values, and so on. Des ...

unrestricted motion through the utilization of css3 transitions and translations

When applying a new CSS translate, it's common practice to specify the exact number of pixels you want an element to move, such as 50px, 60px. This results in a relative movement from its current position. You can see an example of this here: http://j ...

Are you wondering about the correct way to install eslint-config-airbnb without encountering any "UNMET PEER DEPENDENCY"

➜ beslint git:(master) ✗ eslint -v v3.15.0 ➜ beslint git:(master) ✗ npm install -g eslint-config-airbnb eslint-plugin-jsx-a11y eslint-plugin-import eslint-plugin-react /Users/next/.nvm/versions/node/v7.5.0/lib ├── UNM ...

Creating a Custom Hot Module Replacement Hook for Vue.js and Webpack

Is there a way to create a hook that triggers when a Vue component is updated using hot module replacement? [HMR] App is up to date. Now I want to execute a specific method after the update. ...

Top method for identifying genuine users and preventing bots

Utilizing a Maps API can be costly, especially with the fees per request To minimize requests, I heavily rely on caching techniques The API is invoked on every pageload, but unnecessary for non-human users like googlebot What would be the most effective ...

Adjust the background to scroll to the bottom of the image first and then change it to be fixed

Here is the code I have written: body{ margin:0; padding:0; line-height: 1.5em; background-image: url(http://fehlbelichtet.stefanwensing.de/wp-content/uploads/sites/6/2016/04/alte-strasse-endlos.jpg); background-repeat:no-repeat; background-attachment: ...

Guide on decrypting a file encrypted with C# using Node JS

I currently have encrypted files in C# using DES and PKCS7 encryption. My objective is to decrypt these files in Node JS. The decryption code in C# that I am using appears like this: public string SSFile_Reader( string fileToDecrypt ) { DESCryptoService ...

Using Google Apps Script to retrieve post data from a web application through the `doPost` method

https://i.sstatic.net/2HpSJ.jpg When trying to access formIDArray in my appscript, it returns nothing. How can I properly access the object "FormIDArray[]" from the appscript environment? ...

Issues with error handling in ExpressJS arise frequently

In the server.js file, towards the very end, there is a block of code that appears to handle errors: app.use(logErrors); function logErrors (err: Error, req: Request, res: Response, next: NextFunction) { console.log(err); mongoDal ...

What is the best way to loop through an array of documents returned by Mongoose using Mongoose?

Within my server built on node.js (express based), there is a function that retrieves all users. Here is the function: export async function findAllUser() { let users = await User.find({}).exec() return users } In my node.js application, I have two m ...

Iterating through a JSON object and an array

I've been attempting to iterate through a JSON object but I'm struggling with it. Below is the JSON object I need to work with. This JSON data will be fetched from another website, and my goal is to loop through it to extract certain details. ...

What is the best way to manage the appearance of multiple elements in React simultaneously?

I have a fun little game that I've been working on. Check it out - here In my game, when you hover over a square, it turns blue. If you hover over it again, it turns white. I achieve this by applying styles to the event target on hover. const handleM ...

What could be causing XMLHttpRequest to encounter issues with the readystate and status states while running on localhost

Hey guys, I'm having some trouble with this code and can't figure out why it's not working. Here is the code snippet: <script> function findMatch() { if(window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); ...

Is there a way to conceal a div element if the user is not logged in?

I have been enlisted to assist my friend with a project involving his website. Within the site, there is a checkbox that prompts the display of a div when selected. I believe it would be more effective for this checkbox to only be visible to users who are ...

Fade out all the other images using jQuery

I have created a jQuery code to fade images, but when I move the mouse over them all images fade simultaneously! $(".playThumb").fadeTo("normal", 1); $(".playThumb").hover(function() { $(".playThumb").each(function() { if ( $(this) != $(this) ...