I got to make a block like that.
Is there a way how to apply box-shadow for the block without shadows overlapping?
Here is my the best result - http://codepen.io/To_wave/pen/zwwqRd
<div class="box">
<div class="triangle"></div>
</div>
body {
background: #F8F8F8;
padding: 50px;
}
.box {
height: 150px;
background: #FFF;
position: relative;
box-shadow: 0 2px 4px 0 rgba(62, 62, 62, 0.2);
}
.triangle {
width: 14px;
height: 26px;
position: absolute;
left: -13px;
bottom: -4px;
overflow: hidden;
}
.triangle:after {
content: "";
position: absolute;
width: 18px;
height: 30px;
background: #fff;
transform: skew(-26deg);
bottom: 4px;
left: 10px;
box-shadow: 0px 2px 4px 0px rgba(62, 62, 62, 0.2);
}
to_wave.
I create this bubble box using only one div and a different concept on the triangle to avoid this shadow box issue. Its not the perfect solution, but it works: https://jsfiddle.net/DiogoBernardelli/028wqpee/1/
What i made was create this m-bubble::before with width: calc(100% + 7px) (the calc is because the left:-7px positioning), and adding a bottom:-3px. That way, this element will fill the entire bottom of the bubble and you will avoid the shadows overlapping.
I used perspective, rotateX and transform-origin to create this "one side skewed" element. If you have a better solution to do it, fill free to make your own adjustments.
Hope it works for you, and sorry about my english.
Best regards from Brazil.
What about using canvas?
https://codepen.io/partypete25/pen/bWWLzN
<canvas id="myCanvas" width="600" height="400"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
// begin custom shape
context.beginPath();
context.moveTo(20,20);
context.lineTo(500,20);
context.lineTo(500,300);
context.lineTo(10,300);
context.lineTo(20,280);
// complete custom shape
context.closePath();
context.lineWidth = 5;
context.shadowBlur=10;
context.shadowColor="black";
context.fillStyle = '#fff';
context.fill();
</script>
I improved my initial idea.
It looks pretty complex, but works codepen.io
<div class="wrapper">
<div class="container">
<div class="box">
</div>
</div>
</div>
body {
background-color: #F8F8F8;
}
.wrapper {
position: relative;
padding-right: 2px;
}
.wrapper::after {
content: '';
position: absolute;
display: block;
right: 2px;
top: 0;
width: 0;
height: calc(100% - 5px);
box-shadow: 0 2px 4px 1px rgba(62, 62, 62, .2);
z-index: -1;
}
.container {
padding: 1px 0 8px 30px;
position: relative;
overflow: hidden;
}
.box {
position: relative;
background: #FFFFFF;
height: 120px;
box-shadow: 0 2px 4px 0 rgba(62, 62, 62, .2);
}
.box::after {
content: '';
display: block;
position: absolute;
background-color: #FFFFFF;
height: 26px;
width: calc(100% + 12px);
left: -6px;
bottom: -5px;
transform: skewX(-26deg);
box-shadow: -1px 3px 4px -2px rgba(62, 62, 62, .2)
}
Related
I have this test setup. When I hover over the "Block 1" it should get transformed while keeping its integrity. What I see is that background color is changing. It seems like it's all about background of that .blocks:after element.
(if I comment that, background of element won't change while hovering over).
So, what could cause a problem?
Source - https://jsfiddle.net/1k5e2090/6/
body {
background: #d3d3d3;
}
.blocks {
display: flex;
position: relative;
width: 150px;
height: 55px;
margin: 25px;
justify-content: center;
align-items: center;
color: white;
font-family: 'Helvetica', sans-serif;
font-size: 20px;
}
.blocks#block1 {
background: #4BACC6;
left: 500px;
top: 200px;
}
.blocks#block2 {
left: 500px;
top: -50px;
background: #9BBB59;
}
.blocks#block3 {
left: 200px;
top: -45px;
background: #C0504D;
}
.blocks:after {
position: absolute;
content: '';
background: #F2F2F2;
top: -7px;
left: -7px;
right: -7px;
bottom: -7px;
z-index: -1;
}
.blocks#block1:after {
box-shadow: 3.5px 5.5px 1px -1px rgba(75, 172, 198, 0.45);
}
.blocks#block2:after {
box-shadow: 3.5px 5.5px 1px -1px rgba(155, 187, 89, 0.45);
}
.blocks#block3:after {
box-shadow: 3.5px 5.5px 1px -1px rgba(192, 80, 77, 0.45);
}
.blocks#block1:hover {
transition: 1s ease;
transform: translate(-100px);
}
It's because of the :after behavior on .blocks elements. See this fiddle
.blocks:hover:after { border: 6px solid #fff; background: transparent; z-index: -2; }
.blocks {
border: 7px solid #f2f2f2;
}
i have edited your fiddle https://jsfiddle.net/1k5e2090/9/
you have used the border as a :pseudo element which is not necessary. it is actually creating the problem
In place of using before and after use simple border on blocks and gives box shadow, This is happened because you use position absolute in before and after so when a block moves before and after adopt automatically.Hope it work
Simple use border around the block and remove before and after your problem will solved
I have two divs on top of each other (adjoined) and they booth as one unit shall have one box-shadow. Now the upper div gives shadow on the lower div which I don't want. I have tried to manipulate it with a "z-index:2" to be more on top but no luck.
I would like to hide the bottom shadow of the upper div and hide the top shadow of the lower div
Also I don't want the shadow to fold into the adjoined sides. The two divs should be one unit having one shadow
In my example here I have simpified the html
<div class="upper-box" style="width:100px;height:100px;">
</div>
<div class="lower-div" style="width:100px;height:100px;">
</div>
In the jsfiddle the css is all in original and here goes all the work of change.
.upper-box {
border-top: 0 none;
margin-bottom: 2px;
margin-top: -2px;
overflow: auto;
position: relative;
padding-top: 0;
/* Expanded panel gets emphasized by a shadow */
box-shadow: 0px 6px 50px 7px rgba(255,255,255,0.75),
0px 6px 50px 7px rgba(88,88,88,0.75),
0px 6px 50px 7px rgba(88,88,88,0.75),
0px 6px 50px 7px rgba(88,88,88,0.75)
;
z-index: 3;
border-style: solid;
border-color: #000000;
border-width: 0px;
position: relative;
}
.lower-div {
border-bottom: 0px;
box-shadow: 0px 6px 50px 7px rgba(88,88,88,0.75);
z-index: 2;
border-style: solid;
border-color: #000000;
border-width: 0px;
}
I would like to hide the bottom shadow of the upper div and hide the top shadow of the lower div
Also I don't want the shadow to fold into the adjoined sides. The two divs should be one unit having one shadow
Here is my live demo
https://jsfiddle.net/y289sdeb/
You could use a pseudo element, like this
.upper-box {
position: relative;
width: 100px;
height: 100px;
background: white;
}
.lower-div {
position: relative;
width: 100px;
height: 100px;
background: white;
}
.upper-box::after,
.lower-div::after {
content: '';
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
box-shadow: 0px 6px 50px 7px rgba(88, 88, 88, 0.75);
z-index: -1;
}
<div class="upper-box">
</div>
<div class="lower-div">
</div>
Based on a comment, a wrapper can be used
.wrapper {
position: relative;
display: inline-block;
}
.upper-box {
position: relative;
width: 100px;
height: 100px;
}
.lower-div {
position: relative;
width: 100px;
height: 100px;
}
.wrapper::after {
content: '';
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
box-shadow: 0px 6px 50px 7px rgba(88, 88, 88, 0.75);
z-index: -1;
}
<div class="wrapper">
<div class="upper-box">
</div>
<div class="lower-div">
</div>
</div>
I am trying to structure a media query and for some reason the page is creating a shadow when my mouse is hovering anywhere on the page. It is only doing it on a desktop with the window scaled down to a viewport of 640 or below.
I am referring to this shadow line under the blue container:
This can be seen live at :
http://optimumwebdesigns.com/contact
I believe the cause is a container I have, contact_arrow_box . The code for it is this:
.contact_arrow_box {
position: relative;
background: #88b7d5;
width: 50%;
height: 100%;
float: right;
}
.contact_arrow_box:after, .contact_arrow_box:before {
right: 100%;
top: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.contact_arrow_box:after {
border-color: rgba(136, 183, 213, 0);
border-right-color: #88b7d5;
border-width: 30px;
margin-top: -30px;
}
.contact_arrow_box:before {
border-width: 36px;
margin-top: -36px;
}
My media query alteration for this container:
.contact_arrow_box {
width: 100%;
height: auto;
}
.contact_arrow_box:after, .contact_arrow_box:before {
top: 100%;
left: 50%;
}
.contact_arrow_box:after {
border-width: 30px;
margin-left: -30px;
}
.contact_arrow_box:before {
border-width: 36px;
margin-left: -36px;
margin-top: 0;
}
Does anyone see the cause for this?
This is the culprit
.no-touch:hover {
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 0 20px rgba(0, 0, 0, 0.3);
}
Disable or overwrite it to remove the box-shadow effect
Is it possible to make a div same as this shape, if yes could you please share the code
I would use SVG: http://codepen.io/anon/pen/JdMVXY
<svg>
<path d="M260 150, 0 150, 0 0, 300 0 Q260 75, 260 150"
stroke="transparent" fill="#bd9" />
</svg>
When you have defined the correct aspect ratio of the box, you can also scale the SVG element with a simple CSS transformation (as shown in the example)
Result
This is possible within CSS using a single element with pseudo-elements with border-radius and background-shadow to create the curve.
div {
height: 100px;
width: 300px;
position: relative;
overflow: hidden;
}
div:before {
content: '';
position: absolute;
top: -150%;
left: 50%;
width: 200%;
padding-bottom: 200%;
border-radius: 100%;
background: none;
-webkit-box-shadow: 0px -10px 5px 300px #F15723;
box-shadow: 0px -10px 5px 300px #F15723;
z-index: -1;
}
<div></div>
Try this to make 'div' element:
<div id="test">
<div class="oposite-radius"></div>
<style>
#test {
position: relative;
margin: 30px;
width: 200px;
height: 100px;
border: 1px solid #333;
}
.oposite-radius {
position: absolute;
height: 100px;
width: 20px;
border: 1px solid #333;
background-color: #fff;
left: 180px;
border-radius: 100% 0 0 0;
border-width: 1px 0 0 1px;
}
</style>
We're trying to create an HTML page that consists of masonry-style floated elements that contain a picture and title. The elements have a shadow and the page has a slight gradient background. Targets that have already been visited have a folded corner.
The folded corner causes a couple of problems:
1) How can we make the element's box-shadow end before the folded corner on the right and bottom sides? Will we have to do the shadows the pre-CSS3 way with divs containing semi-transparent gradients?
2) How to do the folded corner itself? We can't just impose an image on the right bottom corner on top of the white background, because the page's background gradient must show through.
So far, I've thought of four ways of doing this:
Method 1: The idea behind this one is to use two pseudo-elements on the .box to get the corner and then two pseudo-elements on the .box-text to get the shadows in the corners right - demo. The biggest problem with this one is that it is... well, ugly.
HTML structure:
<div class="box">
<header></header>
<div class="box-text">
<p>Text</p>
</div>
</div>
Relevant CSS:
body {
background: #ccc;
}
.box {
box-shadow: 2px 2px 13px #000;
position: relative;
background: white;
}
.box:before, .box:after, .box-text:before, .box-text:after {
position: absolute;
content: '';
}
.box:before {
bottom: -25px;
right: -25px;
width: 75px;
height: 75px;
background: #ccc;
}
.box:after {
bottom: 0;
right: 0;
width: 50px;
height: 50px;
box-shadow: -2px -2px 2px #777;
background: linear-gradient(-45deg, transparent 38%, #333 50%, #faf0f0 50%);
}
.box-text:before {
bottom: 32px;
right: -15px;
width: 15px;
height: 18px;
background: radial-gradient(top left, #333 0%, transparent 40%);
}
.box-text:after {
bottom: -15px;
right: 32px;
width: 18px;
height: 15px;
background: radial-gradient(top left, #333 0%, transparent 40%);
}
Method 2: combine shadows in a nicer manner using a skewed pseudo-element for that particular corner (I would have shadows on the pseudo-element) - demo
I think this one looks nicer and also has the advantage of working in IE9 as well (the previous one didn't, since it made use of CSS gradients).
The HTML would be exactly the same and the CSS would become:
.box {
box-shadow: 0 0 5px 1px #777;
position: relative;
background: white;
}
.box:before, .box:after, .box-text:before {
position: absolute;
z-index: 2;
content: '';
}
.box:before {
bottom: -38px;
right: -38px;
width: 71px;
height: 71px;
transform: rotate(45deg);
z-index: 1;
background: #ccc;
}
.box:after {
bottom: 0;
right: 0;
border: solid 23px #f9f0f0;
border-bottom-color: transparent;
border-right-color: transparent;
box-shadow: -1px -1px 2px #777;
z-index: 4;
}
.box-text:before {
right: 0;
bottom: 22px;
width: 47px;
box-shadow: 2px 2px 3px 1px #777;
transform: skewY(-45deg);
}
Method 3: I got an idea from the previous method - demo. I think the previous one looks slightly nicer though...
CSS that has changed:
.box:before {
bottom: -24px;
right: -7px;
width: 35px;
height: 70px;
box-shadow: inset 2px 0 3px 1px #999;
transform: rotate(45deg);
z-index: 1;
background: #ccc;
}
.box:after {
bottom: 0;
right: 0;
border: solid 23px #f9f0f0;
border-bottom-color: transparent;
border-right-color: transparent;
box-shadow: -1px -1px 2px #777;
z-index: 4;
}
.box-text:before {
bottom: -27px;
right: -10px;
width: 35px;
height: 70px;
transform: rotate(45deg);
background: #ccc;
}
Method 4: Uses just 2 pseudo-elements, both on the box - demo
.box:before, .box:after {
position: absolute;
z-index: 2;
content: '';
}
.box:before {
right: -8px;
bottom: 22px;
width: 65px;
box-shadow: 2px 2px 5px 1px #777, 0 25px 0 25px #ccc;
transform: rotate(-45deg);
}
.box:after {
bottom: 0;
right: 0;
border: solid 23px #f9f0f0;
border-bottom-color: transparent;
border-right-color: transparent;
box-shadow: -1px -1px 2px #777;
z-index: 4;
}