Circle with fading borders on the bottom - html

I'm trying to draw this output with css (or svg). For me, the tough part is the half-arc at the left and right side of the circle. Should I stick to pure css or is it better using images?
Any help is appreciated...
This is what I managed to make :
Here is the code :
body {
background-color: #002911 !important;
}
h3 {
color: #ffd004;
}
#actions-container {
margin-top: 30px;
}
#actions-container .action-icon {
width: 200px;
height: 200px;
background-color: rgb(255, 208, 4);
border-radius: 50%;
box-shadow: 5px -2px 6px 3px #0000004a;
/* center contents*/
display: flex;
justify-content: center;
align-items: center;
}
.right-arc {
position: relative;
display: inline-block;
font-size: 30px;
color: lightgreen;
margin: 40px;
}
.right-arc::after {
content: '';
position: absolute;
right: -150px;
top: 57px;
height: 300px;
width: 300px;
border-radius: 50% 50% 50% 50%;
border-width: 0px 1px 0px 0px;
border-style: solid;
/*border-top: outset;*/
}
/*svg {
width: 33%;
height: auto;
}*/
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet" />
<div class="container" id="actions-container">
<div class="d-flex justify-content-between">
<div class="action-icon-box text-center ">
<div class="right-arc">
</div>
<h3 class="text-center">Title</h3>
<div class="p-1 action-icon text-center mt-4">
<img class="center" src="/Content/images/lp-homepage/microphone.png" height="100" />
</div>
</div>
</div>
</div>

You could use a pseudo element with an inset box-shadow to create the fade out border on the bottom like this :
body {
background: #232323;
}
.wrap {
box-sizing: border-box;
position: relative;
width: 50%;
border: 3px solid #ffd004;
border-radius: 50%;
}
.wrap::before {
content:'';
display:block;
padding-bottom:100%;
}
.wrap::after {
content: '';
position: absolute;
bottom: -3px;
left: -3px;
right: -3px;
height: 100%;
z-index: 1;
box-shadow: inset 0px -270px 70px -100px #232323;
}
.title {
color: #ffd004;
margin: 0;
position: absolute;
top: -3px;
left: 0;
width: 100%;
text-align: center;
z-index: 2;
background: #232323;
}
.circle {
position: absolute;
top:15%;
left:15%;
width: 70%;
height: 70%;
border-radius: 50%;
background: #ffd004;
z-index: 2;
}
<div class="wrap">
<h2 class="title">Title</h2>
<div class="circle"></div>
</div>
Be aware that this will only work on plain color background. If you need to display this over a gradient or image, I highly suggest using SVG.
The aspect ratio of the circle is kept using the "padding technique" from this answer : Maintain the aspect ratio of a div with CSS

If you need transparency, you can use a mask-image with a linear-gradient.
/* based on #web-tiki's implementation */
body {
background: #232323;
}
.wrap {
box-sizing: border-box;
position: relative;
width: 50%;
padding: 60px;
}
/* the border */
.wrap::before {
content:"";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border: 3px solid #ffd004;
border-radius: 50%;
-webkit-mask-image: linear-gradient(transparent 10%, black 10%, transparent 80% );
mask-image: linear-gradient(transparent 10%, black 10%, transparent 80% );
}
/* the circle */
.wrap::after {
content:"";
display:block;
background: #ffd004;
padding-top: 100%;
border-radius: 50%;
box-shadow: 6px 0px 10px black;
}
.title {
color: #ffd004;
margin: 0;
position: absolute;
top: -3px;
left: 0;
right: 0;
text-align: center;
}
body:hover {
/* CSS checkerboard stolen from https://drafts.csswg.org/css-images-4/#example-2de97f53 */
background: repeating-conic-gradient(rgba(0,0,0,0.1) 0deg 25%, white 0deg 50%);
background-size: 2em 2em;
}
<div class="wrap">
<h2 class="title">Title</h2>
</div>

Try this
body {
background-color: #002911 !important;
}
h3 {
color: #ffd004;
}
#actions-container {
margin-top: 30px;
}
#actions-container .action-icon {
width: 200px;
height: 200px;
background-color: rgb(255, 208, 4);
border-radius: 50%;
box-shadow: 5px -2px 6px 3px #0000004a;
/* center contents*/
display: flex;
justify-content: center;
align-items: center;
}
.action-icon-box{
position: relative;
}
#actions-container .action-icon-box::after,#actions-container .action-icon-box::before{
position: absolute;
content: '';
width: 300px;
height:300px;
border-radius: 50%;
z-index:-1;
top:0px;
border: 2px solid;
border-color:transparent;
}
#actions-container .action-icon-box::before{
border-right-color: green;
right: -60px;
}
#actions-container .action-icon-box::after{
border-left-color: green;
left: -60px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container" id="actions-container">
<div class="d-flex justify-content-between">
<div class="action-icon-box text-center ">
<h3 class="text-center">Title</h3>
<div class="p-1 action-icon text-center mt-4">
<img class="center" src="/Content/images/lp-homepage/microphone.png" height="100" />
</div>
</div>
</div>
</div>

Related

CSS - Rectangle div with cut corners and border color

I'm trying to achieve the shape as shown in this image:
To have 2 rectangle divs with cut corners , and 1 div positioned behind another div.
But the corners seems incorrect and I can't find the way to show the borders of the shapes.
.wrapper {
display: flex;
justify-content: center;
}
.connect {
width: 254px;
height: 50px;
background: red;
background: #FF2D5069;
border-top: 2px solid #FF2175;
position: absolute;
bottom: 0;
z-index: 5;
}
.connect::before {
content: '';
position: absolute;
bottom: 0;
right: -2px;
border-top: 52px solid white;
border-left: 42px solid transparent;
}
.connect::after {
content: '';
position: absolute;
bottom: 0;
left: -2px;
border-top: 52px solid white;
border-right: 42px solid transparent;
}
.connect-behind {
width: 300px;
height: 44px;
background: red;
background: #FF2D5069;
border-top: 2px solid #FF2175;
position: absolute;
bottom: 0;
}
.connect-behind::before {
content: '';
position: absolute;
bottom: 0;
right: -2px;
border-top: 46px solid white;
border-left: 26px solid transparent;
}
.connect-behind::after {
content: '';
position: absolute;
bottom: 0;
left: -2px;
border-top: 46px solid white;
border-right: 26px solid transparent;
}
<div class="wrapper">
<div class="connect"></div>
<div class="connect-behind"></div>
</div>
I took reference from other threads to use behind and after for the solution but it doesn't seem working correct for my problem. Please help, thanks.
You could use perspective and transform:
possible example (for infos : with grid instead absolute) :
.wrapper {
display: grid;
justify-content: center;
align-items: end;
height: 300px;
perspective: 50px;
}
.connect,
.connect-behind {
transform: rotatex(50deg);
background: red;
margin: 0 auto;
background: #FF2D5069;
border-top: 2px solid #FF2175;
grid-row: 1;
grid-column: 1;
transform-origin: bottom center;
}
.connect-behind {
width: 300px;
height: 44px;
}
.connect {
width: 254px;
height: 50px;
;
}
<div class="wrapper">
<div class="connect"></div>
<div class="connect-behind"></div>
</div>
to draw a border around the shape, drop-shadow could be usefull
.wrapper {
display: grid;
justify-content: center;
align-items: end;
height: 300px;
perspective: 50px;
filter:
drop-shadow( 1px 0px 0 )
drop-shadow(-1px 0px 0 )
drop-shadow( 0px 1px 0 )
drop-shadow( 0px -1px 0 );
}
.connect,
.connect-behind {
transform: rotatex(50deg);
background: red;
margin: 0 auto;
background:white;
grid-row: 1;
grid-column: 1;
transform-origin: bottom center;
background:#ffa500;
}
.connect-behind {
width: 254px;
height: 50px;
border-left:solid 2px;
border-right:solid 2px;
}
.connect {
background:#ed1c24;
width: 300px;
height: 44px;
;
}
<div class="wrapper">
<div class="connect"></div>
<div class="connect-behind"></div>
</div>
You can use clip-path for things like this. Works well in a ( I think ) most browsers. Some, like ie11 and older browsers won't render it correctly, though, so you may need a fallback for those cases.
body {
overflow: hidden;
}
.wrapper {
display: flex;
justify-content: center;
}
.connect {
width: 254px;
height: 80px;
background: red;
background: #FF2D5069;
border-top: 2px solid black;
position: absolute;
bottom: 0;
z-index: 5;
clip-path: polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
}
.connect-border-left {
height: 80px;
width: 2px;
background: black;
left: calc(50% - 131px);
position: absolute;
bottom: -12px;
transform: rotate(34deg) translateX(-50%);
display: inline-block;
}
.connect-border-right {
height: 80px;
width: 2px;
background: black;
right: calc(50% - 131px);
position: absolute;
bottom: -12px;
transform: rotate(-34deg) translateX(-50%);
display: inline-block;
}
.connect-behind {
width: 300px;
height: 60px;
background: red;
background: #FF2D5069;
border-top: 2px solid black;
position: absolute;
bottom: 0;
clip-path: polygon(14% 0%, 86% 0%, 100% 100%, 0% 100%);
}
.connect-behind-border-right {
height: 100px;
width: 2px;
background: black;
right: calc(50% - 103px);
position: absolute;
bottom: -11px;
transform: rotate(-32deg) translateX(-50%);
display: inline-block;
}
.connect-behind-border-left {
height: 100px;
width: 2px;
background: black;
left: calc(50% - 103px);
position: absolute;
bottom: -11px;
transform: rotate(32deg) translateX(-50%);
display: inline-block;
}
<div class="wrapper">
<div class="connect"></div>
<div class="connect-border-left"></div>
<div class="connect-border-right"></div>
<div class="connect-behind"></div>
<div class="connect-behind-border-left"></div>
<div class="connect-behind-border-right"></div>
</div>
an idea with skew transformation, clip-path and multiple background:
.box {
--b:3px; /* border width */
--t:20px; /* top part width */
--s:30px; /* side part width */
margin:10px;
display:inline-block;
width:250px;
height:150px;
position:relative;
}
.box::before,
.box::after {
content:"";
position:absolute;
top:0;
bottom:0;
left:0;
width:50%;
border-style:solid;
border-width:var(--b) 0 0 var(--b);
background:
linear-gradient(black 0 0) 0 var(--t)/100% var(--b),
linear-gradient(black 0 0) var(--s) 0/var(--b) 100%,
linear-gradient(red 0 0) left/var(--s) 100%,
orange;
background-repeat:no-repeat;
transform-origin:bottom right;
transform:skew(-20deg);
clip-path:polygon(0 calc(var(--t) + var(--b)), calc(var(--s) + var(--b)) calc(var(--t) + var(--b)),calc(var(--s) + var(--b)) 0,60% 0,100% 100%,0 100%);
}
.box::after {
transform:scale(-1,1) skew(-20deg);
}
<div class="box"></div>
<div class="box" style="--b:2px;--t:30px;--s:15px;"></div>

Does anyone know how to draw these types of arrows with CSS?

I'm trying to make some arrows like the following
arrows
I am using Sass and Bootstrap4 and I want to make them by drawing them with css3
I've tried this, but I don't know how to achieve it:
.line1 p{
background-color: red;
width: 80px;
height: 80px;
text-align: center;
align-items: center;
border-radius: 50%;
color: #fff;
font-size: 2rem;
}
.line1 p::before{
content:'';
display: block;
color: blue;
width: 300px;
height: 10px;
position: absolute;
border: 5px solid red;
margin: 30px 10px 0;
z-index: -1;
border-radius: 0 50px 50px 0;
background-color: red;
}
.line1 p::after{
content:'';
display: block;
color: blue;
width: 10px;
height: 200px;
position: absolute;
border: 5px solid red;
margin-left: 20px;
z-index: -1;
background-color: red;
}
<div class="col-md-3 align-items-center mr-0">
<div class="line1 my-auto">
<p class="d-block my-auto">1</p>
</div>
</div>
I come from the future and you managed to do it like this:
.line-container{
border-bottom: 5px solid red;
border-right: 5px dashed red;
}
.line-container::before{
content:"";
// display:block;
position: absolute;
height: 20px;
width:20px;
border-radius:50%;
background: red;
bottom:-7px;
left:0;
}
.line-container::after{
content:"2";
position:absolute;
width:55px;
height:55px;
border-radius:50%;
background: red;
bottom:-25px;
right:-7px;
font-size:2rem;
font-weight:700;
color:#fff;
text-align:center;
}
.line-container p::before{
content:"➤";
position:absolute;
font-size:32px;
color:red;
right:2.6px;
top:-30px;
transform: rotate(270deg);
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-8 mt-5">
<div class="line-container px-md-5 pt-5">
<p class="mt-5" >Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dicta minus </p>
</div>
</div>
You only need to use the 'lines' of the rectangles of the containers, they already exist so you only need to put color
I was able to find the initial css for a triangle here. Basically you want to make two borders of a div transparent and give them a certain width so it appears to pinch the div into a triangle. I also added the ball which was pretty straightforward aside from positioning.
You may want to make further adjustments to fit your needs but this should get you started :)
.line1 p{
background-color: red;
width: 80px;
height: 80px;
text-align: center;
align-items: center;
border-radius: 50%;
color: #fff;
font-size: 2rem;
}
.line1 p::before{
content:'';
display: block;
color: blue;
width: 300px;
height: 10px;
position: absolute;
border: 5px solid red;
margin: 30px 10px 0;
z-index: -1;
border-radius: 0 50px 50px 0;
background-color: red;
}
.line1 p::after{
content:'';
display: block;
color: blue;
width: 10px;
height: 200px;
position: absolute;
border: 5px solid red;
margin-left: 20px;
z-index: -1;
background-color: red;
}
.arrow1{
position: absolute;
transform: rotate(180deg);
left: 3px;
top: 225px;
width: 0;
height: 0;
border-right: 28px solid transparent;
border-bottom: 60px solid red;
border-left: 28px solid transparent;
}
.ball1{
position: absolute;
left: 300px;
top: 15px;
background-color: red;
border-radius: 50%;
height: 50px;
width: 50px;
}
<div class="col-md-3 align-items-center mr-0" style="position: relative;">
<div class="line1 my-auto">
<p class="d-block my-auto">1</p>
<div class='arrow1'></div>
<div class='ball1'></div>
</div>
</div>
Well, I'll give you a quick PoC you could easily expand on so its use could be defined for the instance with pre-made templates but if you want all other directions and stuff you'll have to do the extra creative work and fill in the blanks on your own but this might help get you started. Cheers!
.magic-arrows {
position: relative;
display: flex;
align-items: center;
justify-content: center;
height: var(--arrow-circle-height);
width: var(--arrow-circle-width);
background-color: var(--arrow-color);
border-radius: 50%;
overflow: visible;
}
.magic-arrows:before, .magic-arrows:after {
content: '';
display: block;
position: absolute;
color: var(--arrow-color);
border: var(--arrow-color) var(--arrow-dash-size) dashed;
overflow: visible;
z-index: -1;
}
.magic-arrows:before {
height: 0;
width: calc( var(--arrow-circle-width) + var(--arrow-width) );
left: var(--arrow-circle-width);
top: 50%;
transform: translateY(-50%);
}
.magic-arrows:after {
width: 0;
height: calc( var(--arrow-circle-width) + var(--arrow-width) );
top: var(--arrow-circle-width);
left: 50%;
transform: translateX(-50%);
}
.magic-arrows .arrow-right, .magic-arrows .dot-down {
position: absolute;
font-size: var(--arrow-size);
color: var(--arrow-color);
}
.magic-arrows .arrow-right {
top: 50%;
left: calc(var(--arrow-circle-width) + var(--arrow-width) + var(--arrow-size) + 1rem);
transform: translateY(-55%);
}
.magic-arrows .dot-down {
position: absolute;
left: 50%;
top: calc(var(--arrow-circle-width) + var(--arrow-width) + var(--arrow-size) + 1rem);
transform: translateX(-55%) rotate(90deg);
}
<div class="magic-arrows"
style="--arrow-color: red;
--arrow-circle-height: 3rem;
--arrow-circle-width: 3rem;
--arrow-width: 10rem;
--arrow-dash-size: 5px;
--arrow-size: 2rem;">
<span>3</span>
<div class="arrow-right">➤</div>
<div class="dot-down">◉</div>
</div>

Draw triangle in corner of div

I'd like to draw some kind of triangle in the corner of a div. Because I don't want to use "px" I'd like to achieve the same result also with percentage values.
This is what it should looks like:
.container {
position: absolute;
top: 5%;
left: 5%;
width: 60%;
height: 30%;
background: black;
color: white;
border-radius: 12px;
overflow: hidden;
}
.triangle {
position: relative;
top: 10%;
left: 90%;
width: 10%;
height: 10%;
-webkit-transform: rotate(45deg);
background: green;
}
<div class="container">
<div class="triangle"></div>
</div>
Any help would be very appreciated. Thanks in advance!!
You can use position: absolute on triangle element and set top and right properties to 0.
.container {
position: absolute;
top: 5%;
left: 5%;
width: 60%;
height: 30%;
background: black;
color: white;
border-radius: 12px;
overflow: hidden;
}
.triangle {
width: 0;
height: 0;
border-style: solid;
border-width: 0 30px 30px 0;
border-color: transparent #608A32 transparent transparent;
right: 0;
top: 0;
position: absolute;
}
<div class="container">
<div class="triangle"></div>
</div>
You can also just use pseudo-element with absolute position for triangle.
.container {
position: relative;
width: 300px;
height: 70px;
background: black;
border-radius: 12px;
overflow: hidden;
}
.container:after {
content: '';
width: 0;
height: 0;
border-style: solid;
border-width: 0 30px 30px 0;
border-color: transparent #608A32 transparent transparent;
right: 0;
top: 0;
position: absolute;
}
<div class="container"></div>
Below is another example with triangles in all corners.
.all_triangles_container {
position: relative;
width: 300px;
height: 70px;
background: black;
overflow: hidden;
}
.triangle {
width: 0;
height: 0;
border-style: solid;
position: absolute;
}
.triangle_tl {
border-width: 0 0 30px 30px;
border-color: transparent transparent transparent green;
left: 0;
top: 0;
}
.triangle_tr {
border-width: 0 30px 30px 0;
border-color: transparent red transparent transparent;
right: 0;
top: 0;
}
.triangle_br {
border-width: 30px 30px 0 0;
border-color: transparent yellow transparent transparent;
right: 0;
bottom: 0;
}
.triangle_bl {
border-width: 0 30px 30px 0px;
border-color: transparent transparent purple transparent;
left: 0;
bottom: 0;
}
<div class="all_triangles_container">
<div class="triangle triangle_tl"></div>
<div class="triangle triangle_tr"></div>
<div class="triangle triangle_br"></div>
<div class="triangle triangle_bl"></div>
</div>
You can simply rely on background and create the triangle with a linear-gradient without extra markup and pseudo-element:
.container {
width: 400px;
height: 100px;
background: linear-gradient(-135deg,#608A32 35px,#000 0);
color: white;
border-radius: 12px;
overflow: hidden;
}
<div class="container"></div>
Related: https://stackoverflow.com/a/49696143/8620333
The trick is make a square with position:absolute first and then use top and right position negative values(equal to the half of width of the element) to adjust it and then rotate it using transform
Stack Snippet
.container {
position: absolute;
top: 5%;
left: 5%;
width: 60%;
height: 30%;
background: black;
color: white;
border-radius: 12px;
overflow: hidden;
}
.triangle {
position: absolute;
top: -25px;
right: -25px;
width: 50px;
height: 50px;
transform: rotate(45deg);
background: green;
}
<div class="container">
<div class="triangle"></div>
</div>
Another way to use gradients backgrounds
Stack Snippet
.container {
position: absolute;
top: 5%;
left: 5%;
width: 60%;
height: 30%;
background-image: linear-gradient(45deg, black 92%, green 92%);
color: white;
border-radius: 12px;
}
<div class="container"></div>
Of course you can also have striped background similar to textbox resizers
.button {
position: relative;
width: 150px;
height: 35px;
background: black;
border-radius: 8px;
overflow: hidden;
}
.blue { background: #09f; }
.red { background: #f00; }
.orange { background: #f90; }
.green { background: #0c0; }
.button:after {
content: '';
width: 45px;
height: 14px;
background: repeating-linear-gradient(
0deg,
rgba(255,255,255,.7),
rgba(255,255,255,.7) 2px,
transparent 2px,
transparent 4px
);
border-style: 0px solid;
right: -15px;
bottom: -4px;
position: absolute;
transform: rotate(-45deg);
}
<div class="button"></div>
<div class="button blue"></div>
<div class="button red"></div>
<div class="button orange"></div>
<div class="button green"></div>
If overflow: hidden on the container is not an option you can use the pseudo element's bottom border:
.container:after {
content: '';
position: absolute;
width: 0;
height: 0;
margin: -16px;
border: 10px solid transparent;
border-bottom-color: red;
transform: rotate(-45deg);
}
Adjust margin and border values for your case.

Is it possible to add image as box shadow with css?

Is it possible to add image as box shadow, for example to put image with dots instead of standard shadow?
https://i.stack.imgur.com/DOJGh.png
or somehow to replace shadow from picture with dots?
to get effect like this on picture down here
http://prntscr.com/fvjnht
Did you want something like this? It's not exactly box-shadow, but it imitates it.
You can set whatever image you like as a background for .image::after.
html, body {
margin: 0;
}
body {
width: 100vw;
height: 100vh;
}
.contain {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.image{
position: relative;
width: 200px;
height: 200px;
background-image: url(http://via.placeholder.com/200x200);
}
.image::after {
content: '';
background: linear-gradient(to bottom, #333, red);
position: absolute;
width: 100%;
height: 100%;
bottom: -10px;
right: -10px;
z-index: -1;
}
<div class="contain">
<div class="image"></div>
</div>
I think this is exactly what you are looking for:
body {
background: black;
}
#logo {
width: 200px;
height: 200px;
display: block;
position: relative;
}
#logo::after {
content: "";
background: url("https://rfclipart.com/image/big/3f-a9-1a/red-dotted-halftone-background-Download-Royalty-free-Vector-File-EPS-183199.jpg");
opacity: 0.4;
top: 0;
left: 0;
bottom: 0;
right: 0;
position: absolute;
border-radius: 50%;
z-index: -1;
}
img {
width: 90%;
height: 90%;
padding: 5%;
display: block;
float: left;
border-radius: 50%;
box-shadow: 0px 0px 40px #ccc;
-moz-box-shadow: 0px 0px 40px #ccc;
-webkit-box-shadow: 0px 0px 40px #ccc;
}
<div id="logo">
<img src="http://icons.iconarchive.com/icons/graphicloads/colorful-long-
shadow/256/User-icon.png" alt=""/>
</div>
Kind of like this?
.image_carousel img {
margin-right: 14px;
display: block;
float: left;
box-shadow: 3px 3px 1px #ccc;
-webkit-box-shadow: 3px 3px 1px #ccc;
-moz-box-shadow: 3px 3px 1px #ccc;
}
<div class="image_carousel"><img src="//placehold.it/300/f80/fff" alt=""/></div>
Credit goes to Joseph Marikle.
Like this?
span {
border: 2px dotted red;
display: inline-block;
}
img {
padding: 0;
margin: 0;
display: block;
}
<span class="dotted-border"><img src="http://placehold.it/200"/></span>

I want to position a css triangle as a background

I want to build the following layout:
Preferable i want only use css for that. But even with an background-image i wouldn't know how to build it. I searched the web, but didn't find the help i needed.
The Layout contains a div with some text in it. The background-color is a light gray. Then i would love to add a darker triangle background as shown in the picture. This should work as a responsive layout, too.
What i tried:
# html
<div class="wrapper">
<h1>Das ist ein test</h1>
<h2>subheadline</h2>
</div>
#css
.wrapper {
padding-top: 100px;
text-align: center;
width: 100%;
background-color: #4d4d4d;
height: 400px;
color: #fff;
position: relative;
}
.wrapper:before{
height: 50%;
width:100%;
position:relative;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
transform: rotate(45deg);
content:'';
display:block;
position:absolute;
top: 0;
background-color: #3d3d3d;
}
But this does not work and i can't figure it out on my own.
Thank you for your help!
You can set 2 light gradients on top of the darker background.
They overlap each other and leave only the remaining triangle darker
div {
width: 400px;
height: 200px;
border: solid 1px green;
background: linear-gradient(to top left, lightgreen 50%, transparent 50%),
linear-gradient(to top right, lightgreen 50%, transparent 50%), green;
}
<div></div>
Try this one, but still need some work on the responsive part.
.box{
position: relative;
width: 100%;
max-width: 600px;
background: #ccc;
min-height: 300px;
}
.box:before {
width: 0;
height: 0;
content: "";
position: absolute;
z-index: 0;
top: 0;
left: 0;
border-left: 300px solid transparent;
border-right: 300px solid transparent;
border-top: 180px solid #555;
}
.box .content{
z-index: 10;
position: relative;
color: #fff;
text-align: center;
padding-top: 40px;
}
h1, h2{
margin: 0;
padding: 0;
}
h2{
margin-bottom: 80px;
}
.btn{
background: #f00;
color: #fff;
display: inline-block;
padding: 5px 10px;
text-align: center;
text-decoration: none;
min-width: 200px;
font-size: 20px;
}
<div class="box">
<div class="content">
<h1>Headline</h1>
<h2>Headline</h2>
CTA
</div><!--// end .content -->
</div><!--// end .box -->
This should get you close, and illustrates a CSS only approach:
* {
margin: 0;
padding: 0
}
body {
background: #ccc;
min-height: 500px;
}
div {
width: 0;
height: 0;
margin: 0px auto;
border: 200px solid transparent;
border-top-color: grey;
}
a {
display: block;
background: blue;
color: white;
padding: 5px 10px;
width: 200px;
margin: 0px auto;
position: relative;
top: -200px;
text-align: center;
text-decoration: none;
}
<div></div>
link