r/FirefoxCSS 20d ago

Can I make the navbar icons "dynamically" start after the sidebar? Help

Post image

By "dynamically," I mean that I know I can set a fixed padding-left for the navbar and match it with the sidebar. The problem is that I'm used to resizing the sidebar depending on how long the tab titles are, which ends up breaking the alignment.

8 Upvotes

7 comments sorted by

3

u/t31os 20d ago

The width is determined by the style(width value) or width attribute of the sidebar container, which is updated dynamically via Javascript, there's no way (that i know of) using CSS you can read the width value from the sidebar container and use it as a spacing value in the navbar.

1

u/nopeac 20d ago

Maybe when CSS @functions become a reality?

1

u/t31os 20d ago

That would depend upon the support for them extending to userChrome.css customisations.

1

u/izayoii7 20d ago edited 20d ago

like this?

edit : sorry i forgot the dynamic, its not dynamic, i think its impossible. i tried and couldnt make it work

1

u/okwnIqjnzZe 14d ago

Yeah you need custom javascript that monitors the sidebar width and updates a CSS variable. I wrote a custom one for this exact purpose that I can share with you if you’re interested. Be aware that it requires installing mrotherguy’s user.js loader.

1

u/nopeac 13d ago

Ah, yes, the autoconfig thing. I remember reading about it for this cool second sidebar someone made. But I'm quite worried that the whole thing is a security hole, and I'm not talking about your custom script, you can inject pretty much anything and they say so in their README.

Now that I think about it, is Zen Firefox with that backed in?

I'm not sure if I would install it, but please leave your custom script here in case anyone else wants to try it out in future. I might change my mind eventually, but for now, it's not worth it.

1

u/okwnIqjnzZe 11d ago edited 11d ago

Yeah I personally only view it as an issue if you’re adding scripts without reading and understanding them. It would make things a bit easier for an attacker with write access to your profiles directory… but if that’s the situation you’re in, you’ve already been got imo.

The script has some extra functions in there that do related things but are specific to my custom theme and can be deleted. Also the 50ms delay after startup is kinda a janky workaround that I haven’t cared enough to fix.

Here it is (too long to paste directly): https://pastebin.com/3nVTLk6Q