Set the size of "one" with respect to "great-grandparent".
div#one {
width: 50%;
height: 20vh;
background-color: tomato;
}
On 27/06/2021 06:52, Andrew Poulos wrote:
Set the size of "one" with respect to "great-grandparent".
Just give it a size in percentage and see what happens.
div#one {
width: 50%;
height: 20vh;
background-color: tomato;
}
On 28/06/2021 4:09 am, ? Good Guy ? wrote:
On 27/06/2021 06:52, Andrew Poulos wrote:
Set the size of "one" with respect to "great-grandparent".
Just give it a size in percentage and see what happens.
div#one {
width: 50%;
height: 20vh;
background-color: tomato;
}
First, doing it that way means the width is set with respect to its
parent and not it's great grand parent. Secondly, using vh for height
bears no relation to the size of the parents(s).
Andrew Poulos
Is there a way to set the width and height of an element with respect to
a great grandparent (or higher) element?
The HTML looks a bit like this:
<body>
<div id="great-grandparent">
<div></div>
<div>
<div>
<div id="one"></div>
</div>
</div>
</div>
</body>
Set the size of "one" with respect to "great-grandparent".
Andrew Poulos
Is there a way to set the width and height of an element with respect toCorrected --
a great grandparent (or higher) element?
The HTML looks a bit like this:
<body>
<div id="great-grandparent">
<div></div>
<div>
<div>
<div id="one"></div>
</div>
</div>
</div>
</body>
Set the size of "one" with respect to "great-grandparent".
Andrew Poulos
First, doing it that way means the width is set with respect to its
parent and not it's great grand parent. Secondly, using vh for height
bears no relation to the size of the parents(s).
#great-grandparent div#one {You could also play with div:nth-child(?) but it can get tricky with
width: 50%;
height: 20vh;
background-color: tomato;
}
On Sun, 27 Jun 2021 15:52:06 +1000, Andrew Poulos <ap_prog@hotmail.com>
wrote in <hfCdnXjhAsaaj0X9nZ2dnUU7-RPNnZ2d@westnet.com.au>:
Is there a way to set the width and height of an element with respect toCorrected --
a great grandparent (or higher) element?
The HTML looks a bit like this:
<body>
<div id="great-grandparent">
<div></div>
<div>
<div>
<div id="one"></div>
</div>
</div>
</div>
</body>
Set the size of "one" with respect to "great-grandparent".
Andrew Poulos
If the grand-parent's width has been set, then
var w = document.getElementById('great-grandparent').style.width ;
var w1 = Number( w.replace(/[^\d]/g, "") ) ; //size
var w2 = w.replace(/\d/g, "") ; //unit
document.getElementById('one').style.width = (w1) * adjustment +w2;
If grand-parent's width has NOT been set, then create an invisible element >with the wanted width inside and use that which does not require all the >above fussing.
The width unit must be physical rather than percentage.
Similarly for height.
Is there a way to set the width and height of an element with respect to
a great grandparent (or higher) element?
The HTML looks a bit like this:
<body>
<div id="great-grandparent">
<div></div>
<div>
<div>
<div id="one"></div>
</div>
</div>
</div>
</body>
Set the size of "one" with respect to "great-grandparent".
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 83:28:56 |
Calls: | 6,658 |
Calls today: | 4 |
Files: | 12,203 |
Messages: | 5,333,525 |
Posted today: | 1 |