changing before pseudo element on hover - html

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?

Related

Display the full image over the card

In this card, I have given an image tag. When I run the code half of the image gets hidden. My exception is that the image should overwrite the card like this:
.
So please let me know how to achieve this.
Here is my code:
.section6-card1-diagonal {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-color: transparent;
width: 246px;
height: 406px;
border-color: lightgrey;
margin-left: 20px;
margin-top: 20px;
margin-bottom: 20px;
position: relative;
overflow: hidden;
}
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
left: -155px;
}
<div class="card section6-card1-diagonal">
<h5>Dell Inspiron Heavy metallic Display</h5>
<img class="section4-image" src="https://i5.walmartimages.com/asr/726f43a4-2dbb-4340-adc1-ce798580ba23_1.c5ced9469e3036a57d81678e9ebd2f1d.jpeg" />
<div class="cards1">
</div>
</div>
Here is a simple solution .
Just give negative z-index to the .cards1
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
left: -155px;
z-index:-1;
}
That will bring the div behind the image , Because the Image will have more priority in simple words
play width .section4-image class for better styling
.section6-card1-diagonal {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-color: transparent;
width: 246px;
height: 406px;
border-color: lightgrey;
margin-left: 20px;
margin-top: 20px;
margin-bottom: 20px;
position: relative;
overflow: hidden;
}
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
left: -155px;
}
.section4-image {
height: 55vh;
background-color: "red";
width: 52vh;
margin-left: 10%;
margin-top: 0%;
}
<div class="card section6-card1-diagonal">
<h5>Dell Inspiron Heavy metallic Display</h5>
<img class="section4-image" src="https://i5.walmartimages.com/asr/726f43a4-2dbb-4340-adc1-ce798580ba23_1.c5ced9469e3036a57d81678e9ebd2f1d.jpeg" />
<div class="cards1">
</div>
</div>
Firstly: you need to upload transparent image (PNG) image of desktop.
Secondly: you need to upload small resolution image.
Currently you uploaded high resolution image which is 1500x1500
Now you need to add below css to show you image and also make it transparent.
.section4-image {
width:100%;
}
After make transparent image you need to add z-index css on image for show up on the shape.
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
z-index: -1;
}
.section4-image {
z-index: 1;
}
`
.section6-card1-diagonal {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
border-color: transparent;
width: 246px;
height: 406px;
border-color: lightgrey;
margin-left: 20px;
margin-top: 20px;
margin-bottom: 20px;
position: relative;
overflow: hidden;
}
.cards1 {
border-bottom: 225px solid #846EB1;
border-left: 401px solid transparent;
position: absolute;
bottom: 0;
left: -155px;
}
.section4-image {
width:100%;
}
<div class="card section6-card1-diagonal">
<h5>Dell Inspiron Heavy metallic Display</h5>
<img class="section4-image" src="https://i5.walmartimages.com/asr/726f43a4-2dbb-4340-adc1-ce798580ba23_1.c5ced9469e3036a57d81678e9ebd2f1d.jpeg" />
<div class="cards1">
</div>
</div>

How to remove the bottom part of my ugly arrow mark in the pseudo `after` content

body{
background:#fff;
}
.triangle {
position: relative;
margin: 3em;
padding: 1em;
box-sizing: border-box;
background: #fff;
box-shadow: 0px 0 5px 0 rgba(0, 0, 0, 0.4);
border-radius:5px;
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 0;
right: 1%;
box-sizing: border-box;
border: 0.75em solid black;
border-color: transparent transparent ;
transform-origin: 0 0;
transform: rotate(135deg);
box-shadow: 0px 0px 5px rgba(0, 0, 0, .5);
}
<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>
Can you please replace ".triangle::after" with this code and check whether it solves you problem or not?
.triangle::after {
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 0;
right: 1%;
box-sizing: border-box;
border: 0.75em solid black;
border-color: transparent transparent;
transform-origin: 0 0;
transform: rotate(135deg);
background: #fff;
box-shadow: -2px 2px 2px 1px rgb(233, 233, 233);
}
Just add z-index: -1; to the pseudo element to move it behind the main element:
body{
background:#fff;
}
.triangle {
position: relative;
margin: 3em;
padding: 1em;
box-sizing: border-box;
background: #fff;
box-shadow: 0px 0 5px 0 rgba(0, 0, 0, 0.4);
border-radius:5px;
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 0;
right: 1%;
box-sizing: border-box;
border: 0.75em solid black;
border-color: transparent transparent ;
transform-origin: 0 0;
transform: rotate(135deg);
box-shadow: 0px 0px 5px rgba(0, 0, 0, .5);
z-index: -1;
}
<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>
It may be help and also looks good
body{
background:#fff;
}
.triangle {
position: relative;
margin: 3em;
padding: 1em;
box-sizing: border-box;
background: #fff;
box-shadow: 0px 0 5px 0 rgba(0, 0, 0, 0.4);
border-radius:5px;
}
.triangle::after{
content: "";
position: absolute;
width: 0;
height: 0;
margin-left: -0.5em;
top: 17px;
right: 1%;
box-sizing: border-box;
border: 0.75em solid;
border-color: #fff;
transform-origin: 0 0;
transform: rotate(-133deg);
box-shadow: 1px 1px 0px rgba(0, 0, 0, 0.3);
}
<div class="triangle">This is a CSS3 triangle with a proper box-shadow!</div>
Same method use here.
Z-index: -1 is safe bro

Get fixed div element in sidebar

<nav class="offcanvas-menu">
<div class="user-details"></div>
<ul class="test">
<li>content</li>
</ul>
<div class=navfooter>
footer content
</div>
</nav>
i dont know how to get the .navfooter on the bottom of the sidebar. it is allways unter the .test container. i tryed couple of things but its not getting work
these are the styles for it
<style>
.test{
left: 0;
top: 20%;
height: 400px;
width: 200px;
background: #ECF0F1;
-webkit-box-shadow: 0px 2px 7px rgba(0, 0, 0, 0.40);
box-shadow: 0px 2px 7px rgba(0, 0, 0, 0.40);
}
.navfooter {
position: relative;
bottom: 0;
z-index: 999;
height: 64px;
width: 100%;
background: #1e67cb;
box-shadow: 0 -1px 5px rgba(0,0,0,.6);
-webkit-box-shadow: 0 -1px 5px rgba(0,0,0,.6);
}
.offcanvas-menu {
position: fixed;
top: 0;
left: 0;
z-index: 1031;
/*visibility: hidden;*/
background: #fff;
border-right: 1px solid #CCC;
width: 250px;
height: 100%;
-webkit-transition: all 0.5s;
transition: all 0.5s;
}
</style>
Have you tried changing the .navfooter to absolute?
.navfooter {
position: absolute;
bottom: 0;
z-index: 999;
height: 64px;
width: 100%;
background: #1e67cb;
box-shadow: 0 -1px 5px rgba(0,0,0,.6);
-webkit-box-shadow: 0 -1px 5px rgba(0,0,0,.6);
}

CSS3: Shadow only without parent background

I have a problem with CSS3 Shadows that I did not expirience before.
It seems like a box-shadow, that is applied to a div via the :before and :after selector, is only possible, if the container of the div has no background-color set.
Is there any way to make this possible?
<div class="container">
<div class="shadow-box">
test
</div>
</div>
The .container must not have a background-color set. I created an example on http://jsfiddle.net/v1utr15n/
You need to make sure that the .container will start a new stacking order. You can do this by either setting a position: relative; z-index: 0 or a opacity other than 1, e.g. opacity: .9999.
.container {
background-color: #fff;
height: 500px;
position: relative;
z-index: 0;
}
.shadow-box {
background-color: #fff;
position: relative;
width: 300px;
height: 300px;
}
.shadow-box:before,
.shadow-box:after {
content: "";
position: absolute;
z-index: -1;
-webkit-box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
-moz-box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
top: 50%;
bottom: 0;
left: 10px;
right: 10px;
-moz-border-radius: 100px / 10px;
border-radius: 100px / 10px;
}
<div class="container">
<div class="shadow-box">
test
</div>
</div>
See http://philipwalton.com/articles/what-no-one-told-you-about-z-index/ for some background information on z-index and stacking order context.
Put the code of the box-shadow in the shadow-box class, not in before or after.
URL: http://jsfiddle.net/v1utr15n/1/
.container {
background-color: #fff;
height: 500px;
}
.shadow-box {
background-color: #fff;
position: relative;
width: 300px;
height: 300px;
-webkit-box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
-moz-box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
box-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}
.shadow-box:before,
.shadow-box:after {
content: "";
position: absolute;
z-index: -1;
top: 50%;
bottom: 0;
left: 10px;
right: 10px;
-moz-border-radius: 100px / 10px;
border-radius: 100px / 10px;
}
<div class="container">
<div class="shadow-box">
Shadow box
</div>
</div>

Css Shape Creation Curved Wave

This is what i have got so far
After after checking out tutorial
I want know how curved effect is generated on divs the only question that i found near to what i was looking for was At here at stackoverlow but that too dint help
How folded edge effect is created on as in the above picture
Css
#MenuShape{
height:50px;
background-color:orange;
width:200px;
position:relative;
text-align:center;
left:100px;
}
#MenuShape:after{
content:"";
position: absolute;
width: 0;
height: 0;
left:200px;
border-top: 50px solid transparent;
border-left: 100px solid orange;
border-bottom: 0px solid transparent;
}
#MenuShape:before{
content:"";
position: absolute;
width: 0;
height: -50;
left:-100px;
border-top: 50px solid transparent;
border-right: 100px solid orange;
border-bottom: 0px solid transparent;
}
HTML
<div id="MenuShape" >
sachin
</div>
https://css-tricks.com/ this the site on inspecting it i found its span wrapped
anchor tag along with svg tag
<a href="/" class="home">
<svg viewBox="0 0 100 25" class="shape-tab">
<use xlink:href="#shape-tab"></use>
</svg>
<span>Blog</span></a>
Click here to see the unexpected behaviour it works fine in codepen
Here is a final demo (archived) on the folded corners:
and the following code is how you can create them:
.note {
position: relative;
width: 30%;
padding: 1em 1.5em;
margin: 2em auto;
color: #fff;
background: #97C02F;
overflow: hidden;
}
.note:before {
content: "";
position: absolute;
top: 0;
right: 0;
border-width: 0 16px 16px 0;
border-style: solid;
border-color: #fff #fff #658E15 #658E15;
background: #658E15;
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), -1px 1px 1px rgba(0, 0, 0, 0.2);
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), -1px 1px 1px rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3), -1px 1px 1px rgba(0, 0, 0, 0.2);
/* Firefox 3.0 damage limitation */
display: block;
width: 0;
}
.note.rounded {
-moz-border-radius: 5px 0 5px 5px;
border-radius: 5px 0 5px 5px;
}
.note.rounded:before {
border-width: 8px;
border-color: #fff #fff transparent transparent;
-moz-border-radius: 0 0 0 5px;
border-radius: 0 0 0 5px;
}
<div class="note"></div>
To create a curved wave effect you can use this code:
#wave {
position: relative;
height: 70px;
width: 600px;
background: #e0efe3;
}
#wave:before {
content: "";
display: block;
position: absolute;
border-radius: 100% 50%;
width: 340px;
height: 80px;
background-color: white;
right: -5px;
top: 40px;
}
#wave:after {
content: "";
display: block;
position: absolute;
border-radius: 100% 50%;
width: 300px;
height: 70px;
background-color: #e0efe3;
left: 0;
top: 27px;
}
<div id="wave"></div>
To achieve the curve you’ll need to inverse where it starts. Follow the same demo, just reverse your values.
See a live demonstration (archived) of how border radius can create the shapes and effects you want and adjust each corner to see it in action.