As you can see below, I have two items with similar effect.
In the first case i use an overlay element in order to achieve the effect as you see it.
What I want is to have the same effect but with shadow not the overlay trick.
What I can't achieve is to make the shadow start 20px from top but have zero oveflow from the bottom as you see it in the first item.
Is it possible with css shadow to achieve the same thing or I have to go with the first option?
.container {
padding: 20px;
}
.item, .desired-item {
max-width: 300px;
height: 300px;
position: relative;
}
.desired-item {
padding-top: 25px;
}
figure {
width: 100%;
padding: 0;
margin: 0;
}
figure img {
width: 100%
}
.item .overlay {
position: absolute;
background-color: #ff6666;
width: 100%;
height: calc(100% - 20px);
visibility: visible;
opacity: 1;
z-index: -1;
right: -20px;
transition: all .25s;
margin-top: 20px;
}
.item figure:hover .overlay {
visibility: visible;
opacity: 0.3;
z-index: 1;
right: 0;
height: calc(100% - 0px);
margin-top: 0;
}
.desired-item figure:hover {
-webkit-box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 0px 0px rgba(0,0,0,0.75);
}
.desired-item figure {
-webkit-box-shadow: 20px 20px 0px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 20px 20px 0px 0px rgba(0,0,0,0.75);
box-shadow: 20px 20px 0px 0px rgba(0,0,0,0.75);
transition: all .5s;
}
<div class="container">
<h2>overlay effect:</h2>
<div class="item">
<figure>
<div class="overlay"></div>
<img src="https://via.placeholder.com/600x600.jpg/09f/fff">
</figure>
</div>
<h2>Shadow effect:</h2>
<div class="desired-item">
<figure>
<div class="overlay"></div>
<img src="https://via.placeholder.com/600x600.jpg/09f/fff">
</figure>
</div>
</div>
Apply the shadow on the image and rely on overflow to hide the non needed part:
figure img {
display:block;
box-shadow: 20px 20px 0px 0px rgba(0, 0, 0, 0.75);
transition: all .5s;
}
figure:hover img {
box-shadow: 0px 0px 0px 0px rgba(0, 0, 0, 0.75);
}
figure {
display:inline-block;
padding-right:20px;
overflow: hidden;
}
<figure>
<img src="https://via.placeholder.com/150x150.jpg/09f/fff">
</figure>
Related
Hi everyone thank you for taking the time. I am trying to add the nav-bar that is out of place inside of a container. This is the HTML
<div class="container-login100" style="background-image: url('images/packages.jpg');">
<div class="wrap-login100 p-l-55 p-r-55 p-t-80 p-b-30">
<div class="nav-container">
<nav class="nav-bar-outer">
<buttton type="button" class="hamburger-btn"> HERE </buttton>
</nav>
</div>
<form class="login100-form validate-form">
<!--css form content-->
And this is the CSS.
[ Nav-Bar ]*/
.nav-container{
position: absolute;
width: auto;
}
.nav-bar-outer{
background-color: #ffbf00;
padding:5px;
height:50px;
width:390px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
background-position: center;
background-size: cover;
position: relative;
}
.wrap-login100 {
border-bottom-right-radius: 10px;
border-bottom-right-radius: 10px;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
width: 390px;
background: rgba(0, 0, 0, 1);
overflow: hidden;
box-shadow: 0 3px 20px 0px rgba(0, 0, 0, 0.1);
-moz-box-shadow: 0 3px 20px 0px rgba(0, 0, 0, 0.1);
-webkit-box-shadow: 0 3px 20px 0px rgba(0, 0, 0, 0.1);
-o-box-shadow: 0 3px 20px 0px rgba(0, 0, 0, 0.1);
-ms-box-shadow: 0 3px 20px 0px rgba(0, 0, 0, 0.1);
}
.login100-form {
width: 100%;
}
.p-l-55 {padding-left: 55px;}
.p-b-30 {padding-bottom: 30px;}
.p-r-55 {padding-right: 55px;}
.p-t-80 {padding-top: 80px;}
.p-b-37 {padding-bottom: 37px;}
So I think because there is padding in the black container the bar is not positioning itself like I would like to how could it fit inside the container without me having to change the padding (since the content inside would get messed up)
Please add this new CSS to your CSS file.
.wrap-login100 {
position: relative;
}
.nav-container {
position: absolute;
width: auto;
left: 55px;
right: 55px;
}
.nav-bar-outer {
width: 100%;
padding: 0;
}
I am building a portfolio website and I want a mockup on top of a background but when I hover over the mockup I cannot interact with the background. I want them to both scale, but the mockup should scale more than the background, therefore I need a :hover on both of them separately.
I tried fiddling around with the z-index but it did not work out. Here is what it looks like now: https://imgur.com/NPrHdAI
Here is my HTML and CSS:
.try {
display: flex;
justify-content: center;
flex-wrap: wrap;
margin: 80px 0px 60px 10px;
}
.bg {
height: 250px;
margin: 10px;
border-radius: 3px;
-webkit-box-shadow: 0px 5px 10px 0px rgba(214, 214, 214, 0.3);
-moz-box-shadow: 0px 5px 10px 0px rgba(214, 214, 214, 0.3);
box-shadow: 0px 5px 10px 0px rgba(214, 214, 214, 0.3);
transition: all .3s ease-in-out;
}
.mockup {
position: absolute;
height: 300px;
transition: all .3s ease-in-out;
}
.mockup:hover {
transform: scale(1.2);
}
<div class="try">
<div>
<img class="mockup" src="img/mockup.png">
<img class="bg" src="img/bg.jpg">
</div>
<div>
<img class="mockup" src="img/mockup.png">
<img class="bg" src="img/bg.jpg">
</div>
<div>
<img class="mockup" src="img/mockup.png">
<img class="bg" src="img/bg.jpg">
</div>
</div>
I want both elements to be scaling separately, but the mockup blocks the background from scaling on hover.
You could use a wrapper div that triggers the hover, and assign different effects to mockup and bg like this:
.wrapper:hover .mockup {
transform: scale(1.2);
}
.wrapper:hover .bg {
transform: scale(5.0);
}
Full snippet: (You can see they both resize different)
.try {
display: flex;
justify-content: center;
flex-wrap: wrap;
margin: 80px 0px 60px 10px;
}
.bg {
height: 250px;
margin: 10px;
border-radius: 3px;
-webkit-box-shadow: 0px 5px 10px 0px rgba(214,214,214,0.3);
-moz-box-shadow: 0px 5px 10px 0px rgba(214,214,214,0.3);
box-shadow: 0px 5px 10px 0px rgba(214,214,214,0.3);
transition: all .3s ease-in-out;
}
.mockup {
position: absolute;
height: 300px;
transition: all .3s ease-in-out;
}
.wrapper:hover .mockup {
transform: scale(1.2);
}
.wrapper:hover .bg {
transform: scale(5.0);
}
<div class="wrapper">
<img class="mockup" src="img/mockup.png">
<img class="bg" src="img/bg.jpg">
</div>
So i managed to create a inset shadow on an image, after reading around the web..
it works, but i cannot make it change on :hover.
Currently i have:
.shadow {
position: relative;
max-width: 100%;
float: left;
}
.shadow::before {
border-radius: 100%;
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
box-shadow: inset 3px 3px 8px rgba(0, 0, 0, .6);
transition: box-shadow .2s ease-in-out;
}
.shadow:hover:before {
box-shadow: inset 5px 5px 55px rbga(0, 0, 0, .8);
}
.shadow img {
float: left;
border-radius: 100%;
width: 300px;
}
<div class="shadow">
<img src="https://picsum.photos/300/300?image=1015">
</div>
I have put the code here: https://codepen.io/anon/pen/rRwGmV
I hope some of you know how to do this.
Thanks
.shadow {
position: relative;
max-width: 100%;
float: left;
}
.shadow::before {
border-radius: 100%;
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
box-shadow: inset 3px 3px 8px red;
transition: box-shadow .2s ease-in-out;
}
.shadow:hover::before {
box-shadow: inset 5px 5px 55px green;
}
.shadow img {
float: left;
border-radius: 100%;
width: 300px;
}
<div class="shadow">
<img src="https://picsum.photos/300/300?image=1015">
</div>
what do you think about do it without :before?
.shadow img{
border-radius: 50%;
box-shadow: 3px 3px 8px rgba(0,0,0,.6);
}
img:hover {
box-shadow: 5px 5px 5px red;
}
<div class="shadow">
<img src="https://picsum.photos/300/300?image=1015">
</div>
Here is my codepen whith this code
Did I forget to do something? How can I improve?
I'm trying to have a skewed element change size on hover but for whatever reason, the elements only change whenever the mouse is about 200px below where it should be. I'm guessing this is either happening because of the way I transformed the elements or because of the way I positioned them on the page.
Code below
.layers {
margin: 150px 150px;
height: 500px !important;
width: 500px !important;
-webkit-perspective: 1000px; /* Chrome, Safari, Opera */
perspective: 1000px;
}
.layer img {
height: 500px;
width: 500px;
-webkit-box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
background: rgba(255, 255, 255, 0.65);
-webkit-transform: rotateX(75deg); /* Chrome, Safari, Opera */
transform: rotateX(75deg);
display: inline;
transition: all .5s;
-webkit-transition: all .5s;
}
.layer:hover img {
-webkit-box-shadow: 0px 0px 65px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 65px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 65px 0px rgba(0,0,0,0.75);
height: 510px;
width: 510px;
transition: all .5s;
-webkit-transition: all .5s;
}
.layer1 {
display: inline-block;
position: relative;
z-index: 3;
}
.layer2 {
display: inline-block;
position: relative;
z-index: 2;
bottom: 450px;
}
.layer3 {
display: inline-block;
z-index: 1;
position: relative;
bottom: 900px;
}
<div class="layers">
<div class="layer1 layer">
<img src="http://placehold.it/500x500" alt="">
</div><!-- layer1 -->
<div class="layer2 layer">
<img src="http://placehold.it/500x500" alt="">
</div><!-- layer2 -->
<div class="layer3 layer">
<img src="http://placehold.it/500x500" alt="">
</div><!-- layer3 -->
</div><!-- layers -->
Try putting the transform: rotateX(75deg); on .layer instead of its child image, like so:
.layers {
margin: 150px 150px;
height: 500px !important;
width: 500px !important;
-webkit-perspective: 1000px; /* Chrome, Safari, Opera */
perspective: 1000px;
}
.layer {
-webkit-transform: rotateX(75deg); /* Chrome, Safari, Opera */
transform: rotateX(75deg);
}
.layer img {
height: 500px;
width: 500px;
-webkit-box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
background: rgba(255, 255, 255, 0.65);
display: inline;
transition: all .5s;
-webkit-transition: all .5s;
}
.layer:hover img {
-webkit-box-shadow: 0px 0px 65px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 65px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 65px 0px rgba(0,0,0,0.75);
height: 510px;
width: 510px;
transition: all .5s;
-webkit-transition: all .5s;
}
.layer1 {
display: inline-block;
position: relative;
z-index: 3;
}
.layer2 {
display: inline-block;
position: relative;
z-index: 2;
bottom: 450px;
}
.layer3 {
display: inline-block;
z-index: 1;
position: relative;
bottom: 900px;
}
<div class="layers">
<div class="layer1 layer">
<img src="http://placehold.it/500x500" alt="">
</div><!-- layer1 -->
<div class="layer2 layer">
<img src="http://placehold.it/500x500" alt="">
</div><!-- layer2 -->
<div class="layer3 layer">
<img src="http://placehold.it/500x500" alt="">
</div><!-- layer3 -->
</div><!-- layers -->
Try replacing perspective: 1000px with transform: perspective(1000px)
.layers {
margin: 150px 150px;
height: 500px !important;
width: 500px !important;
//-webkit-perspective: 1000px; /* Chrome, Safari, Opera */
transform: perspective(1000px);
}
.layer img {
height: 500px;
width: 500px;
-webkit-box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 25px 0px rgba(0,0,0,0.75);
background: rgba(255, 255, 255, 0.65);
-webkit-transform: rotateX(75deg); /* Chrome, Safari, Opera */
transform: rotateX(75deg);
display: inline;
transition: all .5s;
-webkit-transition: all .5s;
}
.layer:hover img {
-webkit-box-shadow: 0px 0px 65px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 65px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 65px 0px rgba(0,0,0,0.75);
height: 510px;
width: 510px;
transition: all .5s;
-webkit-transition: all .5s;
}
.layer1 {
display: inline-block;
position: relative;
z-index: 3;
}
.layer2 {
display: inline-block;
position: relative;
z-index: 2;
bottom: 450px;
}
.layer3 {
display: inline-block;
z-index: 1;
position: relative;
bottom: 900px;
}
<div class="layers">
<div class="layer1 layer">
<img src="http://placehold.it/500x500" alt="">
</div><!-- layer1 -->
<div class="layer2 layer">
<img src="http://placehold.it/500x500" alt="">
</div><!-- layer2 -->
<div class="layer3 layer">
<img src="http://placehold.it/500x500" alt="">
</div><!-- layer3 -->
</div><!-- layers -->
Explanation from CSS-Tricks:
[...] the perspective property doesn't affect how the element is
rendered; it simply enables a 3D-space for children elements. This is
the main difference between the transform: perspective() function and
the perspective property. The first gives element depth while the
later creates a 3D-space shared by all its transformed children.
For some strange reason Safari only allows me to scroll downward with the two finger gesture inside an iFrame. However, if I use the scroll bar I can scroll up and down. WTF?!
This is the html and css for the iframe and its wrapper.
#iframe-wrapper {
-webkit-overflow-scrolling: touch !important;
overflow-y: scroll !important;
height: 312px;
}
#iframe-wrapper>iframe {
border-radius: 4px;
background-color: white;
border: none;
-webkit-box-shadow: inset 0px 0px 15px -5px rgba(0, 0, 0, 0.75);
-moz-box-shadow: inset 0px 0px 15px -5px rgba(0, 0, 0, 0.75);
box-shadow: inset 0px 0px 15px -5px rgba(0, 0, 0, 0.75);
}
.fixed-window {
position: fixed;
height: 100%;
width: 100%;
overflow-y: auto;
overflow-x: hidden;
left: 0;
right: 0;
}
.popup {
margin: -100px auto 100px;
position: absolute;
border: 0px solid white;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
box-shadow: 0px 0px 18px rgba(0, 0, 0, 0.4);
max-width: 720px;
width: 100%;
top: 50%;
left: 50%;
transform: translateX(-50%);
-ms-transform: translateX(-50%);
-webkit-transform: translateX(-50%);
}
#container {
padding: 0 40px;
}
<div class="fixed-window">
<div class="popup">
<div id="container">
<div class="on-submit-hide">
<div id="iframe-wrapper">
<iframe height="100%" width="100%" src="http://www.lipsum.com/feed/html">
</iframe>
</div>
</div>
</div>
</div>
</div>
Why is this happening, is it a Safari bug?? Does anyone else have this problem? In the rest of the browsers it works fine, including ie9 :weary:.