Hexagon image background css - css

How to use background image inside instead of background color (green)?
I want to use the image inside and on the sides leaving a white border
The problem is that when insert the image, it does not cover the entire area inside.
*, *:after, *:before {
box-sizing: border-box;
}
body {
background: rgba(128, 128, 128, 0.37);
margin: 0px;
padding: 0px;
}
.xpt {
text-align: center;
}
.xpt-hex {
position: relative;
z-index: 0;
color: #fff;
display: inline-block;
margin: 80px 5px 75px 5px;
}
.xpt-hex:before {
content: "";
position: absolute;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-ms-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);
}
.xpt-hex, .xpt-hex:after, .xpt-hex:before {
width: 229px;
height: 143px;
background: #fff;
text-align: justify;
border-radius: 15px;
}
.xpt-ihex {
position: absolute;
z-index: 1;
left: 12px;
right: 12px;
top: 6px;
bottom: 6px;
}
.xpt-ihex, .xpt-ihex:after, .xpt-ihex:before {
background: #adcf24;
border-radius: 15px;
}
.xpt-ihex:after, .xpt-ihex:before {
width: 100%;
height: 100%;
}
.xpt-ihex:before {
content: "";
position: absolute;
-webkit-transform: rotate(-60deg);
-moz-transform: rotate(-60deg);
-ms-transform: rotate(-60deg);
-o-transform: rotate(-60deg);
transform: rotate(-60deg);
}
.xpt-ihex:after {
content: "";
position: absolute;
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
-ms-transform: rotate(60deg);
-o-transform: rotate(60deg);
transform: rotate(60deg);
}
.xpt-box-inr {
z-index: 2;
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: 0;
}
.xpt-hex:after {
content: "";
position: absolute;
-webkit-transform: rotate(60deg);
-moz-transform: rotate(60deg);
-ms-transform: rotate(60deg);
-o-transform: rotate(60deg);
transform: rotate(60deg);
}
<div class="xpt">
<div class="xpt-hex">
<div class="xpt-ihex">
<div class="xpt-box-inr"></div>
</div>
</div>
</div>
svg works
body{background: grey;}
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="135px" height="100%" viewBox="87.5 87.5 65 73" xml:space="preserve" preserveAspectRatio="xMidYMid">
<defs>
<pattern id="ashex-img" height="100%" width="150px" patternContentUnits="objectBoundingBox" preserveAspectRatio="xMidYMid slice">
<image height="1" width="1" preserveAspectRatio="xMidYMid slice" xlink:href="http://screenwriter.kinoscenariy.net/wp-content/uploads/2013/07/boy-102832_1920-150x150.jpg"></image>
</pattern>
</defs>
<path fill="url(#ashex-img)" stroke="white" stroke-width="2" d="M146.38,105.483l-23.467-13.498c-0.785-0.452-1.819-0.7-2.912-0.7c-1.094,0-2.128,0.249-2.911,0.7 L93.62,105.483c-1.605,0.922-2.911,3.173-2.911,5.018v26.99c0,1.847,1.306,4.1,2.91,5.024l23.472,13.5 c0.784,0.45,1.817,0.699,2.909,0.699c1.091,0,2.125-0.249,2.913-0.699l23.468-13.5c1.605-0.927,2.912-3.18,2.912-5.024v-26.99 C149.293,108.658,147.985,106.406,146.38,105.483z"></path>
</svg>

TRY THIS FIDDLE
Fiddle example for hexagon with background image
using pseudo elements

Related

svg animate polyline heartrate

I am aiming an svg-animation for the heartrate-polyline like here https://codepen.io/chriscoyier/pen/bGyoz
But it seems I am doing sth wrong. Do you know whats wrong in this code?
And if you know some technic to make the animation like real heartrate: Always start showing the line from beginning instead of rebuilding it from the end, that would be great! :-)
#heart {
position: absolute;
width: 100px;
height: 90px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 9999;
margin-top:10px;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #1D74BA;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
svg.heart-rate {
position: absolute;
z-index: 999;
color: white;
fill: currentColor;
left: 213%;
top: 5%;
transform: translate(-50%,-50%) scale(0.85);
}
.path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 2s linear alternate infinite;
}
#keyframes dash {
from {
stroke-dashoffset: 1000;
}
to {
stroke-dashoffset: 0;
}
}
<div id="heart">
<svg class="heart-rate" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="689px" height="359px" viewBox="0 0 689 359" preserveAspectRatio="xMidYMid meet" ><rect id="svgEditorBackground" x="0" y="0" width="689" height="359" style="fill: none; stroke: none;"/><path clas="path" style="stroke:white;fill:none;stroke-width:4px;" id="e1_polyline" d="M106.204 222.314 113.506 219.658 124.126 226.296 130.1 203.728 136.738 222.977 140.721 218.331 155.987 230.943 164.617 207.047 169.927 223.641 176.565 219.658 180.547 224.969 196.478 224.969"/></svg>
</div>
path is an element, not a class. You need to remove the period from your selector.
.path { ... } becomes path { ... }
#heart {
position: absolute;
width: 100px;
height: 90px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 9999;
margin-top:10px;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #1D74BA;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
svg.heart-rate {
position: absolute;
z-index: 999;
color: white;
fill: currentColor;
left: 213%;
top: 5%;
transform: translate(-50%,-50%) scale(0.85);
}
path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: dash 2s linear alternate infinite;
}
#keyframes dash {
from {
stroke-dashoffset: 1000;
}
to {
stroke-dashoffset: 0;
}
}
<div id="heart">
<svg class="heart-rate" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="689px" height="359px" viewBox="0 0 689 359" preserveAspectRatio="xMidYMid meet" ><rect id="svgEditorBackground" x="0" y="0" width="689" height="359" style="fill: none; stroke: none;"/><path clas="path" style="stroke:white;fill:none;stroke-width:4px;" id="e1_polyline" d="M106.204 222.314 113.506 219.658 124.126 226.296 130.1 203.728 136.738 222.977 140.721 218.331 155.987 230.943 164.617 207.047 169.927 223.641 176.565 219.658 180.547 224.969 196.478 224.969"/></svg>
</div>
If this was my code, I would change the animation slightly...
#heart {
position: absolute;
width: 100px;
height: 90px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 9999;
margin-top:10px;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #1D74BA;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
svg.heart-rate {
position: absolute;
z-index: 999;
color: white;
fill: currentColor;
left: 213%;
top: 5%;
transform: translate(-50%,-50%) scale(0.85);
}
path {
stroke-dasharray: 500;
stroke-dashoffset: 500;
animation: dash 4s linear infinite;
}
#keyframes dash {
0% {
stroke-dashoffset: 500;
}
50% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: -500;
}
}
<div id="heart">
<svg class="heart-rate" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="689px" height="359px" viewBox="0 0 689 359" preserveAspectRatio="xMidYMid meet" ><rect id="svgEditorBackground" x="0" y="0" width="689" height="359" style="fill: none; stroke: none;"/><path clas="path" style="stroke:white;fill:none;stroke-width:4px;" id="e1_polyline" d="M106.204 222.314 113.506 219.658 124.126 226.296 130.1 203.728 136.738 222.977 140.721 218.331 155.987 230.943 164.617 207.047 169.927 223.641 176.565 219.658 180.547 224.969 196.478 224.969"/></svg>
</div>

css rotating trapeze and heart-rate line

We want to animate our logo which is working so far but I dont know how to make those gears appearing like trapeze? Also how to adjust this heartbeat line so its similar to the real log?
I know how to make a trapeze as there are lot of ready code snippets in the internet, but I am struggling to integrate this here.
.parent {
position:relative;
transform: scale(0.4);
}
.gear {
position: relative;
width: 200px;
height: 200px;
margin: auto;
background: black;
border-radius: 50%;
animation-name: spin;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.gear .center {
position: absolute;
top: 25px;
left: 25px;
z-index: 10;
width: 150px;
height: 150px;
background: #fff;
border-radius: 50%;
}
.tooth {
position: absolute;
top: -25px;
left: 75px;
z-index: 1;
width: 45px;
height: 250px;
background: black;
}
.tooth:nth-child(2) {
transform: rotate(45deg);
}
.tooth:nth-child(3) {
transform: rotate(90deg);
}
.tooth:nth-child(4) {
transform: rotate(135deg);
}
#keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#heart {
position: absolute;
width: 100px;
height: 90px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 9999;
margin-top:10px;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #1D74BA;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
svg.heart-rate {
position: absolute;
z-index: 999;
color: white;
fill: currentColor;
left: 50%;
top: 40%;
transform: translate(-50%,-50%) scale(0.6);
}
<div class="parent">
<div id="heart">
<svg class="heart-rate" ersion="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="150px" height="73px" viewBox="0 0 150 73" enable-background="new 0 0 150 73" xml:space="preserve">
<polyline fill="none" stroke="#fff" stroke-width="3" stroke-miterlimit="10" points="0,45.486 38.514,45.486 44.595,33.324 50.676,45.486 57.771,45.486 62.838,55.622 71.959,9 80.067,63.729 84.122,45.486 97.297,45.486 103.379,40.419 110.473,45.486 150,45.486"
/>
</svg>
</div>
<div class="gear">
<div class="center"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
</div>
<br>
</div>
Achieved the trapeze with CSS gradient. You can use 4 gradients at 4 corners with appropriate angles to make it look like a trapeze.
.tooth {
background: linear-gradient(70deg, transparent 10px, #000 10px),
linear-gradient(-70deg, transparent 10px, #000 10px),
linear-gradient(250deg, transparent 10px, #000 10px),
linear-gradient(110deg, transparent 10px, #000 10px);
background-position: bottom left, bottom right, top right, top left;
background-size: 55% 55%;
background-repeat: no-repeat;
}
Full working snippet:
.parent {
position: relative;
transform: scale(0.4);
}
.gear {
position: relative;
width: 200px;
height: 200px;
margin: auto;
background: black;
border-radius: 50%;
animation-name: spin;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.gear .center {
position: absolute;
top: 25px;
left: 25px;
z-index: 10;
width: 150px;
height: 150px;
background: #fff;
border-radius: 50%;
}
.tooth {
position: absolute;
top: -25px;
left: 75px;
z-index: 1;
width: 45px;
height: 250px;
background: linear-gradient(70deg, transparent 10px, #000 10px), linear-gradient(-70deg, transparent 10px, #000 10px), linear-gradient(250deg, transparent 10px, #000 10px), linear-gradient(110deg, transparent 10px, #000 10px);
background-position: bottom left, bottom right, top right, top left;
background-size: 55% 55%;
background-repeat: no-repeat;
}
.tooth:nth-child(2) {
transform: rotate(45deg);
}
.tooth:nth-child(3) {
transform: rotate(90deg);
}
.tooth:nth-child(4) {
transform: rotate(135deg);
}
#keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#heart {
position: absolute;
width: 100px;
height: 90px;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 9999;
margin-top: 10px;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #1D74BA;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
svg.heart-rate {
position: absolute;
z-index: 999;
color: white;
fill: currentColor;
left: 50%;
top: 40%;
transform: translate(-50%, -50%) scale(0.6);
}
<div class="parent">
<div id="heart">
<svg class="heart-rate" ersion="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="150px" height="73px" viewBox="0 0 150 73" enable-background="new 0 0 150 73" xml:space="preserve">
<polyline fill="none" stroke="#fff" stroke-width="3" stroke-miterlimit="10" points="0,45.486 38.514,45.486 44.595,33.324 50.676,45.486 57.771,45.486 62.838,55.622 71.959,9 80.067,63.729 84.122,45.486 97.297,45.486 103.379,40.419 110.473,45.486 150,45.486"
/>
</svg>
</div>
<div class="gear">
<div class="center"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
</div>
<br>
</div>
Couldnt find a good solution for the trapeze but created a nice animated svg polyline:
.parent {
position:relative;
transform: scale(0.4);
}
.gear {
position: relative;
width: 200px;
height: 200px;
margin: auto;
background: black;
border-radius: 50%;
animation-name: spin;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.gear .center {
position: absolute;
top: 25px;
left: 25px;
z-index: 10;
width: 150px;
height: 150px;
background: #fff;
border-radius: 50%;
}
.tooth {
position: absolute;
top: -25px;
left: 75px;
z-index: 1;
width: 45px;
height: 250px;
background: black;
}
.tooth:nth-child(2) {
transform: rotate(45deg);
}
.tooth:nth-child(3) {
transform: rotate(90deg);
}
.tooth:nth-child(4) {
transform: rotate(135deg);
}
#keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#heart {
position: absolute;
width: 100px;
height: 90px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 9999;
margin-top:10px;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #1D74BA;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
svg.heart-rate {
position: absolute;
z-index: 999;
color: white;
fill: currentColor;
left: 213%;
top: 5%;
transform: translate(-50%,-50%) scale(0.85);
}
path {
stroke-dasharray: 500;
stroke-dashoffset: 500;
animation: dash 4s linear infinite;
}
#keyframes dash {
0% {
stroke-dashoffset: 500;
}
50% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: -500;
}
}
<div class="parent">
<div id="heart">
<svg class="heart-rate" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="689px" height="359px" viewBox="0 0 689 359" preserveAspectRatio="xMidYMid meet" ><rect id="svgEditorBackground" x="0" y="0" width="689" height="359" style="fill: none; stroke: none;"/><path style="stroke:white;fill:none;stroke-width:4px;" id="e1_polyline" d="M106.204 222.314 113.506 219.658 124.126 226.296 130.1 203.728 136.738 222.977 140.721 218.331 155.987 230.943 164.617 207.047 169.927 223.641 176.565 219.658 180.547 224.969 196.478 224.969"/></svg>
</div>
<div class="gear">
<div class="center"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
</div>
</div>

heart, heartrate and animated gear with css

This is our logo:
We would like to create it with css and animate the gear, but as you can see if you run my code, I am struggling with following:
heart is not within the gear
if I put div of heart in the gear its animating to, but only the gear should animate
currently the heart-rate (blue line) isnt done with css, cause I dont know how to solve this
Do you know how to solve this?
body{background: #fff;}
.parent{
display: flex;
height: 500px;
}
.gear{
position: relative;
width: 200px;
height: 200px;
margin: auto;
background: black;
border-radius: 50%;
animation-name: spin;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.gear .center{
position: absolute;
top: 25px;
left: 25px;
z-index: 10;
width: 150px;
height: 150px;
background: #fff;
border-radius: 50%;
}
.tooth{
position: absolute;
top: -25px;
left: 75px;
z-index: 1;
width: 45px;
height: 250px;
background:black;
}
.tooth:nth-child(2){
transform: rotate(45deg);
}
.tooth:nth-child(3){
transform: rotate(90deg);
}
.tooth:nth-child(4){
transform: rotate(135deg);
}
#keyframes spin {
from {transform: rotate(0deg); }
to {transform: rotate(360deg);}
}
#heart {
position: relative;
width: 100px;
height: 90px;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #1D74BA;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin :100% 100%;
}
svg.heart-rate{
position: absolute;
z-index:999;
transform: scale(0.6);
color:white;
fill: currentColor;
}
<div class="parent">
<div id="heart">
<svg class="heart-rate" ersion="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="150px" height="73px" viewBox="0 0 150 73" enable-background="new 0 0 150 73" xml:space="preserve">
<polyline fill="none" stroke="#009B9E" stroke-width="3" stroke-miterlimit="10" points="0,45.486 38.514,45.486 44.595,33.324 50.676,45.486 57.771,45.486 62.838,55.622 71.959,9 80.067,63.729 84.122,45.486 97.297,45.486 103.379,40.419 110.473,45.486 150,45.486"
/>
</svg>
</div>
<div class="gear">
<div class="center"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
</div>
</div>
Use position:absolute on the heart and position it in the center of the parent using top,left and transform
body {
background: #fff;
}
.parent {
display: flex;
height: 500px;
position:relative;
}
.gear {
position: relative;
width: 200px;
height: 200px;
margin: auto;
background: black;
border-radius: 50%;
animation-name: spin;
animation-duration: 4s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
.gear .center {
position: absolute;
top: 25px;
left: 25px;
z-index: 10;
width: 150px;
height: 150px;
background: #fff;
border-radius: 50%;
}
.tooth {
position: absolute;
top: -25px;
left: 75px;
z-index: 1;
width: 45px;
height: 250px;
background: black;
}
.tooth:nth-child(2) {
transform: rotate(45deg);
}
.tooth:nth-child(3) {
transform: rotate(90deg);
}
.tooth:nth-child(4) {
transform: rotate(135deg);
}
#keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
#heart {
position: absolute;
width: 100px;
height: 90px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
z-index: 9999;
margin-top:10px;
}
#heart:before,
#heart:after {
position: absolute;
content: "";
left: 50px;
top: 0;
width: 50px;
height: 80px;
background: #1D74BA;
-moz-border-radius: 50px 50px 0 0;
border-radius: 50px 50px 0 0;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
transform: rotate(-45deg);
-webkit-transform-origin: 0 100%;
-moz-transform-origin: 0 100%;
-ms-transform-origin: 0 100%;
-o-transform-origin: 0 100%;
transform-origin: 0 100%;
}
#heart:after {
left: 0;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
-webkit-transform-origin: 100% 100%;
-moz-transform-origin: 100% 100%;
-ms-transform-origin: 100% 100%;
-o-transform-origin: 100% 100%;
transform-origin: 100% 100%;
}
svg.heart-rate {
position: absolute;
z-index: 999;
color: white;
fill: currentColor;
left: 50%;
top: 40%;
transform: translate(-50%,-50%) scale(0.6);
}
<div class="parent">
<div id="heart">
<svg class="heart-rate" ersion="1.0" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="150px" height="73px" viewBox="0 0 150 73" enable-background="new 0 0 150 73" xml:space="preserve">
<polyline fill="none" stroke="#fff" stroke-width="3" stroke-miterlimit="10" points="0,45.486 38.514,45.486 44.595,33.324 50.676,45.486 57.771,45.486 62.838,55.622 71.959,9 80.067,63.729 84.122,45.486 97.297,45.486 103.379,40.419 110.473,45.486 150,45.486"
/>
</svg>
</div>
<div class="gear">
<div class="center"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
<div class="tooth"></div>
</div>
</div>

CSS custom shape with border radius

I want to create something like this via CSS.
Just want to use only CSS to create this custom shape with border radius. Any ideas please?
You can overlap a few div tags and use the skew effect.
HTML
<div class="container">
<div class="shape shape1"></div>
<div class="shape shape2"></div>
<div class="shape shape3"></div>
</div>
CSS
.container {
position: relative;
padding: 30px;
}
.shape {
position: absolute;
text-align: center;
padding: 12px;
height: 60px;
width: 200px;
}
.shape:after {
border-radius: 5px;
content: '';
position: absolute;
height: 100%;
width: 100%;
background: green;
top: 0;
left: 0;
}
.shape1:after {
-webkit-transform: skew(-5deg, -3deg);
-moz-transform: skew(-5deg, -3deg);
-ms-transform: skew(-5deg, -3deg);
-o-transform: skew(-5deg, -3deg);
transform: skew(-5deg, -3deg);
}
.shape2:after {
-webkit-transform: skew(0deg, -1deg);
-moz-transform: skew(0deg, -1deg);
-ms-transform: skew(0deg, -1deg);
-o-transform: skew(0deg, -1deg);
transform: skew(0deg, -1deg);
top: 4px;
left: 3px;
}
.shape3:after {
-webkit-transform: skew(3deg, -2deg);
-moz-transform: skew(2deg, -2deg);
-ms-transform: skew(2deg, -2deg);
-o-transform: skew(2deg, -2deg);
transform: skew(2deg, -2deg);
top: 2px;
left: -5px;
}
.set2 {
margin-top: 80px;
}
.set2 .shape2:after {
background: red;
}
.set2 .shape3:after {
background: blue;
}
Here's a jsFiddle
You may want to look into CSS3 2D Transforms. It's possible to do similar things, but there are limitations as well. I tried to do something similar to the referenced shape :)
// CSS
#shape {
position: relative;
text-align: center;
padding: 12px;
margin-bottom: 6px;
height: 60px;
width: 200px;
margin:30px;
}
#shape:after {
border-radius: 5px;
content: '';
position: absolute;
top: 0;
right: 0;
height: 100%;
width: 100%;
background: green;
-webkit-transform: skew(-5deg, -3deg);
-moz-transform: skew(-5deg, -3deg);
-ms-transform: skew(-5deg, -3deg);
-o-transform: skew(-5deg, -3deg);
transform: skew(-5deg, -3deg);
}
// HTML
<div id="shape"></div>
Check the jsFiddle

CSS Only Marker Shape

I want to create a CSS only shape that looks like a marker or guitar pick.
My Codepen demo I've been working from: http://codepen.io/Vestride/pen/otcem
// CSS Marker
// I was attempting to make this shape in CSS. The marker on the far right is an image. Next to it is SVG. The rest are my attempts :|
// stackoverflow question: http://stackoverflow.com/questions/11982066/css-only-marker-shape
// Top part is a perfect circle
// Bottom half is edges that curve out!
body {
margin: 40px 20px;
background: url(http://subtlepatterns.com/patterns/furley_bg_#2X.png) ;
background-size: 600px 600px;
}
figure {
position: relative;
float: left;
margin-left: 60px;
width: 80px;
height: 80px;
}
figure:first-child {
margin-left: 0;
}
.one {
border-radius: 50% 50% 0 50%;
background: hotpink;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.two {
background: skyblue;
border-top-left-radius: 50%;
border-top-right-radius: 50% 100%;
border-bottom-left-radius: 100% 50%;
border-bottom-right-radius: 0%;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.three {
border-radius: 50%;
background: lightgreen;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.three::before {
content: '';
position: absolute;
width: 106%;
height: 106%;
background: lightgreen;
border-top-left-radius: 60%;
border-top-right-radius: 50% 100%;
border-bottom-left-radius: 100% 50%;
border-bottom-right-radius: 0%;
}
.four {
border-radius: 50% 50% 0 50%;
background: seagreen;
overflow-x: visible;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-o-transform: rotate(45deg);
transform: rotate(45deg);
}
.four::before {
content: '';
position: absolute;
width: 100%;
height: 100%;
background: red;
border-top-left-radius: 50%;
border-top-right-radius: 50% 100%;
border-bottom-left-radius: 100% 50%;
border-bottom-right-radius: 0%;
}
.five {
width: 80px;
height: 102px;
background-image: url(http://i.imgur.com/t80ZS.png);
/* Overlay the objective */
/*margin-left: -80px;
opacity: 0.6;*/
}
.svg {
position: relative;
float: left;
margin-left: 60px;
}
<figure class="one"></figure>
<figure class="two"></figure>
<figure class="three"></figure>
<figure class="four"></figure>
<figure class="svg">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="81px" height="104px" viewBox="0 0 81 104">
<g transform="translate(1, 1)"><path fill="#FFFFFF" stroke="#CCCCCC" stroke-width="2" d="M78.399,39.2c0,36.998-39.199,62.599-39.199,62.599S0,76.198,0,39.2C0,17.55,17.551,0,39.2,0 C60.848,0,78.399,17.55,78.399,39.2z"/></g>
</svg>
</figure>
<!-- Image -->
<figure class="five"></figure>
I've been unsuccessful in replicating the curvy edges by the point. Ideally I'd like to accomplish this with one element (+pseudo elements).
Take a look at this one, i changed their css abit:
http://codepen.io/anon/pen/HLJlu
With SVG
You can achieve the marker shape with an inline svg. The following example uses a path element with 2 cubic bezier curve commands:
svg{width:80px;height:100px;}
<svg viewbox="0 0 80 100">
<path d="M40 99.5 C-22.5 57.5 0 0 40 0.5 C80 0 102.5 57.5 40 99.5z" stroke-width="1" stroke="grey" fill="transparent"/>
</svg>
With CSS
You can also make the marker shape with CSS only using border radius, absolute positioning and 2 pseudo elements. Note that this example uses only one div element
div{
position:relative;
width:80px;
height:102px;
overflow:hidden;
border-radius:40px;
}
div:before, div:after{
content:'';
position:absolute;
top:0px;
width:240px;
height:150px;
border:1px solid green;
}
div:before{
left:0;
border-top-left-radius:40px;
border-bottom-left-radius:240px 110px;
}
div:after{
right:0;
border-top-right-radius:40px;
border-bottom-right-radius:240px 110px;
}
<div></div>
<svg x="0px" y="0px" width="32px" height="45px"
viewBox="38 12 128 180" style="cursor:help;" >
<style type="text/css">
.st0{ fill:#FFF;stroke:#000;stroke-width:6;stroke-miterlimit:10;}
.st1{fill:#FFFFFF;}
.st2{fill:#1309FF;}
.st3{fill:#1309FF;}
.st4{fill:#1309FF;}
.st6{font-size:57.2285px;}
</style>
<path class="st0" d="M158.5,73.8c0-32.3-26.2-58.4-58.4-58.4c-32.3,0-58.4,26.2-58.4,58.4c0,16.6,6.9,31.5,18,42.1
c7.2,7.2,16.7,17.2,20.1,22.5c7,10.9,20,47.9,20,47.9s13.3-37,20.4-47.9c3.3-5.1,12.2-14.4,19.3-21.6
C151.2,106.1,158.5,90.9,158.5,73.8z"/>
<circle class="st4" cx="100.1" cy="74.7" r="44.1"/>
<text x="100" y="90" class="st1 st5 st6" text-anchor="middle" >12</text>
</svg>
This will be better OR This
<svg width="32px" height="45px" viewBox="38 12 128 180" >
<path style="fill:#FFFFFF;stroke:#020202;stroke-width:4;stroke-miterlimit:10;" d="M158.5,73.8c0-32.3-26.2-58.4-58.4-58.4c-32.3,0-58.4,26.2-58.4,58.4c0,16.6,6.9,31.5,18,42.1c7.2,7.2,16.7,17.2,20.1,22.5c7,10.9,20,47.9,20,47.9s13.3-37,20.4-47.9c3.3-5.1,12.2-14.4,19.3-21.6C151.2,106.1,158.5,90.9,158.5,73.8z"/>
<circle style="fill:' + color + ';" cx="100.1" cy="74.7" r="44.1"/>
<text x="100" y="90" text-anchor="middle" style="font-size:57.2285px;fill:#FFFFFF;">12</text>
</svg>

Resources