Opacity of CSS3 Modals Background Non-Transparent

I'm currently working on developing a Pure CSS3 Modal.

However, I encountered two issues along the way:

  1. The background doesn't change to transparent black color when the modal is clicked. This is a common feature in modals where it forces the background to become a transparent color. See screenshots for reference:

The original background color is #fff (white). When the modal is active, the background turns into a greyish transparent color.

  1. I've been contemplating how I can implement a 3D Flip Horizontal Animation or create a smooth rotation effect instead of the plain top-to-bottom movement for the modal transition.

Here's the HTML code snippet:

<p><a href="#modal" class="btn go">Display Modal</a></p>
    </div>

    <div id="modal">
        <div class="modal-content">
                <h1>What is a modal?</h1>
            <div class="copy">
                <p>A modal window is any type of window that is a child (secondary window) to a parent window and usurps the parent's control. It is commonly associated with an Internet Web site pop-up window that stays in front of the original window.  A user may not press any controls or enter any information on the parent window (the original window which opened the modal) until the modal has been closed.</p>
            </div>

                <a href="#" class="btn">Close Modal</a>
            <div class="overlay"></div>
        </div>
    </div>

And here are the stylesheet codes:

    .container {
    width:50%;
    margin:90px auto
}


#modal {
    background:#97d2f1;
    left:50%;
    top:-50%;
    width:80%;
    padding: 20px;
    margin:-250px 0 0 -40%;
    position:absolute;
    color: #fff;
    visibility: hidden;
    box-shadow:0 3px 7px rgba(0,0,0,.25);
    transition: all 0.4s ease-in-out;
    -moz-transition: all 0.4s ease-in-out;
    -webkit-transition: all 0.4s ease-in-out;
}

#modal:target {
        opacity: 1;
        top:50%;
        visibility: visible;

    }


#modal .overlay {
    background-color: #000;
    background: rgba(0,0,0,.5);
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    z-index: 10;
}



.btn {
    padding:0 3em;
    outline:none;
    border:none;
    color:#fff;
    text-transform:uppercase;
    font-weight:700;
    letter-spacing:1px;
    font-size:1em;
    line-height:4;
    overflow:hidden;
    border-radius:5px;
    background:rgba(0,0,0,0.2);
    text-align:center;
    cursor:pointer;
    margin:20px auto;
    display:block;
    width: 30%;
    margin-top: 40px;


}

Check out my JS FIDDLE link for live demo: http://jsfiddle.net/agx4w5pm/1/

If you have suggestions on improving my JSFIDDLE code, it would be greatly appreciated!

Thank you in advance for your assistance!

Answer №1

Was a bit confused by your initial point, but I've successfully added the rotation effect to your modal as requested in the second point. Please update the following classes:

#modal {
    background:#97d2f1;
    left:50%;
    top:-50%;
    width:80%;
    padding: 20px;
    margin:-250px 0 0 -40%;
    position:absolute;
    color: #fff;
    top: 50%;
    box-shadow:0 3px 7px rgba(0,0,0,.25);
    transition: all 1s ;
    -moz-transition: all 1s ;
    -webkit-transition: all 1s ;
    -webkit-transform: rotateX(270deg); /* Added for rotation effect */
    -webkit-transform-origin: 50% 50%;
    -webkit-perspective: 1500px; 
}

#modal:target {
    opacity: 1;
    top:50%;
    -webkit-transform: rotateX(0deg);
}

Note the

-webkit-transform: rotateX(270deg);
property that is responsible for the rotation effect.

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

Expansive background with adaptable height dimensions

Is there a way to use Foundation to create a header with a full-width image and responsive height using CSS only, or do I need to use JavaScript for this? Can someone assist me with this? This is the code from index.html: <!doctype html> <html ...

Providing an image in a Django web application

I'm having trouble displaying an image on my Django web app. Despite placing the image in the static folder, and the hello.html in the templates folder, I'm still getting a broken image link. Below is the content of hello.html: {% load static %} ...

What is the best way to switch the visibility of a div on click from another div?

My goal is to make a div toggle visible or hidden when another div is clicked. The only connection between the two divs is that they are both nested within the same parent div. There's a DIV element with the class of "comment" which contains a DIV ele ...

Creating consistency in tab spacing within a text area

At the moment, I am utilizing an HTML textarea attribute to collect input from users and then displaying that text back to them formatted. However, there seems to be an issue with how it handles tabs. For instance, when attempting to input the following: ...

Enhancing User Interaction with Bootstrap Input Forms

Struggling with a CSS and Bootstrap issue, I am unable to find a solution. The problem I am facing is that the content in a div form is not responsive within its parent div. It always extends beyond the parent div and does not adjust its size when the scre ...

What is the best way for me to collect messages submitted through a form on my website?

After completing my website using HTML, CSS, and JavaScript, I added a form with inputs for name, email, and message at the bottom of the page. Now, I am trying to figure out how to receive the information submitted by visitors in my email. ...

Show a persistent header once you scroll past a certain point using Bootstrap

Utilizing Bootstrap affix property to reveal a header after scrolling down by 100px has been successful for me. However, I encountered an issue when trying to set the opacity property to 0.0001, it works as expected. But when setting it to 0 or changing di ...

Tips on aligning multiple elements vertically in a justified manner

I'm struggling to articulate what I need, but I'll give it a shot. I want to vertically align three different elements, each wrapped in their own divs. This is my current code: .service_info { margin-top: 45px; clear: both; ...

PHP: Link to logo in different folder by including 'nav.php'

I am facing an issue with my nav.php file: <div> <!-- there's a lot of code here so I want to write it once and include it in all pages within the main folder as well as subfolders <img src="logo.png"> </div> The structur ...

Preventing access to drives and desktop until the mandatory HTML form is completed

Looking to develop a webpage in JSP that will automatically open whenever my system is started. Users will be required to fill out a form on this page before proceeding further. If they attempt to bypass filling out the form, they should not have access ...

The Github page is continuously loading without displaying any content

Recently, I created a web-map application using the OpenLayers library and published it on Github Pages. You can access it through this link: . However, when I try to load the page, the content doesn't show up and it just keeps loading indefinitely. ...

How can we transfer animation duration and `@keyframe` values through a function in CSS?

In my angular project, I am currently adding animations to text. However, I want to make these animations dynamic. For instance, I have a CSS class called .slide-in-top with an animation time set to 1.3s. Instead of this static value, I want to be able to ...

Create a container and add two div elements with absolute positioning inside

Utilizing bootstrap 3, I am looking to incorporate two shadows within a container. The first shadow will be positioned at the top of the container, followed by the second shadow at the bottom using absolute positioning. CSS: .section-st1 { padding: 0 ...

What is the best way to create a transparent sticky header that blends with the background while still maintaining visibility over images and text?

On my web page, the background features a radial gradient but the content extends beyond the viewport, causing the center of the gradient to not align with the center of the screen, producing the desired effect. However, I'm facing an issue with a sti ...

I'm curious about how I can apply @media queries given that certain phones possess higher resolution than computers

There seems to be a common recommendation to utilize @media queries for adjusting CSS based on whether the user is on mobile or not. However, I'm a bit confused because my phone has a width of 1440p while my computer has 1920p. Should I consider apply ...

Set the height of CSS3 to 100% full

I'm struggling to articulate my question, so please feel free to suggest a better title or guide me in the right direction. I'm working on a website using a mix of HTML5 and CSS3, and I want it to display consistently across various browsers. H ...

Unable to retrieve the divs once they have been appended to a different HTML file

<div id="div1"> <div id="div2"> </div> <div id="div3"></div> <div id="div4"> <div id="div5"> <div id="div6"> </div> <div id="divcontent"> </div> </ ...

Determine the currently active view on a mobile device

I am trying to determine whether the user is viewing the website vertically or horizontally on their mobile device or iPad in order to adjust the image scale accordingly. For example: If the user is viewing the page horizontally, I want the image style t ...

Employ a .js file in order to prevent encountering a 404 error

I am in the process of designing a webpage that displays plots and information from .csv files. As new files are added and old ones go away, I need the webpage to adjust dynamically based on which files are available. $.get('dir/'+myvar[1]+&apos ...

Tips for customizing the focus style of a Text Field in Material-UI

My current Search box design is represented in the following image: https://i.sstatic.net/VuKIp.png I am looking for ways to customize the background color, border, and icon of the search box when it is focused. Additionally, I would like to know how to m ...