- How to create animated border on hover
- 45 CSS Border Animations
- Related Articles
- Author
- Links
- Made with
- About a code
- Animated Border Gradient
- Author
- Links
- Made with
- About a code
- Rotating Border Animation
- Author
- Links
- Made with
- About a code
- Transparent Inner Border with Hover Effect
- Author
- Links
- Made with
- About a code
- Zig-Zag Border & Cool Hover Effect
- Author
- Links
- Made with
- About a code
- CSS Only Cool Hover Effect
- Author
- Links
- Made with
- About a code
- Border Gradient Hover Effect
- Author
- Links
- Made with
- About a code
- Fancy Border on Hover
- Author
- Links
- Made with
- About a code
- Fancy Border on Hover
- Author
- Links
- Made with
- About a code
- CSS Only Border Hover Effect
- Author
- Links
- Made with
- About a code
- Framed on Hover
- Author
- Links
- Made with
- About a code
- Fancy Border Radius CSS
- Author
- Links
- Made with
- About a code
- Houdini Gradient Border Animation
- Author
- Links
- Made with
- About a code
- Framed
- Author
- Links
- Made with
- About a code
- Input with Gradient-Border — Dark
- Author
- Links
- Made with
- About a code
- Dashed Border Icon Animations
- Author
- Links
- Made with
- About a code
- Fancy Animated Rainbow Border
- Author
- Links
- Made with
- About a code
- Magic Border Mixin
- Author
- Links
- Made with
- About a code
- Gradient Border
- Author
- Links
- Made with
- About a code
- Fancy Border Radius
- Author
- Links
- Made with
- About a code
- CSS Border
- Author
- Links
- Made with
- About the code
- Rotating Border
- Author
- Links
- Made with
- About a code
- Gold Border Shimmer
- Author
- Links
- Made with
- About the code
- Animating border-radius
- Author
- Links
- Made with
- About the code
- Border Animation
- Author
- Links
- Made with
- About a code
- CSS Border Animation
- Author
- Links
- Made with
- About the code
- Animating border-radius
- Author
- Links
- Made with
- About the code
- Border Animation CSS
- Author
- Links
- Made with
- About the code
- Stripe Border
- Author
- Links
- Made with
- About the code
- CSS Only Border Animation
- Author
- Links
- Made with
- About the code
- Button Border Slide Mixin
- Author
- Links
- Made with
- About the code
- Draw Borders from Center
- Author
- Links
- Made with
- About the code
- Border Composition and Animation
- Author
- Links
- Made with
- About the code
- Border Animation
- Author
- Links
- Made with
- About the code
- Border Animation
- Author
- Links
- Made with
- About the code
- CSS Border Hover Transitions
- Author
- Links
- Made with
- About a code
- CSS Border Transitions
- Author
- Links
- Made with
- About the code
- Animated Border
- Author
- Links
- Made with
- About the code
- Double Border Animation
- Author
- Links
- Made with
- About the code
- Border Animation
- Author
- Links
- Made with
- About the code
- Border-Gradient Mixin
- Author
- Links
- Made with
- About the code
- Border Animation Effect
- Author
- Links
- Made with
- About the code
- SVG Border Animation
- Author
- Links
- Made with
- About the code
- Animated Border Gradient Effect
- Author
- Links
- Made with
- About the code
- Border-Radius Animation
- Author
- How to create animated border using css3 or canvas while hover?
- My excepted output:
- 2 Answers 2
How to create animated border on hover
I want to create a hover effect like in this site: http://themes.creiden.com/circleflip/blog-with-sidebar/ Just hover over the «More» link. http://joxi.ru/uXHGU_3JTJBkDpt35Iw So I tried to do something like this, but I have only this variant http://jsfiddle.net/TY8CQ/ Code: HTML
body < padding: 100px; background: #f6f6f6; >a < display: block; width: 200px; position: relative; background: #fff; height: 40px; font: 14px/40px Tahoma; color: #39adf0; text-decoration: none; -webkit-transition: 0.2s; margin: auto; text-align: center; position: relative; >a:after < content: ''; position: absolute; top: 0; left: 0; width: 0; height: 1px; background: #39adf0; -webkit-transition: 0.2s; -moz-transition: 0.2s; -ms-transition: 0.2s; -o-transition: 0.2s; transition: 0.2s; >a:before < content: ''; position: absolute; top: 0; right: 0; width: 1px; height: 0; background: #39adf0; -webkit-transition: 0.2s; -moz-transition: 0.2s; -ms-transition: 0.2s; -o-transition: 0.2s; transition: 0.2s; >a:hover:after < width: 100%; >a:hover:before
But in the example (in the website) the stroke appears in order and in all sides. How can I do this? CSS3 only? Maybe with jQuery?
Buddy, it’s simple enough, you can get all the source code from the site you mentioned. It’s just a bit finicky and I’m not sure people are gonna help you «lift» someone elses code! Basically you’re on the wrong track in anycase as the effect you want to replicate consists of 4 elements not 2. Use your web-inspectory/firebug to investigate and see what happens on ‘hover’ in the CSS
Have you tried inspecting the element? There’s 3 spans inside that link, one with text, and two with borders, which get transformed with transitions. It’s more complex than your try, but it’s all there for everyone to analyze.
45 CSS Border Animations
Collection of hand-picked free HTML and CSS border animation code examples from Codepen, Github and other resources. Update of June 2021 collection. 13 new examples.
Related Articles
Author
Links
Made with
About a code
Animated Border Gradient
Compatible browsers: Chrome, Edge, Opera, Safari
Author
Links
Made with
About a code
Rotating Border Animation
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Transparent Inner Border with Hover Effect
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Zig-Zag Border & Cool Hover Effect
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
CSS Only Cool Hover Effect
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Border Gradient Hover Effect
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Fancy Border on Hover
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Fancy Border on Hover
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
CSS Only Border Hover Effect
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Framed on Hover
CSS only framed div on hover.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Fancy Border Radius CSS
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Houdini Gradient Border Animation
Compatible browsers: Chrome, Edge, Opera, Safari
Author
Links
Made with
About a code
Framed
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Input with Gradient-Border — Dark
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Dashed Border Icon Animations
CSS icon animations success, warning and danger. Simple and clean icon animations.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Fancy Animated Rainbow Border
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Magic Border Mixin
Magic border on hover, two styles: standard border and mask border (allows gradients etc).
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Gradient Border
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Fancy Border Radius
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
CSS Border
Animated CSS border (using an SVG).
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Rotating Border
Rainbow rotating border in HTML and CSS.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
Gold Border Shimmer
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Animating border-radius
mix-blend-mode : luminosity & animating border-radius on CSS. Resize the container to see how the color of the shapes and text in the block changes.
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About the code
Border Animation
Border animation using clip-path .
Compatible browsers: Chrome, Firefox, Opera, Safari
Author
Links
Made with
About a code
CSS Border Animation
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Animating border-radius
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Border Animation CSS
Pure CSS border animation.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Stripe Border
Diagonal stripe border effects in pure CSS.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
CSS Only Border Animation
CSS-only border animation on hover. It needs a solid background in order to work.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Button Border Slide Mixin
A Sass mixin for a link animation where the border slides around the link on hover.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Draw Borders from Center
Draw borders from the center of the box using psudo elements.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Border Composition and Animation
Show staggered border composition without resorting to empty elements and using multiple backgrounds instead.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Border Animation
Attractive CSS border animation.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Border Animation
SVG ellipse border animation.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
CSS Border Hover Transitions
Border hover transitions using CSS.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About a code
CSS Border Transitions
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Animated Border
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Double Border Animation
A border animation in SVG using two lines.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Border Animation
Pure CSS border animation without SVG.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Border-Gradient Mixin
Implementation of border gradient that can be applied to elements with border-radius .
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Border Animation Effect
Border animation effect with SVG and CSS
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
SVG Border Animation
Simple and beautiful SVG border animation.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Animated Border Gradient Effect
I’ve created an animated gradient border using CSS3 gradients and animations. I make changes to the background-position CSS property during animation to give the effect.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
Links
Made with
About the code
Border-Radius Animation
Experiment with border-radius animation.
Compatible browsers: Chrome, Edge, Firefox, Opera, Safari
Author
How to create animated border using css3 or canvas while hover?
I need to create a animated border while hovering .I tried with using css3 but not able to get the perfect solution.
My excepted output:
So i like create a animated border like above image while hovering.Basically i need to draw a border while hovering. Please help any one for achieve this solution. Thanks in advance.
HI @Zac.Ledyard.Thanks for your response.If you can please share some example code using SVG. Sorry am new to SVG.
Here is an example of what I mean. You will have to play with the values a bit, but here is a working version: codepen.io/anon/pen/vOEdqj
2 Answers 2
You could do this with SVG though I don’t think this is possible with just one shape, but I may be wrong. You can do it with two overlayed . The third example is more similar to your graphics.
svg < width: 125px; height: 125px; transform: rotate(-90deg); >.svg_2, .svg_3 < transform: rotate(-130deg); >/* 377 is roughly the circumference of the circle */ /*. if you change the size you will need to alter this value too*/ .circle < stroke-dasharray: 377; stroke-dashoffset: 377; transition: all 1s ease; >.svg_3 .circle < stroke-dashoffset: 294; >.svg_1:hover .circle < stroke-dashoffset: 0; >.svg_2:hover .circle < stroke-dashoffset: 0; >.svg_3:hover .circle
Here’s how to do it in html canvas:
- Listen for mousemove events and set a flag indicating if the mouse is inside the circle.
- Run an animation loop that draws an increasing arc when hovering and a decreasing arc when bluring.
Here’s example code and a Demo:
var canvas=document.getElementById("canvas"); var ctx=canvas.getContext("2d"); function reOffset() < var BB=canvas.getBoundingClientRect(); offsetX=BB.left; offsetY=BB.top; >var offsetX,offsetY; reOffset(); window.onscroll=function(e) < reOffset(); >var PI=Math.PI; var PI2=PI*2; var sweep=0; var radius=50; var linewidth=10; var hoverState='new'; var isInside=false; // canvas.width=radius*2+linewidth; // canvas.height=radius*2+linewidth; var cw=canvas.width; var ch=canvas.height; var cx=cw/2; var cy=ch/2; ctx.lineWidth=linewidth; ctx.beginPath(); ctx.strokeStyle='black'; ctx.arc(cx,cy,radius,0,PI2); ctx.stroke(); requestAnimationFrame(animate); $("#canvas").mousemove(function(e)); function handleMouseMove(e) < // tell the browser we're handling this event e.preventDefault(); e.stopPropagation(); mouseX=parseInt(e.clientX-offsetX); mouseY=parseInt(e.clientY-offsetY); // Put your mousemove stuff here var dx=mouseX-cx; var dy=mouseY-cy; isInside=dx*dx+dy*dyfunction animate(time) < hoverState=isInside?'hovering':'bluring'; if(hoverState=='hovering')if(hoverState=='bluring') if(sweep>PI2) < hoverState='idle'; sweep=PI2; >if(sweep <0)< hoverState='idle'; sweep=0; >// only redraw when hovering or bluring if(hoverState=='hovering' || hoverState=='bluring') < ctx.clearRect(0,0,cw,ch); // ctx.beginPath(); ctx.strokeStyle='black'; ctx.arc(cx,cy,radius,0,PI2); ctx.stroke(); // ctx.beginPath(); ctx.strokeStyle='green'; ctx.arc(cx,cy,radius,-PI/2,-PI/2+sweep); ctx.stroke(); >requestAnimationFrame(animate); >