Slide in from the right side of the screen

Hey everyone, I'm currently working on building a unique right-hand side page slide effect that involves two different states. Initially, when you open the sliding panel, I want to display a menu. Then, when a menu item is selected, I want another box to expand and showcase more information.

It's a bit challenging to explain exactly what I have in mind as I haven't come across anything quite like it before. Essentially, I envision the first div opening from the right with 100% height and 200px width. When a link is clicked within that container, I'd like another div to extend to the left and enlarge the box even further. I hope this makes sense! If anyone knows where I can find similar examples or has JavaScript tips to achieve this effect, please share them. Here's what I've coded so far:

HTML:

<div id="enquirypost">

<div style="width:200px;">
<a href="#extra" style="color:#999; text-decoration:underline;">Extra Expand</a>
<br />
<br />
Menu<br />
<a href="#" style="color:#fff; text-decoration:none;">Close</a>
</div>

<div id="extra">test</div>


</div>

<a href="#enquirypost" style="color:#999; text-decoration:underline;">Login/Register</a>

CSS:

body{margin:0;}
#enquirypost {
        height:100%;
        overflow:hidden;
        z-index:1000;
        width:0px;
        float:right;
        background:#ccc;
        font-size:20px;
        line-height:65px;
        position:absolute;
        top:0px;
        right:0px;
        color:#FFF;
        text-align:center;
        -webkit-transition:all 0.5s ease;
        -moz-transition:all 0.5s ease;}
#enquirypost:target 
{
    bottom:0px;
    overflow:auto;
    min-width:200px; 
    height: 100%;
    -webkit-transition:all 0.5s ease;
    -moz-transition:all 0.5s ease;
}

#extra {
        height:100%;
        overflow:hidden;
        z-index:1000;
        width:0px;
        float:right;
        background:#000;
        font-size:20px;
        line-height:65px;
        position:absolute;
        top:0px;
        right:0px;
        color:#FFF;
        text-align:center;
        -webkit-transition:all 0.5s ease;
        -moz-transition:all 0.5s ease;}
#extra:target 
{
    bottom:0px;
    overflow:auto;
    min-width:400px; 
    height: 100%;
    -webkit-transition:all 0.5s ease;
    -moz-transition:all 0.5s ease;
}

Check out this jsfiddle for a preview.

Answer №1

Find more #Additional content outside of the #inquirypost.

http://jsfiddle.net/davidja/wFutQ/15/

    <div id="inquirypost">

    <div style="width:200px;">
    <a href="#additional" style="color:#999; text-decoration:underline;">Expand Additional</a>
        <br />
        <br />
        Menu<br />
    <a href="#" style="color:#fff; text-decoration:none;">Close</a>
    </div>

    </div>

    <a href="#inquirypost" style="color:#999; text-decoration:underline;">Login/Register</a>

    <div id="additional">test</div>

Answer №2

Experiment with moving the #extra div outside of the #enquirypost div and observe the changes. It may not be exactly what you're seeking, but I found that it improved the appearance when tested on your jsFiddle.

Furthermore, eliminating the float attribute becomes necessary when using position: absolute to optimize the code structure. Consider adding "-o-transition" along with "transition" for cross-browser compatibility and smooth page rendering.

Answer №3

I have found a solution that may be what you're looking for:

http://jsfiddle.net/wFutQ/17/

The trick here is to place the div with the "submenu" class before the div with the "menu" class. This allows you to use the CSS selector .submenu:target + .menu { to keep the menu open when the submenu is targeted.

You can also nest subsubmenus while keeping the submenu and menu open using the selectors .subsubmenu:target + .submenu and

.subsubmenu:target + .submenu + .menu
.

Here is an example of my HTML code (some classes are not currently utilized):

<div>

    <div id="extra" class="menuPart submenu">
            <div class="content">test</div>
    </div>

    <div id="enquirypost" class="menuPart menu">
        <div class="content">
            <a href="#extra" style="color:#999; text-decoration:underline;">Extra Expand</a>
            <br />
            <br />
            Menu<br />
            <a href="#" style="color:#fff; text-decoration:none;">Close</a>
        </div>
    </div>

</div>

<a href="#enquirypost" style="color:#999; text-decoration:underline;">Login/Register</a>

And here is my CSS code:

body {
    margin:0;
}

.menuPart {
    height: 100%;
    width: 0px;
    font-size:20px;
    line-height:65px;
    position:absolute;
    color: #FFF;
    text-align: center;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
}

.menu:target {
    overflow: auto;
    min-width: 200px;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
}

.submenu:target + .menu {
    overflow: auto;
    min-width: 200px;
}

.submenu:target {
    overflow: auto;
    min-width: 200px;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    padding-right: 200px;
}

#enquirypost {
    background: #CCC;
    right: 0px;
}

#extra {
    background: #000;
    right: 0px;
}

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

Data transfer from server to client using Node.js and express

Hello there! We have just begun diving into server-side code in school and it's definitely a challenge. I'm currently working on connecting my client-side JavaScript to my server-side JavaScript, where the server side contains an array of 2 objec ...

Integrating a feature for displaying No Results Found

I am struggling to modify a script for auto-completing search fields. My goal is to include a "No Results Found" option along with a hyperlink when no matching results are found. I'm having difficulty figuring out how to add an else statement to displ ...

The remove() function is failing when attempting to add input fields dynamically

Hello, I am currently facing an issue with dynamically generating input fields based on AJAX results. Unfortunately, the .remove() function is not working as expected and my current solution involves repetitive code. Any guidance or assistance would be g ...

What could be causing the @each statement in SASS to not function properly in Next.js?

I am struggling with my SCSS files and color scheme colors.scss @import './variables'; $colors: ( p: $color-primary, s: $color-secondary, t: $color-tertiary, q: $color-quartary, ); @each $name, $hsl in $colors { .c-#{name} { colo ...

The function Data.model.updateItem is throwing a TypeError: it is not recognized as a valid function

Encountered an issue in Keystone JS with MongoDB: Error shows 'Vehicle.model.updateItem is not a function TypeError: Vehicle.model.updateItem is not a function'. The objective is to update the model using an object similar to how Items were crea ...

Error on JSP Hello Page

As a novice in JSP, I am attempting to create a simple JSP page where I can set my class fields for name and surname and display them on the page. Below is my Java class: package org.mypackage.person; /** * * @author cemalinanc */ public class Person ...

What steps do I need to take in order to transform my standard filter form that uses a submit button, into one

Currently, there is a table of venues displayed on the index page. Users can filter these venues by area and type using a form with a submit button that triggers a page reload. After filtering, all the matched venues are shown, and the form automatically ...

Is there a way to eliminate all elements with a specific class name from the DOM?

My website includes a section with product elements that are identified by the cart-item class. <div id="cart"> <h1 class="ui-widget-header">Demo Site</h1> <div class="ui-widget-content"> <ol id="insert-zone" cl ...

Exclude all elements within a div with the class name using jQuery's serialize() function

I am attempting to filter out hidden form values from the jQuery output of serialize(). The invisible inputs/selects are nested within div.ui-tabs-hide elements. I need to include all input and select elements within divs that do not have the ui-tabs-hide ...

Bird's-eye view captured by a high-angle camera

As I rotate a sphere around the z-axis, I'm looking for a way to prevent the camera from causing motion sickness by creating a stable elevated view of the sphere. How can I achieve this without the camera's movements being so jarring? If you&apo ...

Can someone help me figure out the issue with my Angularjs ng-repeat implementation?

After spending hours trying to figure out why something so simple is not working, I'm at a loss. Testing with a dummy list proves the functionality works, but when I connect my server-side data source, it fails. The JSON returned from the AJAX call i ...

transforming a JavaScript array into an object

output: Array(5) [ "Samsung", "Iphone", "Nokia", "Xiomi", "Blackberry" ] another output: Array(5) [ Object { id: "Samsung", label: "Samsung" },Object { id: "Iphone", label: ...

The Python CGI script fails to run

While working on a simple python project with an HTML file, I stumbled upon a helpful tutorial that outlined how to execute the code. Check out the provided HTML code snippet: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html ...

The true meaning of CSS3 transition is often misconstr

I'm trying to create a simple linear transition effect, but for some reason it's not working. Any suggestions on what might be causing the issue? HTML <div class="button-modern" style="background-color:#e73032"> <span style="color: ...

Creating a custom function that targets a specific element

When working with JavaScript, you may often encounter functions written in the form of document.getElementById("element").someFunction(); or $("element").someFunction(); rather than the traditional someFunction($("element"));. This is similar to a function ...

Updating an array in JavaScript with a dynamically generated key name while working in the ReactJS framework

I have multiple dropdown menus, and when I select an option from any of them, I want to store the selected value in the component state. The onChange function that I call looks like this: function handleSelect(event) { console.log(event.target.value); ...

Unable to execute npm run command

I am working on a ReactJS project and have a package.json file that includes various dependencies: { "name": "front-end", "version": "0.1.0", "private": true, "dependencies": { "@ ...

Error: Attempting to access properties of an undefined value (trying to read 'map') within React Views

I've encountered a persistent error that's been difficult to troubleshoot. It seems like my list of objects is empty, even though I can see it when logging to the console. My suspicion is that there might be an issue with how I'm using setSt ...

What is the best way to implement component lazy loading in Preact?

My objective is to create two bundles during the build process, one for the index.tsx file and another for the lazy.tsx file. I am confident that there are one or two options that I am overlooking. Check out the example project on GitHub - example project ...

What could be causing Nextjs13 to fail in recognizing an authentication route, resulting in a 404 error?

I have been working on a project utilizing NextJs v13 with Strapi v4 as the backend. My project includes separate layouts for the site, login, and dashboard. While working on the login section, I implemented NextAuth for authentication. However, upon submi ...