Positioning CSS horizontal flyout menu - arranging the flyout items

In my design, I have a left main menu set to a fixed position and with a width of 90px. To enhance user experience, I want to add a secondary flyout menu that slides out from under the main menu, moving from left to right. The flyout menu should also have a fixed position but can vary in width. I plan to implement this slide-out effect using CSS transitions.

Before sliding out, the flyout menu will sit right at the edge of the main menu, ready to transition smoothly:

After sliding out, it will reveal its full content:

To determine the final position of the flyout menu, I can use 'left: 0' with a margin-left equal to the width of the main menu (90px). However, I'm struggling to figure out how to set the initial position so that the flyout menu starts flush against the right edge of the main menu, allowing for a seamless transition to the final position without any delay.

My current attempt involves starting with 'left: -100%', but this places the flyout menu too far to the left, resulting in a noticeable delay before it begins emerging from underneath the main menu.

Answer №1

Your method of determining the width of your elements is undefined, whether in pixels, percentages, or other means. To achieve the desired effect, simply subtract the skinny menu's width from the wider one and set the left value to the negative of that result.

For instance:

.skinny {
   width: 10%;
}

Therefore:

.wide {
    width: 50%;
    left: -40%;
}

as 50% - 10% equals 40%

http://jsfiddle.net/ingridly/pbgd4pqk/

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

Using a background image in a React component

Currently, I am working on a webpage and facing an issue while trying to set a background image for a Material UI element using the background-image CSS property. Despite researching online for solutions, I am unable to make the image appear. P.S.1: I eve ...

Create a new function that generates a unique div element

How can I replicate this function in a different container? function goto(id, t){ // Move to the designated div id using animation $(".headbox-wrapper").animate({"left": -($(id).position().left)}, 600); // Remove the "active" class from a ...

What is the best way to incorporate various styles into one :style attribute?

Within my vuetify project, I encountered a challenge of adding multiple styles to the same style attribute. Specifically, I have successfully implemented a vuetify breakpoint and now wish to include {backgroundColor:'Color'} within the existing a ...

The issue with drop down checkboxes not scrolling correctly is being experienced specifically in IE 8 compatibility mode

Hey there! Currently, I am employing a user-defined Drop down check box control in asp.net. However, whenever I scroll through the application, these drop down check boxes do not seem to move properly. In other words, when I scroll down, they fail to adjus ...

Adjust the font color as the SVG Animation in the Background transforms

I have designed an intricate SVG animation for my background and paired it with text. For reference, please refer to this jsFiddle link. HTML: <div class="content"> <!-- Background SVG --> <svg width="1500" height="800" xmlns="http ...

Creating gaps between flexbox divs for a more visually appealing layout

I am curious about the best practices for creating spacing between two divs that use flexbox. For example: https://i.sstatic.net/OZ8cp.png header { background-image: radial-gradient(circle, #72d6c9, #54d1ed, #7ac5ff, #bcb2fe, #f29cd9); height: 80px ...

Having trouble getting jQuery JavaScript to work on Wordpress and feeling lost about how to implement no-conflict mode syntax

Trying to implement the code from this Codepen http://codepen.io/eternalminerals/pen/qdGvMo on my WordPress website at I understand that since WordPress is in no-conflict mode, I need to change $ to jQuery. I have made this adjustment and ensured that the ...

Express.js problem: Unable to load CSS and JS files from the 'public' directory

Currently, I am working on a web project with Express.js and encountering difficulties in loading CSS and JavaScript files from the 'public' folder. Despite following common practices, it seems that something is amiss. Here is the layout of my pr ...

javascript various backgrounds on click

I have implemented a list to allow users to select their top 3 choices, and I am using JavaScript to track these selections and change the background color accordingly. 1st selection -> Green background 2nd selection -> Yellow background 3rd sel ...

Node.js Less compiler encountering parsing error with #zoom: 1; declaration

Whenever I use "#" hashtags in certain situations in a .less file, I encounter a node less compiler error. It seems to handle color hex values like color: #FFFFFF; fine, but when something like #zoom: 1; is used, it throws a parseError for unrecognized inp ...

Django - issue with table display showing empty row due to query set

In my project, I have two models: one named Season and the other one named Game: # Season class Season(models.Model): teams = models.ManyToManyField('Team', related_name='season_teams', blank=True) current = models.BooleanF ...

_problem with text formatting in bootstrap 4 template

I am having trouble formatting a 2-line text Right now, it appears like this https://i.sstatic.net/nJdOB.png I would like it to display like this https://i.sstatic.net/DflAK.png This is the HTML code I'm using with bootstrap <label for="check ...

Personalized FileInput within a card - Bootstrap 5

I am attempting to incorporate a custom file selection feature within a Bootstrap card: Here is my attempt: <style> label { cursor: pointer; } .custom-input-image { opacity: 0; position: absolute; z-index: -1; } </style> <div ...

What could be causing my bootstrap cards to have varying lengths?

I'm currently working on a project that requires me to apply a specific responsive design using HTML Bootstrap classes. I've managed to format it the way I want, but I'm puzzled as to why the width of my cards within rows is inconsistent in ...

Is there a Firefox extension for optimizing absolute CSS positioning for faster web development?

When it comes to working with CSS, I prefer using Firebug and adjusting the top and left values with the up and down arrow keys. Has anyone found a Firefox add-on that allows me to drag elements around and then easily copy and paste the top and left value ...

Splitting a string into individual parts using PHP

$team = "Admini-aruturek,Kura126"; $parts = explode('-', $team); foreach ($parts as $part){ echo substr($part, 0, strpos($part, ',')); echo substr($part, strpos($part, ',')+1); } So, you w ...

How come the translateX function doesn't function properly for fixed elements in IE9, IE10, and IE11?

Presently, I am endeavoring to obtain the desired outcome in Internet Explorer versions 9, 10, and 11 (functions flawlessly on Chrome and Firefox): When in mobile mode, there is a principal #container envelop that encompasses the entire website content al ...

Steps to turn off Bootstrap's fixed navigation on mobile devices

When a user visits the mobile version of the website or scales the webpage, the Bootstrap navbar will no longer remain fixed at the top. I am looking to set it as a normally scrolling view in the navbar. The Bootstrap class is "navbar-fixed-top" https:// ...

Ensure that the width of the table rows (tr) matches the width of the table header

I'm currently working on implementing a sticky table header. The issue I'm facing is that the width of tableHeaderRow does not match the width of tableHeader. Steps taken for creating sticky header: Make an Ajax call to populate the table with ...

What could be the reason behind CSS styles applying only when inserted within a style tag in my form, and not in the linked CSS file?

I want to express my gratitude for finding a solution to positioning Validator CallOuts on a web form through this question regarding repositioning the AJAX toolkit's CalloutExtender control. Does anyone know why applying CSS classes directly within ...