Setting the z-index property in CSS allows one element to stack above another

My website has a hamburger menu that causes an issue when I navigate to a specific page with a card element. Whenever I open the menu while on this page, the card element ends up overlapping with the menu inexplicably. Despite trying various solutions, I cannot seem to fix this problem in my CSS code...

This is my HTML for the react component:

import TopNavBarMobileComponent from "../TopNavMobileComponent";
import github_icon from '../../assets/github_icon.png'
import instagram_icon from '../../assets/instagram_icon.png'
import my_picture from '../../assets/my_picture.jpg'
import '../../css-mobile/AboutMeStyle.css'

function AboutMeMobile() {
    return (
        <div>
            
            <TopNavBarMobileComponent />

            <div className="info-card-container">

            <aside class="profile-card">

                <div class="mask-shadow"></div>
                <header>
                    <a href="https://github.com/georgesepetadelis/">
                    <img src={my_picture} />
                    </a>
                    <h1 className="name">GEORGE SEPETADELIS</h1>
                    <h2>Software engineer</h2>
                </header>

                <div class="profile-bio">
                    <p>16 y/o and I'm from Greece. I have experience with many programming languages and Frameworks for all mobile platforms like Flutter, React-Native and also native Android and iOS development with Java and Swift. Also I am currently working on Unreal engine and Unity for some big projects. </p>
                </div>

                <ul class="profile-social-links">
                    <li>
                    <a href="https://github.com/georgesepetadelis/">
                        <img src={github_icon} />
                    </a>
                    </li>
                    
                    <li>
                    <a href="https://www.instagram.com/sepetadelhsss/">
                        <img src={instagram_icon} />
                    </a>
                    </li>

                    <li>
                    <a href="https://twitter.com/gsepetadelis">
                        <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/210284/social-twitter.svg" />
                    </a>
                    </li>
                </ul>

        </aside>

            </div>

        </div>

    )
}

export default AboutMeMobile;

This is my CSS file:

@import url(https://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,700italic,800italic,400,600,700,800);

img {
    max-width: 100%;
}

.name {
    margin-top: 7%;
}

.info-card-container {
    z-index: 1;
    margin-top: 15%;
    width: 100%;
    position: absolute;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.profile-card {
    position: relative;
    width: 90%;
    margin-top: 8%;
    padding: 40px 30px 30px;
    background: #fff;
    border: 5px solid rgba(255,255,255,.7);
    text-align: center;
    border-radius: 8px;
    transition: all 200ms ease;
}

.mask-shadow {
    z-index: -1 !important;
    width: 95%;
    height: 12px;
    background: #000;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0 auto;
    position: absolute;
    border-radius: 4px;
    opacity: 0;
    border-radius: 80px;
    transition: all 400ms ease-in;
}

.mask-shadow {
    opacity: 1;
    box-shadow: 0px 30px 60px -5px rgba(55,55,71,0.3);
    position: absolute;
}

.profile-card header {
    display: block;
    margin-bottom: 10px;
}

.profile-card header a {
    width: 150px;
    height: 150px;
    display: block;
    border-radius: 100%;
    margin: -120px auto 0;
    box-shadow: 0 0 0 5px #3300ff;
}

.profile-card header a img {
    border-radius: 50%;
    width: 150px;
    height: 150px;
}

.profile-card header h1 {
    font-size: 20px;
    color: #444;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.profile-card header h2 {
    font-size: 14px;
    color: #acacac;
    text-transform: uppercase;
    margin: 0;
}

.profile-bio {
    font-size: 14px;
    color:#a5a5a5;
    line-height: 1.7;
    font-style: italic;
    margin-bottom: 30px;
}

.profile-social-links {
    margin:0;
    padding:0;
    list-style: none;
}

.profile-social-links li {
    display: inline-block;
    margin: 0 10px;
}

.profile-social-links li a {
    width: 55px;
    height:55px;
    display:block;
    background:#f1f1f1;
    border-radius:50%;
    -webkit-transition: all 2.75s cubic-bezier(0,.83,.17,1);
    -moz-transition: all 2.75s cubic-bezier(0,.83,.17,1);
    -o-transition: all 2.75s cubic-bezier(0,.83,.17,1);
    transition: all 2.75s cubic-bezier(0,.83,.17,1);
    transform-style: preserve-3d;
}

.profile-social-links li a img {
    width: 35px;
    height: 35px;
    margin: 10px auto 0;
}

.profile-social-links li a:hover {
    background: #ddd;
    transform: scale(1.2);
    -webkit-transform: scale(1.2);
}

Answer №1

When working with CSS, it's important to understand the 3D object location which consists of not just x and y coordinates but also a z element. This z element determines the stacking order of elements on a page - determining which ones appear on top and which are positioned behind others. To control the z element (or index), you can utilize the z-index property.

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

Animate the opening and closing of a div element

A form is set up for editing. Within this form, there are 2 separate divs. The first div is labeled editForm, which displays the form for editing, and the second div is labeled infos, which shows the details of this form. My goal is to have the infos se ...

Developing a feature that allows users to switch between different sets of information

I'm currently exploring a new project and attempting to design a toggle that switches between monthly and annual payments based on the user's selection, much like the functionality found here: . At present, I have implemented two sets of price c ...

How can the checkbox be checked dynamically through a click event in Angular.js or JavaScript?

I want to implement a functionality where the checkbox gets selected when a user clicks on a button using Angular.js. Here's an example of my code: <td> <input type="checkbox" name="answer_{{$index}}_check" ng-model=&q ...

Difficulty with float left in HTML/CSS causing divs to appear below each other instead of side by side

I'm currently facing an issue with creating a 2 column layout using the classes "left" and "right". Right now, the .right column is not floating left and is instead appearing below the .left column. Interestingly, when I delete the content inside .le ...

Having trouble getting PostCSS nesting to work with CSS variables in Tailwind CSS and Next.js?

I've been attempting to utilize PostCSS nesting alongside CSS variables, but unfortunately the CSS variables are not being converted at all. Instead, I am seeing Invalid property value in the DOM for CSS Variables. The tailwind.css file I have inclu ...

Keep the footer at the bottom of the screen without needing to define a 100vh in Material UI

In the process of developing my react app with MUI framework, I encountered various challenges in creating a sticky footer at the bottom of my screen. After exploring different solutions, one approach that I found most satisfactory is as follows: export de ...

Adding a new entry to a database that involves many-to-many relationships

I recently inquired about executing a fetch query on a database with a many-to-many relationship. As I delve deeper into learning SQL + PHP, I encountered a rather intricate scenario: Within my database, I have the following tables: Songs Link ...

How can we verify that a state parameter in React is not undefined?

Greetings and thank you for your valuable time! I am currently immersed in a React and Flux tutorial that can be found at this link: React Flux Tutorial The challenge I'm encountering revolves around creating a new author. Whenever I attempt to inpu ...

Dynamic HTML text colors that change rapidly

I have an interesting question to ask... Would it be possible to create text that switches between two colors every second? For example, could the text flash back and forth between red and grey? I don't mean changing the background color, I mean act ...

The result of calling Object.keys(obj) is not being shown on the screen

I have come across a code snippet that functions perfectly fine in the console, however, it is not being displayed on the screen. Any assistance in resolving this issue would be greatly appreciated. {Object.keys(flags).forEach(product => { return ( ...

Troubleshooting Problems with Bootstrap Navbar

I'm facing an issue with the background on the navbar of a website I am currently working on. The background works fine when expanded, but on the collapsed view, the button does not open the navbar as expected. Below is the code snippet that I have be ...

The background-size property in CSS does not seem to properly display on iPhones

Hello there! I'm facing an issue with my CSS code when it comes to displaying the image on Safari browser. It works perfectly fine on other browsers, but for some reason on Safari, the image doesn't show up correctly. I tried using a media query ...

Implement the CSS Grid feature to perfectly align the red field inside the red border on Grid Attack level 63

I've hit a roadblock on level 63 of Coding Fantasy: Grid Attack and I can't seem to figure it out after hours of trying. The game doesn't offer any solutions, and there's no way to skip the level. Can anyone help me with the solution pl ...

Tips for sending an extra parameter to the callback function when using the loader.parse method in Three.js

The Parse method of the Loader object in three.js allows you to specify a callback function that will be triggered upon completion of the parsing process. This callback will receive a unique argument which represents the parsed object. However, I am encou ...

Displaying multiple Blender-exported objects with their corresponding meshes and materials in Three.js

I recently created two unique objects using Blender, each with their own distinct materials and textures applied through UV mapping. During the rendering process using CanvasRenderer from Three.js, I encountered an issue. When I attempted to export the mo ...

Even though the colspan values are identical, they may appear differently when rendered in a web browser

When I run the program and view it in the browser, the colspan values are the same but the cells look different lengths. The Parent/Guardian Information cell is longer than the Student Information cell. Can you explain why this might be happening? Thanks ...

Executing a function in MobX after an asynchronous action is completed

I'm facing an issue with MobX where I need to call onSortHandler and loadingCallback after an asynchronous action in my store. However, the order of these calls is getting mixed up due to the nature of the async action. To make things more complicated ...

Words spilling onto the picture

The issue of the text col-xs-9 col-md-9 overlapping with the image col-xs-3 col-md-3 has been persistent. Even after attempting to add the img-responsive class to the img src, it continues to not work as expected. Interestingly, CSS was intentionally avoid ...

React components featuring Material UI icons

I'm in need of assistance. I am looking for the Material UI icons, but I can't seem to find any information on how to obtain them. https://i.stack.imgur.com/FAUc7.jpg ...

The iPhone header position switches when an HTML5 input type number is selected

I am currently working on a project that involves jQuery Mobile and PhoneGap. One issue I am encountering is when using the iPhone version, the header position changes when I click on an input type number. NOTE: When I focus on the input type number in my ...