Specify child in a parent in svelte - css
I am trying to replicate the page loading template from here
HTML
<div class="loading">
<div class="loading__ring">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve"><path>...../path></svg>
</div>
<div class="loading__ring">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve"><path>......</path></svg>
</div>
</div>
Normal CSS style
/* Demo */
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(#ecf0f1, #fff);
}
/* Animation */
#keyframes rotate {
to {
transform: rotate(360deg);
}
}
/* Variables */
$loader-size: 100px;
/* Loading Icon */
.loading {
width: $loader-size;
height: $loader-size;
&__ring {
position: absolute;
width: $loader-size;
height: $loader-size;
&:first-child {
transform: skew(30deg,20deg);
}
&:last-child {
transform: skew(-30deg,-20deg) scale(-1, 1);
svg {
animation-delay: -0.5s;
}
}
svg {
animation: rotate 1s linear infinite;
fill: rgba(0, 0, 0, 0.2);
}
}
}
I tried to alter into the svelte style by using example specifying child like .loading:global(loading__ring) but this is exactly where I am getting the error saying
Internal server error: /Users/mypc/Documents/testingsveltenvite/v2/src/App.svelte:18:2 Identifier is expected
How do I alter specifying child &__ringor.loading:global(loading__ring) and &:first-child in svelte
/* Loading Icon */
.loading {
width: var(--size);
height: var(--size);
.loading:global(loading__ring) {
position: absolute;
width: var(--size);
height: var(--size);
&:first-child {
transform: skew(130deg,15deg);
}
&:last-child {
transform: skew(-130deg,-1deg) scale(-1, 1);
svg {
animation-delay: -0.91s;
}
}
svg {
animation: rotate 4s linear infinite;
fill: rgba(0, 0, 0, 0.2);
}
}
}
I don't see why you would need the :global() flag, if you have everything inside one component REPL - only the scss has to be converted to normal css (or scss added to the Svelte project)
(the body tag here needs the :global(body) because it's not in the component scope. If you want to make this a loading component, you would probably better add a background element and style this instead)
<script>
import {path} from './path'
</script>
<div class="loading">
<div class="loading__ring">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
{#html path}
</svg>
</div>
<div class="loading__ring">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background:new 0 0 100 100;" xml:space="preserve">
{#html path}
</svg>
</div>
</div>
<style>
:global(body) {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(#ecf0f1, #fff);
}
/* Animation */
#keyframes rotate {
to {
transform: rotate(360deg);
}
}
/* Variables */
:root {
--size: 100px;
}
/* Loading Icon */
.loading {
width: var(--size);
height: var(--size);
}
.loading__ring {
position: absolute;
width: var(--size);
height: var(--size);
}
.loading__ring:first-child {
transform: skew(30deg,20deg);
}
.loading__ring:last-child {
transform: skew(-30deg,-20deg) scale(-1, 1);
}
.loading__ring:last-child svg {
animation-delay: -0.5s;
}
.loading__ring svg {
animation: rotate 1s linear infinite;
fill: rgba(0, 0, 0, 0.2);
}
</style>
Related
How to rotate a div across the axis of an svg circle
I have a black circle and a small red circle on the axis of the bigger one: Both are created with simple svg code: export default function App() { return ( <div> <svg className="main-svg" viewBox="0 0 100 100"> <circle pathLength="25" cx="50%" cy="50%" r="50%" /> </svg> <svg viewBox="0 0 100 100"> <circle className="small-circle" transform-origin="center" fill="green" pathLength="25.5" cx="50%" cy="50%" r="50%" /> </svg> </div> ); } It's easy to rotate the smaller one, because both circles have the same radius so you just need to change the degree: svg { position: absolute; } .small-circle { transform: rotate(20deg); stroke-linecap: round; stroke-width: 5; stroke-dasharray: 0 25; stroke-dashoffset: -2.5; fill: none; stroke: red; } However I would like to insert some content into that red circle svg, namely use a div, and to my knowledge it's very difficult to do with svg. How can I create a rotating div instead of the red svg, hopefully without constant pixel values to it's sizable like the svgs? The code on stackblitz: https://stackblitz.com/edit/react-ts-fwmjzn?file=style.css
Although <foreignObject can be inserted to SVG, It's hard to implement your requirement. Because of .small-circle is rendered by stroke, it's hard to locate x and y's positions when it is rotating. Maybe using div and CSS3 is a good implement. https://stackblitz.com/edit/react-ts-iq2aqm?file=App.tsx,style.css,index.tsx import * as React from 'react'; import './style.css'; export default function App() { return ( <div className="container"> <svg className="main-svg" viewBox="0 0 100 100"> <circle pathLength="25" cx="50%" cy="50%" r="50%" /> </svg> <div className="small-circle">A</div> </div> ); } h1, p { font-family: Lato; } body { margin: 0; } .container { position: relative; outline: 1px solid red; } #keyframes rotate { to { transform: rotate(1turn); } } .small-circle { width: 5vw; height: 5vw; border-radius: 50%; background-color: coral; top: 50%; margin-top: -2.5vw; margin-left: -2.5vw; position: absolute; outline: 1px solid red; transform-origin: 52.5vw center; animation: rotate 8s linear infinite; text-align: center; } hope help you.
how to do on the Angular svg map to bubble point?
I added this map for the angular type script project, dose any one know to how to create bubble count region on the map like this image Stack blitz here here the jsFiddle code link css here p {font-size: 12px} #core { fill: #ff4f81; animation: pulse1 1.5s ease-in-out infinite; } #radar { fill: #F99EAD; animation: pulse2 1.5s ease-in-out infinite; } #keyframes pulse1 { 0% { opacity: 0; transform: scale(0); } 30% { opacity: 1; transform: scale(1.5); } 60% { opacity: 1; transform: scale(2); } 100% { opacity: 0; transform: scale(2); } } #keyframes pulse2 { 0% { transform: scale(1, 1); opacity: 0; } 50% { opacity: 1; } 100% { transform: scale(6, 6); opacity: 0; } } .row-wrap { text-align: center; float: left; margin: 0 10px; } .row-middle { font-size: 30px; color: #0E76FE; font-weight: 700; } .row-middle-two{ font-size: 17px;color: #808490; } .row-middle-three{ font-size: 14px;color: #9DA2AE; } .row-bottom-small{ font-size: 10px; color: #B9C0CD; }.row-top-small{ font-size: 10px; color: #B9C0CD; } .row-bottom{ color: #A3A9B5;font-size: 12px; } .row-top{ color: #A3A9B5;font-size: 12px; } p {font-size: 12px}
So, to add an SVG bubble to your map (which is also SVG), you first need to pick the SVG file you'd like to add. I chose the following (run the fiddle to see how it looks): <?xml version="1.0" encoding="iso-8859-1"?> <svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 293.334 293.334" style="enable-background:new 0 0 293.334 293.334;" xml:space="preserve"> <g> <g> <path style="fill:#010002;" d="M146.667,0C94.903,0,52.946,41.957,52.946,93.721c0,22.322,7.849,42.789,20.891,58.878 c4.204,5.178,11.237,13.331,14.903,18.906c21.109,32.069,48.19,78.643,56.082,116.864c1.354,6.527,2.986,6.641,4.743,0.212 c5.629-20.609,20.228-65.639,50.377-112.757c3.595-5.619,10.884-13.483,15.409-18.379c6.554-7.098,12.009-15.224,16.154-24.084 c5.651-12.086,8.882-25.466,8.882-39.629C240.387,41.962,198.43,0,146.667,0z M146.667,144.358 c-28.892,0-52.313-23.421-52.313-52.313c0-28.887,23.421-52.307,52.313-52.307s52.313,23.421,52.313,52.307 C198.98,120.938,175.559,144.358,146.667,144.358z"/> <circle style="fill:#010002;" cx="146.667" cy="90.196" r="21.756"/> </g> </g> </svg> since you have already had everything set up beside the bubbles, and I didn't want to change it, I added a transform attribute to the <g> (so the bubble will be at the exact points and scale) transform="translate(-64 -126) scale(0.5)" To add it to the map, you just need to insert it in the location groups that you'd like and change the translate parameters so that it is in the right spot. you can see it in work here (stackbitz)
SVG Signature Animation Issues
I'm basically trying to use CSS to make this SVG signature animation happen for my own SVG signature: https://webdesign.tutsplus.com/tutorials/sign-on-the-dotted-line-animating-your-own-svg-signature--cms-23846 I've got it close, but for some reason it's drawing the outline of the SVG image, instead of the strokes of the SVG itself? I'm not sure what I'm doing wrong. Here's what I've got: .signature { max-width: 400px; margin: 0 auto; position: relative; overflow: auto; width: 100%; height: 0; padding-bottom: 20%; } svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } path { fill: none; stroke: #2a3745; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 10; } #keyframes write1 { 5% { stroke-dashoffset: 890; } 60% { stroke-dashoffset: 0; } } #keyframes write2 { 5%, 65% { stroke-dashoffset: 915; } 100% { stroke-dashoffset: 0; } } .stroke-A { stroke-dasharray: 890; animation: write1 4s 1 linear; } .stroke-mber { stroke-dasharray: 915; animation: write2 4s 1 linear; } <div class="signature"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 591.3 429.4" xml:space="preserve"> <g> <g> <path class="stroke-A" d="M1.9,277.9c53.5-7.3,104.9-28.2,148.7-59.7c44.1-31.7,79.6-74.2,104.2-122.5c13.8-27.1,24.2-55.8,31.5-85.4 c-1-0.1-2-0.3-2.9-0.4c-6.4,51.9-10.7,109.6,24.8,152.7c1.1,1.3,3.2-0.4,2.4-1.8c-9.3-16.7-25.7-27.6-42.3-36.3 c-19.1-10.1-39.2-18.9-59.5-26.3C169.2,83.5,125.8,75.6,84.4,87c-19.4,5.3-37.9,14.9-51.4,30c-1.3,1.4,0.8,3.6,2.1,2.1 c24.6-27.5,64.8-36.2,100.4-34.4c43.3,2.2,84.9,19.5,123.4,38.3c18.8,9.2,38.6,20.4,49.1,39.3c0.8-0.6,1.6-1.2,2.4-1.8 c-34.9-42.3-30.2-99.6-23.9-150.5c0.2-1.7-2.5-2-2.9-0.4c-13,52.7-36.2,103-70.3,145.4c-33,41-75.7,73.6-123.8,95 c-28,12.5-57.8,20.9-88.2,25.1C-0.8,275.2,0,278.1,1.9,277.9L1.9,277.9z"/> </g> </g> <g> <g> <path class="stroke-mber" d="M278.2,158.8c8.9-14.5,20.4-27.1,33.8-37.6c4.1-3.2,8.4-7.2,13.9-7.4c4.7-0.1,7.1,2.6,8.6,6.7c3.5,9.4,4.2,19.7,2.7,29.6 c1,0.1,2,0.3,2.9,0.4c-1.7-14.3,3.3-28.5,13.2-38.9c2.8-2.9,6.2-6.8,10.4-7.1c5.6-0.3,6.7,4.5,7.1,8.8c0.7,8.1,0.9,16.2,1.3,24.3 c0.1,1.7,2.4,2.1,2.9,0.4c2.2-7.2,10.3-19.4,18.8-12c2.4,2.1,4,4.5,7,5.9c3,1.4,6.4,1.8,9.6,1.5c15.1-1.5,21.9-16.6,25.7-29.4 c4.7-15.8,5-33.1,0.6-49c-1.1-3.9-4.3-6.9-8.6-4.7c-5,2.6-2.6,12-2.4,16.3c1.3,21.1,5.9,41.9,13.5,61.6c0.5,1.3,2.5,1.6,2.9,0 c1.8-7.5,3.8-15.4,9.6-20.9c6.2-5.9,21.6-9.4,25.3,1.4c2.4,6.9-3.5,13.9-9.3,16.8c-8.5,4.2-17.5,2.6-26.5,1.6 c-1.7-0.2-2.1,2.6-0.4,2.9c16.5,3.3,34.2,5.4,49.3-3.9c6-3.7,11.1-9.1,13.8-15.6c1.8-4.4,3.5-12.9-0.2-16.9 c-3.8-4.1-7.3,1.5-8.3,4.9c-1.4,5.2-0.2,10.8,2.4,15.3c6.2,10.7,19.9,14.8,30.9,9.1c11.2-5.8,17.3-20.8,8.4-31.1 c-0.9-1.1-3,0.1-2.5,1.5c3.7,9.5,7.4,19,11.1,28.5c0.9-0.4,1.8-0.8,2.7-1.2c-12.1-15.7,11.2-29.8,21.6-37.6 c9.1-6.9,16.1-15.5,19.3-26.5c6.2-21.3-3-43.8-21.1-56.1c-1.6-1.1-3.1,1.5-1.5,2.6c20.1,13.7,27.9,41.2,15.4,62.7 c-7.1,12.2-19.9,17.9-29.9,27.2c-8,7.4-13.9,19.6-6.4,29.3c0.9,1.2,3.4,0.6,2.7-1.2c-3.7-9.5-7.4-19-11.1-28.5 c-0.8,0.5-1.7,1-2.5,1.5c8.8,10.2-0.4,25-11.9,28c-12.1,3.1-25.8-6.3-25.3-19.3c0.1-1.9,2.2-10,4.5-4.6c1.2,3,0.2,7.4-0.8,10.3 c-2.3,6.6-7.6,12.1-13.5,15.6c-14.4,8.4-30.9,6.3-46.4,3.2c-0.1,1-0.3,2-0.4,2.9c10.9,1.3,22.8,3,32.1-4.6 c5.5-4.5,9.5-12.9,5.6-19.7c-4.7-8.3-16.8-8.5-24.3-4.3c-9.7,5.4-13,15.8-15.4,25.9c1,0,1.9,0,2.9,0 c-7.4-19.2-12.1-39.4-13.4-59.9c-0.1-2.3-1.8-17,3-14.8c3.6,1.7,4.1,13.1,4.5,16.4c1,9.7,0.5,19.5-1.7,29 c-2.1,8.9-5.2,19-11.6,25.8c-3.5,3.8-8.1,6.2-13.3,6.5c-5.5,0.4-8.9-1.8-12.7-5.5c-10.5-10.3-21.5,1.6-24.9,12.3 c1,0.1,2,0.3,2.9,0.4c-0.3-5.9-0.6-11.8-1-17.7c-0.2-4,0.1-8.6-1.4-12.4c-2.5-6.5-10.1-7.4-15.4-3.6 c-14.4,10.2-22.3,29.4-20.2,46.7c0.2,1.5,2.7,2.2,2.9,0.4c1.8-12.2,1.6-47.3-19.8-38.9c-4.5,1.8-8.5,5.5-12.3,8.5 c-4.4,3.5-8.5,7.3-12.5,11.3c-7.6,7.7-14.3,16.2-19.9,25.4C274.6,158.9,277.2,160.4,278.2,158.8L278.2,158.8z"/> </g> </g> </svg> </div>
As far as i can see it, the problem is your svg-file. Just go back to your illustration-tool and recreate your signature with just a colored path and no fill. Then your animation will just move along this path and not around it. I did just with the "A" in the example below. .signature { max-width: 400px; margin: 0 auto; position: relative; overflow: auto; width: 100%; height: 0; padding-bottom: 20%; } svg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } path { fill: none; stroke: #2a3745; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-miterlimit: 10; } #keyframes write1 { 5% { stroke-dashoffset: 890; } 60% { stroke-dashoffset: 0; } } #keyframes write2 { 5%, 65% { stroke-dashoffset: 915; } 100% { stroke-dashoffset: 0; } } .stroke-A { stroke-dasharray: 890; animation: write1 4s 1 linear; } .stroke-mber { stroke-dasharray: 915; animation: write2 4s 1 linear; } <div class="signature"> <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 591.3 429.4" style="enable-background:new 0 0 591.3 429.4;" xml:space="preserve"> <g> <g> <path class="stroke-A" d="M1.9,277.9c0,0,217-19.4,281.7-268.3c0,0-14.1,118,27,151.2c0,0-158.3-140.8-277.6-43.8"/> </g> </g> <g> <g> <path class="stroke-mber" d="M278.2,158.8c8.9-14.5,20.4-27.1,33.8-37.6c4.1-3.2,8.4-7.2,13.9-7.4c4.7-0.1,7.1,2.6,8.6,6.7c3.5,9.4,4.2,19.7,2.7,29.6 c1,0.1,2,0.3,2.9,0.4c-1.7-14.3,3.3-28.5,13.2-38.9c2.8-2.9,6.2-6.8,10.4-7.1c5.6-0.3,6.7,4.5,7.1,8.8c0.7,8.1,0.9,16.2,1.3,24.3 c0.1,1.7,2.4,2.1,2.9,0.4c2.2-7.2,10.3-19.4,18.8-12c2.4,2.1,4,4.5,7,5.9s6.4,1.8,9.6,1.5c15.1-1.5,21.9-16.6,25.7-29.4 c4.7-15.8,5-33.1,0.6-49c-1.1-3.9-4.3-6.9-8.6-4.7c-5,2.6-2.6,12-2.4,16.3c1.3,21.1,5.9,41.9,13.5,61.6c0.5,1.3,2.5,1.6,2.9,0 c1.8-7.5,3.8-15.4,9.6-20.9c6.2-5.9,21.6-9.4,25.3,1.4c2.4,6.9-3.5,13.9-9.3,16.8c-8.5,4.2-17.5,2.6-26.5,1.6 c-1.7-0.2-2.1,2.6-0.4,2.9c16.5,3.3,34.2,5.4,49.3-3.9c6-3.7,11.1-9.1,13.8-15.6c1.8-4.4,3.5-12.9-0.2-16.9 c-3.8-4.1-7.3,1.5-8.3,4.9c-1.4,5.2-0.2,10.8,2.4,15.3c6.2,10.7,19.9,14.8,30.9,9.1c11.2-5.8,17.3-20.8,8.4-31.1 c-0.9-1.1-3,0.1-2.5,1.5c3.7,9.5,7.4,19,11.1,28.5c0.9-0.4,1.8-0.8,2.7-1.2C536.3,104.9,559.6,90.8,570,83 c9.1-6.9,16.1-15.5,19.3-26.5c6.2-21.3-3-43.8-21.1-56.1c-1.6-1.1-3.1,1.5-1.5,2.6c20.1,13.7,27.9,41.2,15.4,62.7 c-7.1,12.2-19.9,17.9-29.9,27.2c-8,7.4-13.9,19.6-6.4,29.3c0.9,1.2,3.4,0.6,2.7-1.2c-3.7-9.5-7.4-19-11.1-28.5 c-0.8,0.5-1.7,1-2.5,1.5c8.8,10.2-0.4,25-11.9,28c-12.1,3.1-25.8-6.3-25.3-19.3c0.1-1.9,2.2-10,4.5-4.6c1.2,3,0.2,7.4-0.8,10.3 c-2.3,6.6-7.6,12.1-13.5,15.6c-14.4,8.4-30.9,6.3-46.4,3.2c-0.1,1-0.3,2-0.4,2.9c10.9,1.3,22.8,3,32.1-4.6 c5.5-4.5,9.5-12.9,5.6-19.7c-4.7-8.3-16.8-8.5-24.3-4.3c-9.7,5.4-13,15.8-15.4,25.9c1,0,1.9,0,2.9,0 c-7.4-19.2-12.1-39.4-13.4-59.9c-0.1-2.3-1.8-17,3-14.8c3.6,1.7,4.1,13.1,4.5,16.4c1,9.7,0.5,19.5-1.7,29 c-2.1,8.9-5.2,19-11.6,25.8c-3.5,3.8-8.1,6.2-13.3,6.5c-5.5,0.4-8.9-1.8-12.7-5.5c-10.5-10.3-21.5,1.6-24.9,12.3 c1,0.1,2,0.3,2.9,0.4c-0.3-5.9-0.6-11.8-1-17.7c-0.2-4,0.1-8.6-1.4-12.4c-2.5-6.5-10.1-7.4-15.4-3.6 c-14.4,10.2-22.3,29.4-20.2,46.7c0.2,1.5,2.7,2.2,2.9,0.4c1.8-12.2,1.6-47.3-19.8-38.9c-4.5,1.8-8.5,5.5-12.3,8.5 c-4.4,3.5-8.5,7.3-12.5,11.3c-7.6,7.7-14.3,16.2-19.9,25.4C274.6,158.9,277.2,160.4,278.2,158.8L278.2,158.8z"/> </g> </g> </svg> </div>
"Filling Water" effect with infinite repeat wrapping
I've been trying to achieve the effect seen here for one wave in a circle: http://www.jquery-az.com/css/demo.php?ex=131.0_1 Unfortunately, I've been unable to get the animation to repeat smoothly with my own svg, seen here: http://jsbin.com/diserekigo/1/edit?html,css,output. You'll also notice that the bottom "rectangle" part isn't filled either. My css is as follows: .circle { border-radius: 100%; border: 1px solid black; width: 200px; height: 200px; overflow: hidden; position: relative; perspective: 1px; } .liquid { position: absolute; left: 0; top: 0; z-index: 2; width: 100%; height: 100%; -webkit-transform: translate(0, 80%); transform: translate(0, 80%); } .wave { left: 0; width: 400%; position: absolute; bottom: 100%; margin-bottom: -1px; -webkit-animation: wave-front .7s infinite linear; animation: wave-front 0.7s infinite linear; } #-webkit-keyframes wave-front { 100% { -webkit-transform: translate(-100%, 0); transform: translate(-100%, 0); } } #keyframes wave-front { 100% { -webkit-transform: translate(-100%, 0); transform: translate(-100%, 0); } } How can I improve the repeating behavior, as well as make the wave fill up the entire space beneath it?
You're missing a lot from the original demo. Why not just copy and paste and make whatever local changes to the size and position you wanted? Most of your issues are a result of not having all the SVG elements - the original demo has 3, not just 1. I've added them into your jsbin to get it to work: <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" style="display: none;"> <symbol id="wave"> <path d="M420,20c21.5-0.4,38.8-2.5,51.1-4.5c13.4-2.2,26.5-5.2,27.3-5.4C514,6.5,518,4.7,528.5,2.7c7.1-1.3,17.9-2.8,31.5-2.7c0,0,0,0,0,0v20H420z"></path> <path d="M420,20c-21.5-0.4-38.8-2.5-51.1-4.5c-13.4-2.2-26.5-5.2-27.3-5.4C326,6.5,322,4.7,311.5,2.7C304.3,1.4,293.6-0.1,280,0c0,0,0,0,0,0v20H420z"></path> <path d="M140,20c21.5-0.4,38.8-2.5,51.1-4.5c13.4-2.2,26.5-5.2,27.3-5.4C234,6.5,238,4.7,248.5,2.7c7.1-1.3,17.9-2.8,31.5-2.7c0,0,0,0,0,0v20H140z"></path> <path d="M140,20c-21.5-0.4-38.8-2.5-51.1-4.5c-13.4-2.2-26.5-5.2-27.3-5.4C46,6.5,42,4.7,31.5,2.7C24.3,1.4,13.6-0.1,0,0c0,0,0,0,0,0l0,20H140z"></path> </symbol> </svg> <div class="circle"> <div class="liquid"></div> <div id="water" class="water"> <svg viewBox="0 0 560 20" class="water_wave water_wave_back"> <use xlink:href="#wave"></use> </svg> <svg viewBox="0 0 560 20" class="water_wave water_wave_front"> <use xlink:href="#wave"></use> </svg> </div> </div> You also need JavaScript to get the water to fill. http://jsbin.com/pinowufeqe/edit?html,css,js,output
Animate svg path
I have animated a svg path but I need some help. I want to know if it's possible to animate the path at a certain speed and then an other speed. Here is a JSFIDDLE for more explanation. I want the line to go fast and then the text to be less fast. HTML <svg class="svg-path" version="1.1" id="Calque_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 2238.6 153.7" enable-background="new 0 0 2238.6 153.7" xml:space="preserve"> <path class="path" stroke-width="2" fill="none" stroke="#000000" d="M0,149.5c0.6,0,1629.7,0,1631,0c2.7,0,10.6,0,12.4,0c3.3,0,5.9,0,8.2,0c4.1,0,8.1,0,10.9,0 c3.8,0,5.3,0,8.7,0c3.9,0,3.6,0.1,8.1,0c6.3-0.2,8.2-0.9,12.7-2.6c4.5-1.7,8.3-4.1,11.4-7.1c3.1-3,5.5-6.6,7.1-10.7 c1.6-4.1,2.4-8.5,2.4-13.2c0-5.1-1-9.3-3.1-12.6c-2.1-3.3-4.8-6.1-8.2-8.3c-3.4-2.2-7.3-4.1-11.6-5.6c-4.3-1.5-8.8-3-13.3-4.4 c-4.6-1.4-9-3-13.3-4.8c-4.3-1.8-8.2-4-11.6-6.8c-3.4-2.8-6.1-6.2-8.2-10.3c-2.1-4.1-3.1-9.3-3.1-15.5c0-4.8,0.9-9.5,2.8-14 s4.5-8.5,8.1-11.9c3.5-3.4,7.9-6.2,13.1-8.3c5.2-2.1,11.1-3.1,17.8-3.1c7.5,0,19.1,0,25.5,0c7.5,0,22.4,0,35.9,0v140.5l44.4,0 L1788,9.6l66.3,110.3l64.5-109.8l-0.2,140.9h87.1c0,0,64.7,0,64.7-76.9c0-72-63.3-69.4-63.3-69.4s-60.7-2.7-60.7,69.2 c0,77,56.8,76.9,61,77c0.2,0,89.6,0,93.9,0V13.5l104.7,137.3l0-143.7l32.7,0 M1946.3,73.9 M2070.3,74.1"/> </svg> CSS svg{ &.svg-path{ position: absolute; top:25px; left: 0px; width: 100%; height: auto; } .path { stroke-dasharray: 3800; stroke-dashoffset: 0; animation: dash 3.5s linear reverse; } } #keyframes dash { to { stroke-dashoffset: 3800; } } Is that possible to do this with one svg path ?
use this example http://jsfiddle.net/wxx5o9ms/1/ svg.svg-path { position: absolute; top:25px; left: 0px; width: 100%; height: auto; } svg.svg-path path { stroke-dasharray: 3800; animation: dash 3.5s linear reverse; } #keyframes dash { 0% { stroke-dashoffset: 0; transition: 'stroke-dashoffset'; } 70% { stroke-dashoffset: 2000; transition: 'stroke-dashoffset'; } 100% { stroke-dashoffset: 3800; transition: 'stroke-dashoffset'; } }