CSS3 Modal Background Not Transparent - html

I am creating a Pure CSS3 Modal.
Along the way I got two issues.
The Background is not changing to transparent black color when the modal was click.
(if you've seen modal before you know what I mean cause basically it will force the background to be transparent type color.) See Screenshots:
!The original background color is #fff or white
Look at the background its color grayish tranparent color when the the modal was active
I've been thinking how can I make this 3D Flip Horizontal Animate or create a nice and smooth rotation when coming instead of just plain moving from top to bottom.
Here's my HTML:
<p>Display Modal</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>
Close Modal
<div class="overlay"></div>
</div>
</div>
Here's my 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;
}
Here's my JS FIDDLE: http://jsfiddle.net/agx4w5pm/1/
If you could edit my JSFIDDLE code that would be a great help.
Thanks in advance for the help!

Didn't understand your first point. But added rotation effect to your modal like you asked in second point. replace 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);
-webkit-transform-origin: 50% 50%;
-webkit-perspective: 1500px;
}
#modal:target {
opacity: 1;
top:50%;
-webkit-transform: rotateX(0deg);
}
Notice -webkit-transform: rotateX(270deg); property which is giving rotation effect.

Related

el-dialog working but need css to open from bottom to top with effect

I have e;-dialog setup on button click and it is working, all i am trying to do is make sure it opens from the bottom and goes like 300px height and show comntents inside it and when i click outside or inside any element, it will hide
here is my code
css first
<style scoped>
#Status {
display:none;
}
#Status.active {
opacity:1;
display:block;
position:fixed;
bottom:0;
margin: 0 auto 0 auto;
background-color:#fff;
text-align:left;
animation-name:disappear;
animation-duration:4s;
animation-delay:3s;
transition: all linear 0.3s;
animation-fill-mode:forwards;
border-radius:8px 8px 0 0;
z-index:999;
width:100%;
height:120px;
}
</style>
element ui code
<div #click="show = !show">
<el-dialog id="Status" :visible.sync="show" v-if= "show">
<div>
hello
</div>
</el-dialog>
You can just transition the height since it's fixed to the bottom:
<style scoped>
#Status {
overflow: hidden;
height: 0;
opacity: 0;
display: block;
position: fixed;
bottom:0;
margin: 0 auto;
background-color: #fff;
text-align: left;
border-radius: 8px 8px 0 0;
z-index: 999;
width: 100%;
transition: height 250ms ease-in-out,
opacity 250ms ease-in-out;
}
#Status.active {
opacity: 1;
height: 120px;
}
</style>

transition ease-in-out; is not working

I am trying to use simple transiton, but I don't understand why it is not working. Could you help me? I put transition: ease-in-out; in container...
my code:
.container{
width:250px;
height:300px;
background:#00f;
position:relative;
transition: ease-in-out;
}
.show{
display: none;
position:absolute;
bottom:0;
height:50%;
width:100%;
color:#000;
text-indent:5px;
background:rgba(255,255,255,.5);
}
.container:hover > .show{
display:block;
}
http://jsfiddle.net/mAzsL/44/
I use this as example: http://jsfiddle.net/n7Ne9/53/
UPDATE:
My aim was to get effect which is called 'fade in a box' - I wasn't precise, sorry.
Update:
On new requirements, the transition effect needs to be different, please refer the below snippet.
.container {
width: 250px;
height: 300px;
background: #00f;
position: relative;
}
.show {
position: absolute;
opacity:0;
height:30%;
bottom:0px;
left:0px;
right:0px;
color: #000;
text-indent: 5px;
background: rgba(255, 255, 255, .5);
transition: opacity 0.5s ease-in-out;
}
.container:hover>.show {
opacity:1;
}
<div class="container">
<div class="show">Lorem </div>
</div>
Old Answer:
The problem is transition property cannot be applied to the CSS property display:none, the workaround for this is to set the height to 0px initially, a problem you will face is that the text will still be visible on the screen. For this overflowing text to be hidden, use the CSS class overflow:hidden which will hide the content which is outside the element. Also instead of using transition on the parent element, use it directly on the element itself. Refer the below class.
.show{
position:absolute;
overflow:hidden;
bottom:0;
height:0px;
width:100%;
color:#000;
text-indent:5px;
background:rgba(255,255,255,.5);
transition: height 1s ease-in-out;
}
The transition property should be as follows.
transition: height 1s ease-in-out;
First mention which property should have the transition effect. Then duration of the transition, then whether ease-in or some other setting.
Then on hover, set the original height. The transition will be seen.
.container:hover > .show{
height:50%;
}
.container {
width: 250px;
height: 300px;
background: #00f;
position: relative;
}
.show {
position: absolute;
overflow: hidden;
bottom: 0;
height: 0px;
width: 100%;
color: #000;
text-indent: 5px;
background: rgba(255, 255, 255, .5);
transition: height 1s ease-in-out;
}
.container:hover>.show {
height: 50%;
}
<div class="container">
<div class="show">Lorem </div>
</div>

image button with overlay

Almost at the bottom of the page you see 4 images with a button inside of each image. (Verona, Mono Silk, Fibre Silk and Akvarell).
I'm trying to achieve an image, with a centered (both veritically and horizontally) text inside of it. And it all needs to be responsive.
The most important thing that I need to fix with these buttons though is that when you hover over a button, I want the image to become darker (just like it is now) but I want it to stay that way even when you hold the mouse over the text inside. I don't understand which approach I need to have to achieve that.
The html code for a button is:
.product-container {
position:relative;
background-color: #000000;
}
.product-btn {
position: absolute;
top:39%;
left: 0;
right: 0;
margin: 0 auto;
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
}
.product-img {
width:100%;
height: auto;
opacity: 1;
transition:
opacity 0.1s ease-in-out;
-moz-transition: opacity 0.1s ease-in-out;
-webkit-transition: opacity 0.1s ease-in-out;
}
.product-img:hover {opacity: 0.5;}
<div class="product-container">
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"/>
<a href="http://google.se">
<p class="product-btn">Mono Silk</p>
</a>
</div>
How can I achieve this?
To have the image darker when hover both image and text, I changed this CSS rule
.product-img:hover {opacity: 0.5;}
to this
.product-container:hover img {opacity: 0.5;}
You also had an extra closing </div> tag which I removed.
Having block level (p) element inside an inline (a) is invalid, so I changed your p to a span and added text-align: center; to its CSS rule so the text inside is centered.
Having block level element, like p, inside an inline element is in general invalid, though according to the new HTML5 specs, an a now can have block level elements inside (Thanks to #tjameswhite pointing that out), as long as there is no interactive content within (e.g. buttons or other links).
Sample snippet
.product-container {
position:relative;
background-color: #000000;
}
.product-btn {
position: absolute;
top:39%;
left: 0;
right: 0;
margin: 0 auto;
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
text-align: center;
}
.product-img {
width:100%;
height: auto;
opacity: 1;
transition:
opacity 0.1s ease-in-out;
-moz-transition: opacity 0.1s ease-in-out;
-webkit-transition: opacity 0.1s ease-in-out;
}
.product-container:hover img {opacity: 0.5;}
<div class="product-container">
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg">
<a href="http://google.se">
<span class="product-btn">Mono Silk</span>
</a>
</div>
Change the Markup so that image comes after the link.
Then css will get the link to be in center of parent:
.product-container {
position:relative;
background-color: #000000;
}
.product-btn {
position: absolute;
top:50%;
left: 50%;
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
transform: translate(-50%, -50%);
}
.product-img {
width:100%;
height: auto;
opacity: 1;
transition:
opacity 0.1s ease-in-out;
-moz-transition: opacity 0.1s ease-in-out;
-webkit-transition: opacity 0.1s ease-in-out;
}
.product-container > a:hover + img {opacity: 0.5;}
<div class="product-container">
<a href="http://google.se">
<p class="product-btn">Mono Silk</p>
</a>
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"></div>
</div>
In CSS (slow the style change in product-container and make hover action for it):
.product-container {position:relative; background-color: #000000;
transition: opacity 0.1s ease-in-out;
-moz-transition: opacity 0.1s ease-in-out;
-webkit-transition: opacity 0.1s ease-in-out;
}
/*.product-img:hover {opacity: 0.5;}*/
.product-container:hover img {opacity: 0.5;}
In HTML (put link inside the .product-container div):
<div class="product-container"><img class="product-img" src="./Material _ ProFormat AB_files/monosilk.jpg"/><p class="product-btn">Mono Silk</p></div>
Adjust the markup so the image and text are inside of the link:
<div class="col-sm-3 text-center">
<a href="http://google.se" class="product-container">
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg" alt="">
<div class="product-btn">Mono Silk</div>
</a>
</div>
This removes an extra container (moving the product-container class to the link). Then update styles to something like:
.product-container {
position:relative;
background-color: #000000;
display: block;
height: 426px;
width: 426px;
}
.product-img {
width: 426px;
height: 426px;
}
.product-btn {
position: absolute;
top: 39%;
left: 0;
right: 0;
margin: 0 auto;
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
text-align: center;
}
.product-container:hover .product-img {opacity: 0.5;}
.product-container:hover .product-btn {background: rgba(0,0,0,1)}
Note that the link (.product-container) has display: block; and a set width and height, as does the image. Adjust as needed.
The advantage to this is that the entire box is now one big clickable button.
A cool trick is using pseudo elements to vertically align inline blocks. This allows for multiple lines of text to also be aligned properly.
I apologise as I'm at work at the moment, so I hope this fiddle helps.
Will go into more detail in an update later if requested:
https://jsfiddle.net/pj5p0s3s/
/*Disgusting stuff for demo :) */
.product-container {
float:left;
margin-right:5px;
max-width:200px;
}
/* */
.product-container {
position:relative;
background-color: #000000;
}
.product-container a {
display:block;
}
.product-container a:after {
content:"";
background: rgba(0,0,0, 0.3);
position:absolute;
top:0;
left:0;
right:0;
bottom:0;
}
.product-container a:hover:after {
background: rgba(0,0,0,0.6);
transition: 0.3s;
}
.product-container-overlay {
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
text-align:center;
z-index:1;
}
.product-container-overlay:before {
content:"";
height:100%;
display:inline-block;
width:1px;
vertical-align:middle;
}
.product-btn {
background-color: rgba(0,0,0, 0.3);
width: 50%;
border: 1px solid #e1e1e1;
color: #ffffff;
padding: 5px 0;
display:inline-block;
vertical-align:middle;
}
.product-img {
width:100%;
height: auto;
display:block;
}
.product-img:hover {
opacity: 0.5;
}
<div class="product-container">
<a href="http://google.se">
<div class="product-container-overlay">
<p class="product-btn">Mono Silk</p>
</div>
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"/>
</a>
</div>
<div class="product-container">
<a href="http://google.se">
<div class="product-container-overlay">
<p class="product-btn">Mono Silk long title lipsum</p>
</div>
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"/>
</a>
</div>
<div class="product-container">
<a href="http://google.se">
<div class="product-container-overlay">
<p class="product-btn">Mono Silk</p>
</div>
<img class="product-img" src="http://dev2015.proformat.se/wp-content/uploads/2016/02/monosilk.jpg"/>
</a>
</div>

Image Overlay with CSS

So I'll try and be brief - we have a slider on our website and when we upload the images the text on the slider is difficult to read, so we figured out that if we added a white overlay in photoshop to the picture, the slider looks much better.
However, this is not a great solution because once the post moves to the general column, we find that the image with the overlay by photoshop is now not as appealing to the eye.
The solution that was asked ,was can we add a semi-transparent overlay to the div that holds the slider, so that way any image uploaded will have that semi transparent overlay only in the slider.
I did some research on here and other sites working with overlay and css - and have worked it into a set where I'm almost there but am missing some fundamental pieces I think.
Right now its working on hover only, so I need to figure that out, but if you see the example you'll understand
In my utopia - if I click on RUN on jsfiddle, that image should have the overlay on it already, not on hover and I think I'm missing where I'm supposed to make edits
http://jsfiddle.net/9LXcU/
.box {
border:1px solid #000;
padding:5px;
height:151px;
width:195px;
}
.overlay {
background:rgba(255, 0, 0, .75);
text-align:center;
opacity:0;
width:100%;height:100%;
-webkit-transition: all 0.3s ease-in-out;
-moz-transition: all 0.3s ease-in-out;
-o-transition: all 0.3s ease-in-out;
-ms-transition: all 0.3s ease-in-out;
transition: all 0.3s ease-in-out;
}
.box:hover {
border:1px solid #555;
border-radius:5px;
}
.box:hover .overlay {
opacity:12;
}
.search {
position:relative;
top:60px;
}
Well, here is a FIDDLE that may be what you want.
CSS
.box {
border:1px solid #000;
padding:5px;
height:151px;
width:195px;
text-align:center;
background: url('http://www.breastcanceranswers.com/wp-content/uploads/2013/10/featuredimagebcam.jpg');
background-repeat: no-repeat;
background-position: 50% 50%;
}
.overlay {
width: 100%;
height: 100%;
background-color: pink;
opacity: 0.5;
color: red;
vertical-align: middle;
}

CSS3 Menu Animation Flicker

I've created a simple hamburger menu that transforms into a plus sign when the user hovers over it but there's an annoying flicker that occurs on hover. Is it possible to increase the hover region around the entire hamburger in CSS3 so that the flicker doesn't occur?
Here's the codepen link:
http://cdpn.io/LJHpe
As you likely know the flickering is due to the elements starting and stopping being hovered. There are several ways to fix this, the path I chose to do so is to make it one element instead of two (:
<span class="menu">MENU</span>
body {
background:#EDDE45;
position:relative;
margin-left:50%;
top:50px;
}
.menu {
position:relative;
top:50px;
padding-top:3em;
font-family: arial,verdana;
font-size:18px;
color:black;
cursor:default;
}
.menu:before { /* The top two lines */
content:'';
position: absolute;
left: -1em;
top: 0;
width: 5em;
height: .5em;
border-top:0.5em solid black;
border-bottom:0.5em solid black;
transition:transform 0.25s ease-in, border-bottom .2s;
}
.menu:after { /* The third line */
content:'';
position: absolute;
left:-1em;
top:2em;
width:5em;
height:0.5em;
background:black;
transition:all 0.25s ease-in;
}
.menu:hover {
cursor:pointer;
}
.menu:hover:before {
transform:scale(0.8);
border-bottom:0.5em solid rgba(255,255,255,0);
}
.menu:hover:after {
transform:scale(0.8) rotate(90deg);
top:0em;
}
Demo
Let me know if you have any questions!