I'm trying to recreate this print card that has a inverse border radius and a couple borders. I got the borders working on a rectangle using box shadow, and I am fudging the inverted corners with 100% border radius divs. I applied the shadow to the rounded corners though and it looks super off.
Is there any way to use circle svgs to clip the corners then use filter: drop-shadow? not sure that's possible. any better ideas?
html:
#greetings
.top.left
.top.right
.bottom.left
.bottom.right
css:
#greetings{
box-shadow: -6px 6px 0 #8E9090, 6px -6px 0 #8E9090, -6px -6px 0 #8E9090, 6px 6px 0 #8E9090, -9px 9px 0 #f88125, 9px -9px 0 #f88125,9px 9px 0 #f88125, -9px -9px 0 #f88125, -12px 12px 0 #8E9090, 12px -12px 0 #8E9090, 12px 12px 0 #8E9090, -12px -12px 0 #8E9090;;
div {
position: absolute;
width: 40px;
height: 40px;
border-radius: 100%;
background-color: #f88125;
}
.top { top: -20px; }
.bottom { bottom: -20px; }
.left { left: -20px; }
.right { right: -20px; }
.top.right {
box-shadow: -6px 6px 0 #8E9090, -9px 9px 0 #f88125, -12px 12px 0 #8E9090;
}
Target:
Html corners:
Wonky shadow:
I couldn't pull this off with your box-shadow approach.
I achieved something similar with borders and relative positioning. Didn't have time to polish the code, and if you look closely it is not symmetrical. It is not finished, but I thought I'd collaborate with an alternative.
I'm sure you can play around with the circles div widths to make the card look more similar to the original.
html
<div class="label">
<div class="inner-border-two"></div>
<div class="inner-border"></div>
<div class="corner-0 corner"></div>
<div class="corner-0 inner corner"></div>
<div class="border border-top"></div>
<div class="corner-1 corner"></div>
<div class="corner-1 inner corner"></div>
<div class="border border-right"></div>
<div class="corner-2 corner"></div>
<div class="corner-2 inner corner"></div>
<div class="border border-bottom"></div>
<div class="corner-3 corner"></div>
<div class="corner-3 inner corner"></div>
<div class="border border-left"></div>
</div>
css
.label{
position: relative;
display: inline-block;
width: 660px;
height: 458px;
border: 30px solid #F88125;
padding: 0;
}
.label .inner-border-two{
height: 104%;
width: 103%;
border: 2px solid #8E9090;
position: absolute;
top: -8px;
left: -8px;
}
.label .inner-border{
height: 100%;
width: 100%;
border: 6px solid #8E9090;
position: absolute;
}
.label .corner {
width: 38px;
height: 38px;
position: absolute;
background-color: #F88125; //Orange
}
.label .corner-0{
left: 0;
top: 0;
border-bottom-right-radius: 100%;
border-bottom: 6px solid #8E9090;
border-right: 6px solid #8E9090;
}
.label .corner-0.inner{
left: -8px;
top: -8px;
border-bottom: 3px solid #8E9090;
border-right: 3px solid #8E9090;
}
.label .corner-1{
right: 0;
top: 0;
border-bottom-left-radius: 100%;
border-bottom: 6px solid #8E9090;
border-left: 6px solid #8E9090;
}
.label .corner-1.inner{
right: -10px;
top: -8px;
border-bottom: 3px solid #8E9090;
border-left: 3px solid #8E9090;
}
.label .corner-2{
right: 0;
bottom: 0;
border-top-left-radius: 100%;
border-top: 6px solid #8E9090;
border-left: 6px solid #8E9090;
}
.label .corner-2.inner{
right: -10px;
bottom: -8px;
border-top: 3px solid #8E9090;
border-left: 3px solid #8E9090;
}
.label .corner-3{
left: 0;
bottom: 0;
border-top-right-radius: 100%;
border-top: 6px solid #8E9090;
border-right: 6px solid #8E9090;
}
.label .corner-3.inner{
left: -8px;
bottom: -8px;
border-top: 3px solid #8E9090;
border-right: 3px solid #8E9090;
}
Related
Could someone help me make an effect like the one in the example below?
I'm trying to put unsuccessful in the responsiveness part ...
The closest I can get was as follows the code below and the image:
.content .card-l {
margin-top: 1vh;
position: relative;
border-top: 2px solid #00ffde;
border-bottom: 2px solid #c9ff04;
border-left: 2px solid #5bff69;
border-right: 2px solid #2a43c1;
}
.content .card-l::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-top: 3px solid #ba6c0e;
border-bottom: 3px solid #d3cc0b;
border-left: 3px solid #990be6;
border-right: 3px solid #9a1b3b;
}
.content .card-l::after {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-top: 3px solid #070400;
border-bottom: 3px solid #ff8f3a;
border-left: 3px solid #1b9fbd;
border-right: 3px solid #d87777;
}
.content .card-l .card-content {
position: relative;
background: #e0bf95;
padding: 30px;
border-top: 2px solid #82f577;
border-bottom: 2px solid #1c1f31;
border-left: 2px solid #d6d254;
border-right: 2px solid #f380de;
}
.content .card-l .card-content::before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border-top: 3px solid #18fd03;
border-bottom: 3px solid #34eca3;
border-left: 3px solid #5528e9;
border-right: 3px solid #df2cec;
}
.content .card-l .card-content::after {
content: "";
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
border: 3px solid #806c53;
}
You can consider multiple background and clip-path like below:
.box {
--c1:#806c53; /* first color */
--c2:#5d4e39; /* second color */
--b:20px; /* border width */
margin:10px;
width:200px;
height:100px;
font-size:25px;
outline:3px solid #321f1a; /* outer border */
border:var(--b) solid transparent;
padding:3px; /* control the inner border */
background:
linear-gradient(#e0bf94 0 0) content-box, /* main background */
linear-gradient(#321f19 0 0) padding-box; /* inner border */
position:relative;
}
/* main border */
.box:before,
.box:after {
content:"";
position:absolute;
z-index:-1;
top:calc(-1*var(--b));
right:calc(-1*var(--b));
bottom:calc(-1*var(--b));
left:calc(-1*var(--b));
background:
linear-gradient(var(--s1,var(--c1)) 0 0) center/calc(100% - var(--b)) calc(100% - var(--b)) no-repeat,
linear-gradient(var(--s2,var(--c2)) 0 0);
}
.box:after {
--s1:var(--c2);
--s2:var(--c1);
clip-path:
polygon(0 0,0 100%,var(--b) calc(100% - var(--b)),
var(--b) var(--b),calc(100% - var(--b)) var(--b),100% 0);
}
<div class="box"> some text here </div>
<div class="box" style="--b:30px;--c1:red;--c2:darkred;width:300px;"> some text here </div>
<div class="box" style="--b:10px;--c1:blue;--c2:darkblue;width:300px;"> some text here </div>
Here is an example using only one div, with no additional containers or spans, taking advantage of box shadow and the :after pseudo element.
.card-1 {
position: relative;
padding: 4rem;
background: #e0bf94;
box-shadow: 0 0 0 2px #321f19; /* outer border */
border: 4px solid;
border-color: #5d4e39 #5d4e39 #806c53 #806c53; /* second border */
z-index: 1;
}
.card-1:after {
content: '';
position: absolute;
left: 0;
right:0;
top: 0;
bottom: 0;
border: 4px solid;
border-color: #806c53 #806c53 #5d4e39 #5d4e39; /* third border */
box-shadow: inset 0 0 0 2px #321f19; /* inner and last border */
z-index: -1;
}
<div class="card-1">Lorem ipsum</div>
And you can also achieve something pretty similar with nothing but box-shadow.
.card-1 {
position: relative;
padding: 4rem;
background: #e0bf94;
border: 4px solid;
border-color: #5d4e39 #5d4e39 #806c53 #806c53;
box-shadow: 0 0 0 2px #321f19,
inset -4px 4px 0 0 #806c53,
inset 4px -4px 0 0 #5d4e39,
inset 0 0 0 6px #321f19;
}
<div class="card-1">Lorem ipsum</div>
here you can find an example
.content {
border: 2px solid #321f19;
}
.card-l {
border-top: 4px solid #5d4e39;
border-right: 4px solid #806c53;
border-bottom: 4px solid #806c53;
border-left: 4px solid #5d4e39;
}
.card-content {
border-top: 4px solid #806c53;
border-right: 4px solid #5d4e39;
border-bottom: 4px solid #5d4e39;
border-left: 4px solid #806c53;
position: relative;
background-color: #e0bf94;
}
.card-content::before {
content: "";
width: calc(100% - 4px); /*remove one border size from the 100%*/
height: calc(100% - 4px); /*remove one border size from the 100%*/
position: absolute;
border: 2px solid #321f19;
}
span {
display: block;
padding: 30px;
text-align: center;
z-index: 1;
}
.btn {
margin: 10px auto;
display: block;
position: relative;
padding: 10px;
}
<div class="content">
<div class="card-l">
<div class="card-content">
<button id="button" class="btn">hello!!!</button>
</div>
</div>
</div>
You can always put multiple divs to contain different borders.
OR
Use border image in css. It'll be an easier approach if you can find the image. More reference here.
Is it possible to add an even shadow to a div that is not a regular rectangle? Adding box-shadow doesn't work the way it works with a normal div. This is the div I'm talking about:
#talkbubble {
width: 120px;
height: 80px;
background: red;
position: relative;
-moz-border-radius: 10px;
-webkit-border-radius: 10px;
border-radius: 10px;
}
#talkbubble:before {
content:"";
position: absolute;
right: 100%;
top: 26px;
width: 0;
height: 0;
border-top: 13px solid transparent;
border-right: 26px solid red;
border-bottom: 13px solid transparent;
}
yes you can. Here is the example:
.circle {
width:150px;
height:150px;
border: solid 1px #555;
background-color: #eed;
box-shadow: 10px -10px rgba(0,0,0,0.6);
-moz-box-shadow: 10px -10px rgba(0,0,0,0.6);
-webkit-box-shadow: 10px -10px rgba(0,0,0,0.6);
-o-box-shadow: 10px -10px rgba(0,0,0,0.6);
border-radius:100px;
}
<div class="circle">
</div>
i want to give box shadow on the hexagon
here is my jsfiddle
jsfiddle
and this is my hexagon css property
.hex1 {
background-color: rgba(52,152,219,.5);
text-align: center;
line-height: 70px;
height: 80px;
width: 140px;
margin: 60px 10px;
position: relative;
z-index: 1;
box-shadow:2px 2px 2px 2px grey;
}
.hex1:before {
border-top: 40px solid transparent;
border-bottom: 40px solid rgba(52,152,219,.5);
top: -80px;
}
.hex1:after, .hex1:before {
border-left: 70px solid transparent;
border-right: 70px solid transparent;
content: "";
position: absolute;
left: 0;
z-index: -1;
}
.hex1:after {
bottom: -80px;
border-top: 40px solid rgba(52,152,219,.5);
border-bottom: 40px solid transparent;
}
this is not affecting on my hexagon .. is there any way to five border and box shadow to hexagon.
please help
You Can Use these code....
#hexagon{
background: red;
width: 100px; height: 60px;
position: relative;
-moz-box-shadow: 0 0 10px rgba(0,0,0,0.7);
-webkit-box-shadow: 0 0 10px rgba(0,0,0,0.7);
box-shadow: 0 0 10px rgba(0,0,0,0.7);
}
http://jsfiddle.net/jelmerdemaat/5UMxW/3/
I've tried to set a black solid 1px border for triangle: jsFiddle. I write the follwoing markup:
<div>
</div>
and styles
div{
position: absolute;
left:0px;
top:0px;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 10px solid red;
}
But I don't understand how to set the border for the triangle in this case.
You can try this too , basically i have made a larger triangle black in colour and put it behind the red one
<div id="border">
</div>
<div id="red">
</div>
#red{
position: absolute;
left:4px;
top:9px;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 10px solid red;
background-color:transparent;
z-index: 99;
}
#border {
position: absolute;
left:0x;
top:0px;
width: 5px;
height: 10px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 12px solid black;
z-index: 0;
}
here is your solution its work
`div:before {
border-bottom: 12px solid #000000;
border-left: 6px solid rgba(0, 0, 0, 0);
border-right: 6px solid rgba(0, 0, 0, 0);
content: "";
height: 0;
left: -1px;
position: absolute;
top: -1px;
width: 0;
}
div:after {
border-bottom: 10px solid #FF0000;
border-left: 5px solid rgba(0, 0, 0, 0);
border-right: 5px solid rgba(0, 0, 0, 0);
content: "";
height: 0;
left: 0;
position: absolute;
top: 0;
width: 0;
z-index: 111111;
}`
So, my button, for some reason, won't go to the URL that is defined when the user clicks directly on the text lying on top of the button. (ie: for my button, "Test Text")
When you click on the button, it always depresses, but it only goes to the linked URL when you click outside of the text's area.
I have tried using a <div> instead of <a>, but no luck with that either.
You can see the button live at http://198.154.213.30/~foster2/index.php/news
Below is the code for my button:
<a class="button3D" href="http://www.google.com" target="_blank">Test Text</a>
<style>
.button3D {
position: relative;
display: block;
width: 200px;
height: 50px;
top: 50%;
left: 50%;
margin-top: -25px;
margin-left: -100px;
background: #650404;
font-family: sans-serif;
text-align: center;
line-height: 50px;
font-size: 24px;
color: #fff;
text-shadow: 0 -1px rgba(0, 0, 0, 0.5);
border: 1px solid #4e0202;
-webkit-box-shadow: 0 5px 15px -5px #222;
-moz-box-shadow: 0 5px 15px -5px #222;
box-shadow: 0 5px 15px -5px #222;
-webkit-user-select: none;
-moz-user-select: none;
user-select: none;
cursor: pointer;
}
.button3D:before {
content: "";
position: absolute;
top: -9px;
left: 0px;
width: 178px;
height: 0px;
border: 11px solid transparent;
border-bottom: 8px solid #650404;
border-top: 0;
}
.button3D:after {
content: "";
color: #c56338;
line-height: 180px;
font-size: 16px;
position: absolute;
top: -8px;
left: 1px;
width: 178px;
height: 0px;
border: 10px solid transparent;
border-bottom: 7px solid #891414;
border-top: 0;
}
.button3D:active {
width: 158px;
height: 41px;
top: 50%;
left: 50%;
margin-top: -33px;
margin-left: -79px;
line-height: 36px;
font-size: 22px;
color: #eee;
text-shadow: 0 -1px rgba(0, 0, 0, 0.5);
border: 1px solid #3c0101;
background: #4e0202;
border-top: 0;
-webkit-box-shadow: 0 0 0 0;
-moz-box-shadow: 0 0 0 0;
box-shadow: 0 0 0 0;
}
.button3D:active:before {
top: 0;
height: 42px;
width: 158px;
left: -12px;
padding: 0 1px;
border: 11px solid #b3b294;
border-bottom: 8px solid #deddad;
border-top: 0;
}
.button3D:active:after {
content: "";
top: 0;
height: 50px;
width: 182px;
left: -13px;
border: 0;
-webkit-box-shadow: 0 15px 25px -15px rgba(0,0,0,0.5) inset;
-moz-box-shadow: 0 15px 25px -15px rgba(0,0,0,0.5) inset;
box-shadow: 0 15px 25px -15px rgba(0,0,0,0.5) inset;
}
</style>
Appreciate any input/insight you can provide for me as to how I can fix this problem.
I think it is because the link is moving. When you click and hold a link you can drag off the link and it will not navigate. It appears that the moving link is triggering this functionality. The only thing I can think that you could do is use JavaScript onmousedown to navigate.