How to associate the percentage width with a great parent?
You can simply associate the width of li with the parent ul , which in turn refers to the grand parent div :
li
ul
div
div{ overflow: hidden; width: 100%; } ul{ width: 1000%; } li{ width: 3%; }
Use javascript:
var g = document.getElementById('grandparent'); var w = g.clientWidth; if (w > 400) w *= .3; var c = document.getElementsByClassName('child'); for (var i=0; i < c.length; i++) { c[i].style.width = w+'px'; }
I have a jsfiddle example .