I have an example of an area that fills itself on hover, it is done by widening the :before
pseudo-element from width 0 to width 100%. The problem I am getting is when the :before
element is too narrow its borders won't match those of the parent element, this happens because the borders are rounded, and since circular borders' radii can't be bigger than the smallest of the object's dimensions this is understandable.
This creates a glitch at the beginning of the animation that I don't know how to fix.
I am also trying to find a way to fill the box with a diagonal line instead of the vertical line which is the right border of the pseudo-block, does anyone know a way to do this, ideally with only html and css?
Here's the code I have so far:
http://jsfiddle.net/tchikago/egtLx4re/2/
.fillingBox {
position: relative;
width: 300px;
height: 50px;
background: green;
border-radius: 15px;
}
.fillingBox:before {
content:"";
position: absolute;
background: red;
bottom: 0;
top: 0;
left: 0;
z-index: 1;
border-radius: 15px;
right: 100%;
transition: right 2s;
}
.fillingBox:hover:before {
right: 0;
}
For the following html element
<div class="fillingBox"></div>
Thanks for the help