I have a header that I want to have a border on that slides from right to left on hover, using pure CSS if that's possible.
At the moment, I can get a border that slides from left to right using the following CSS:
#header a:after {
content: '';
display: block;
border-bottom: 3px solid $(header.hover.color);
width: 0;
-webkit-transition: 1s ease;
transition: 1s ease;
}
#header a:hover:after { width: 100%; }
Has anyone a good solution for accomplishing this task?
You can position your :after
element to the right
#header {
position: relative;
}
#header a:after {
content: '';
display: block;
border-bottom: 3px solid red;
width: 0;
position: absolute;
right: 0;
-webkit-transition: 1s ease;
transition: 1s ease;
}
#header a:hover:after {
width: 100%;
}