Hi @JMichaelTX, thanks for supplying all the information necessary to be at my fingertips. That's a pleasant experience.
The situation here is different to the previous post, but thankfully to our benefit. The two div
elements here are defined as so-called flex columns, which are both floating elements that adapt to each other's widths automatically (whereas, the previous post's div
elements were positioned absolutely in space, and had their four edges independently set).
This means, we only have to deal with the single div
element, which is the one you supplied.
You can adjust its width like so:
document.querySelector('div[class=_1Eaxs]').style.width='20%';
and this will set the div
elements to an 80/20 split.
Rather than setting it to 0%
(which leaves a minuscule presence at the right edge of the screen), it's probably more effective and convenient to toggle its visibility (which was one of your thoughts):
document.querySelector('div[class=_1Eaxs]').style.display='none'; // hide
document.querySelector('div[class=_1Eaxs]').style.display=''; // show
So, you may end up choosing to set its width to 50%
—which can remain fixed—and toggle the visibility on/off.
Regarding the left sidebar, it's a nav
element that is positioned absolutely when it comes into being (when the browser window is sufficiently wide). The main panel and the right sidebar then, together, are contained in a div
element also positioned absolutely, and creating a situation that closely resembles the one in the previous post.
But, you may find it easier to hide the nav
element and adjust the left border of the div
that contains the remaining two:
function toggleLeftSidebar(){
lsb=document.querySelector('nav[class=_2q2Gx]'); // left sidebar
mrg=document.querySelector('div[class=fy8Gb]'); // main & right panel group
if (lsb===null) return null;
lsb.style.display!==''
? (lsb.style.display='',mrg.style.left='270px')
: (lsb.style.display='none',mrg.style.left='0px');
}
That toggleLeftSidebar()
function is a quick example merely to show how the left border is adjusted for the main and right panel group. In actual fact, while the toggling works in a given browser width, if you reduce the width of the browser so that the nav
element disappears, the left border of the remaining pair will remain set at whatever it was last set to, which isn't ideal.
But your JavaScript is much better than mine, so you can likely devise a more workable solution than that one.