How can I do a folded-corner with external shadow which continues to the parent div shadow, like that :
Thanks.
CSS Backgrounds and Borders Module Level 4 introduces the corner-shape property:
By default, non-zero border-radii define a quarter-ellipse that rounds
the affected corners. However in some cases, other corner shapes are
desired. The corner-shape property specifies a reinterpretation
of the radii to define other corner shapes.
In your case, you should set it to bevel:
Border radii define a diagonal slice at the corner.
The code would be something like
corner-shape: bevel;
border-radius: 0 0 30px;
box-shadow: 0 0 5px #000;
However, this spec is a draft not ready for implementation. So browsers haven't implemented it. But you can use corner-shape preview to see how it would look like.
tried this one, a bit complex, but it works
.box {
width: 200px;
height: 100px;
position: relative;
padding: 25px;
background: none;
}
.box .content {
position: relative;
z-index: 2;
}
.box .the_background {
position: absolute;
left: 0;
top: 0;
z-index: 1;
width: 100%;
height: 100%;
}
.box .the_background .square-top-right {
width: 250px;
height: 125px;
position: absolute;
top: 0;
left: 0;
background: #fff;
display: block;
z-index: 3;
}
.box .the_background .square-bottom-left {
width: 225px;
height: 150px;
position: absolute;
bottom: 0;
left: 0;
background: #fff;
display: block;
z-index: 3;
}
.box .the_background:after {
content: '';
width: 35px;
height: 35px;
background: #ddd;
position: absolute;
z-index: 2;
right: 7px;
bottom: 7px;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-box-shadow: 0px 0px 10px #000;
-moz-box-shadow: 0px 0px 10px #000;
box-shadow: 0px 0px 10px #000;
}
.box .the_background .square-shadow {
position: absolute;
left: 0;
top: 0;
z-index: 1;
width: 100%;
height: 100%;
}
.box .the_background .square-shadow:before {
content: '';
position: absolute;
left: 0;
width: 250px;
height: 125px;
-webkit-shadow: 0px 0px 10px #000;
-moz-shadow: 0px 0px 10px #000;
box-shadow: 0px 0px 10px #000;
}
.box .the_background .square-shadow:after {
content: '';
position: absolute;
bottom: 0;
left: 0;
width: 225px;
height: 25px;
-webkit-shadow: 0px 0px 10px #000;
-moz-shadow: 0px 0px 10px #000;
box-shadow: 0px 0px 10px #000;
}
<div class="box">
<div class="content">
Lorem ipsum...
</div>
<div class="the_background">
<div class="square-top-right"></div>
<div class="square-bottom-left"></div>
<div class="square-shadow"></div>
</div>
</div>
Related
A client wants the grain effect on the box-shadow of this modal.
You can see the grain the box-shadow in the screenshot attached.
How can I achive this using CSS? I've looked but couldn't find anything.
Tried adding an after with a grain effect and applying the box-shadow to it
.grain {
content: "";
display: block;
position: absolute;
width: 100%;
height: 100%;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
background: transparent url(grain.jpg) 0 0;
background-size: 320px 320px;
opacity: .1!important;
z-index: 30;
background-color: #000;
pointer-events: none;
box-shadow: 10px 10px 0px 0px rgba(0,0,0,0.75);
-webkit-box-shadow: 10px 10px 0px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 10px 10px 0px 0px rgba(0,0,0,0.75);
}
You need to use a .png image with transparency; I found a bunch here.
Set position: relative on your element, and position: absolute on the ::after pseudo-element.
.grainy-shadow {
position: relative;
width: 200px;
height: 200px;
background: blue;
margin: 2rem;
}
.grainy-shadow::after {
content: '';
position: absolute;
top: 1rem;
left: 1rem;
bottom: -1rem;
right: -1rem;
z-index: -1;
background-image: url("https://www.transparenttextures.com/patterns/black-orchid.png");
}
body {
background: url(https://img.freepik.com/premium-vector/colorful-random-shapes-abstract-background-geometrical-circle-background-with-copy-space-yellow_655111-46.jpg?w=2000);
}
<div class="grainy-shadow">
<h1>content</h1>
</div>
How can I create a "pile" effect like in this picture?
I'd like the formation/spacing of the pile to stay as it is, and for the pile to shift left or right as the window is resized.
I've been fiddling around with absolute/relative positioning, but I'm a CSS newbie and I'm not sure if this is the way to go.
This is what I have so far:
.boxes {
position: absolute;
top: 100px;
}
.box1 {
position: relative;
left: 10vw;
width:fit-content;
padding: 0px 10px 4px 10px;
box-shadow: 0px 0px 0px 2px rgba(0, 0, 0);
}
.box2 {
position: relative;
width:fit-content;
left: 16vw;
bottom: 13vh;
padding: 0px 10px 4px 10px;
box-shadow: 0px 0px 0px 2px rgba(0, 0, 0);
transform: rotate(10.84deg);
}
.box3 {
position: relative;
width:fit-content;
left: 25vw;
bottom: 20vh;
padding: 0px 10px 4px 10px;
box-shadow: 0px 0px 0px 2px rgba(0, 0, 0);
transform: rotate(21deg);
}
<div class="boxes">
<div class="box1">box1</div>
<div class="box2">box2</div>
<div class="box3">box3</div>
</div>
You should set boxes to relative and it's child absolute like:
.boxes {
top: 100px;
position: relative;
}
.box1 {
position: absolute;
...
}
.box2{
position: relative;
width: 70px;
left: 19vw;
bottom: 7vh;
width: 70px;
transform: rotate(16deg);
padding: 0px 10px 4px 10px;
box-shadow: 0px 0px 0px 2px rgb(0 0 0);
}
.box3 {
left: 27vw;
width: 40px;
bottom: 32vh;
position: relative;
padding: 0px 10px 4px 10px;
transform: rotate(-4deg);
box-shadow: 0px 0px 0px 2px rgb(0 0 0);
}
//etc..
Try to play with rotate transform - MDN
I have created a #wrapper with a width and a height. Then I gave the wrapper position: relative; because we will position the single elements with position: absolute;.
Here is the code I used:
* {
margin: 0;
padding: 0;
}
#wrapper {
position: relative;
height: 150px;
width: 450px;
border: 1px solid;
}
#blue {
width: 100px;
height: 30px;
background: blue;
position: absolute;
bottom: 0;
left: 70px;
}
#purple {
width: 100px;
height: 30px;
background: purple;
position: absolute;
bottom: 20px;
left: 145px;
transform: rotate(25deg);
}
#green {
width: 50px;
height: 30px;
background: green;
position: absolute;
bottom: 63px;
left: 177px;
transform: rotate(-10deg);
}
#red {
width: 100px;
height: 30px;
background: red;
position: absolute;
bottom: 21px;
left: 220px;
transform: rotate(28deg);
}
<div id="wrapper">
<div id="blue"></div>
<div id="purple"></div>
<div id="green"></div>
<div id="red"></div>
</div>
Since iOS 14, contents in a div with an 'overflow-y: scroll' property don't seem to work on Safari, does anyone have a solution? (maybe it's just my code that doesn't work, too.)
I don't know why it does it now, i don't have debug tools on my phone (sadness...) But it was working under iOS 13.6.
I put an example underneath.
<html lang="fr">
<style>
html{
background-color: var(--background);
z-index: -9999;
}
body{
position: relative;
width: 100%;
top: 0;
left: 0;
right: 0;
margin: 0;
z-index: -9999;
}
.head{
position: relative;
display: block;
top: 0;
left: 0;
right: 0;
height: 10vh;
background-color: blue;
border-radius: 8px;
}
.emb-content{
margin-top: 2vh;
margin-bottom: 2vh;
width: 96%;
display: block;
margin-left: 2%;
margin-right: 2%;
border-radius: 10px;
height: 74.5vh;
overflow-y: scroll;
border: none;
z-index: 9999;
-webkit-appearance: none;
-webkit-box-shadow: 0px 2px 10px -1px rgba(0,0,0,0.45);
-moz-box-shadow: 0px 2px 10px -1px rgba(0,0,0,0.45);
box-shadow: 0px 2px 10px -1px rgba(0,0,0,0.45);
}
.footer{
display: block;
position: relative;
height: 10vh;
bottom: 0;
left: 0;
right: 0;
background-color: yellow;
}
</style>
<body>
<div class='head'></div>
<div class='emb-content'>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>add
</div>
<div class='footer'></div>
</body>
</html>
remove z-index: -9999;, z-index < 0 is not supported in ios 14
I've looked at some other threads, but nothing seems to work. I'm trying to center a lightbox of an unknown width in the center of the page (horizontally). Any help would be appreciated. The code is as follows.
HTML
<div class="backdrop"></div>
<div class="box">
<div class="close">x</div>
<img src="../pics/placeholder.png">
</div>
CSS
.backdrop {
position: absolute;
text-align: center;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
background: #000;
opacity: .0;
filter:alpha(opacity=0);
z-index: 50;
display: none;
}
.box {
position: absolute;
top: 20%;
width: auto;
height: auto;
background: #ffffff;
z-index: 51;
padding: 2px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0px 0px 5px #444444;
-webkit-box-shadow: 0px 0px 5px #444444;
box-shadow: 0px 0px 5px #444444;
display: none;
}
.close {
position: absolute;
padding-left: 5px;
padding-top: 5px;
margin-left: 98%
margin-top: 4px;
cursor: pointer;
font-family: sans-serif;
}
• To center an element horizontally with position: relative use:
.element {
position: relative;
display: inline-block;
margin: 0 auto; /* We don't care about 0, but we do care about auto. */
}
• To center an element horizontally with position: absolute or position: fixed use:
.element {
position: fixed; /* Lightboxes usually use position: fixed. */
left: 50%;
transform: translateX(-50%);
}
I've been trying to get this container box into my webpage with html and css.
but I can't seem to get it working properly, could anyone help me out with it?
I dont have any code at the moment, since I've only been copy and pasting tutorials and trying to figure out how it works, but I cant seem to get it right.
Use pseudo elements
Update with shadow
:root{background: #c7c7c7; padding: 80px;}
div{
background: white;
width: 280px;
height: 480px;
position: relative;
margin: 0px auto
}
div:before, div:after{
content: "";
position: absolute;
background: #f2f2f2
}
div:before{
left: 100%;
width: 40px;
height: 100%;
top: 0;
top: 20px;
transform: skew(0deg,45deg);
box-shadow: 2px 1px 1px 0px #9D9C9C, 0 2px 2px #f2f2f2;
}
div:after{
top: 100%;
width: 100%;
height: 40px;
left: 20px;
transform: skew(45deg,0deg);
box-shadow: -2px 2px 1px 0px #9D9C9C, 8px 0 16px #f2f2f2
}
<div><div/>
Update without shadow
:root{background: #c7c7c7; padding: 80px;}
div{
background: white;
width: 280px;
height: 480px;
position: relative;
margin: 0px auto
}
div:before, div:after{
content: "";
position: absolute;
background: #f2f2f2
}
div:before{
left: 100%;
width: 40px;
height: 100%;
top: 0;
top: 20px;
transform: skew(0deg,45deg);
}
div:after{
top: 100%;
width: 100%;
height: 40px;
left: 20px;
transform: skew(45deg,0deg);
}
<div><div/>
Old Update
:root{background-color: #c7c7c7; height: 100vh}
main{
width: calc(100vw - 100px);
height: 120vh;
margin: 20px;
background: white;
position: relative
}
main:before, main:after{
position: absolute;
content: "";
}
main:before{
height: calc(100% - 40px);
width: 50px;
background: #f2f2f2;
right: -50px;
top: 40px
}
main:after{
height: 0;
width: 0;
top: 0;
right: -50px;
border-top: 40px solid transparent;
border-bottom: 0px solid transparent;
border-left: 50px solid #f2f2f2;
}
<main></main>
Or Shadow
:root{background-color: #c7c7c7; height: 100vh}
main{
width: calc(100vw - 100px);
height: 120vh;
margin: 20px;
background: white;
position: relative;
box-shadow: 50px 0 #f2f2f2;
}
main:before{
position: absolute;
content: "";
width: 0;
height: 0;
border-right: 50px solid #c7c7c7;
border-bottom: 50px solid transparent;
right: -50px;
top: 0;
}
<main></main>