I wonder if there is a way in css or even javascript to fill only one part of the border at a time, as if it were an animation in which the border is gradually populated and have control of how much is filled. >
Example:
Theideaistofillinthebordergraduallywitheachactionthattheuserdoes.
Icametoasolutionthanksto@hugocsl
CSS
.btn{display:inline-block;text-align:center;width:100px;height:60px;line-height:60px;text-transform:uppercase;font-family:sans-serif;text-decoration:none;font-size:30px;transition:1.5s;position:relative;border:solid1pxblack;}svg,svgrect{position:absolute;width:100%;height:100%;top:0;left:0;fill:transparent;}#svg#rect{stroke:blue;stroke-width:4;transition:all500ms;stroke-dasharray:320;stroke-dashoffset:320;}
HTML
<ahref="#" class="btn">
<svg id="svg">
<rect id="rect"></rect>
</svg>
Btn
</a>
<br>
<input type="button" value="Mudar" onclick="mudar(start)"/><br/>
Javascript
var dasharray = document.getElementById("svg");
start = 320;
dasharray.style.strokeDasharray = start;
function mudar(start){
var svg = document.getElementById("svg");
var rect = document.getElementById("rect");
this.start = start - 20;
if(this.start < 0){
this.start = 320;
}
svg.style.strokeDashoffset = rect.style.strokeDashoffset = this.start;
};
Whenever there is a user action the border will be filled, I put just the push of a button as an example.