Skip to content

Instantly share code, notes, and snippets.

@Carnaux
Last active October 10, 2019 20:55
Show Gist options
  • Save Carnaux/1f6cc4a305af3befd9e0b7a972d8bce8 to your computer and use it in GitHub Desktop.
Save Carnaux/1f6cc4a305af3befd9e0b7a972d8bce8 to your computer and use it in GitHub Desktop.
var color = "red";
var per = 0.5;
var els = document.getElementsByClassName("u-s");
for(let i = 0; i < els.length; i++){
var height = els[i].offsetHeight;
var width = els[i].offsetWidth;
let underline = document.createElement('div');
underline.style.width = width * per + "px";
underline.style.height = 3 + "px";
underline.style.backgroundColor = color;
underline.style.position = "relative";
underline.style.left = width/2 - ((width *per)/2) + "px";
underline.style.top = 3 + "px";
els[i].appendChild(underline);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment