最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

html - CSS behavior depending on state of another element - Stack Overflow

programmeradmin1浏览0评论

I am editing userchrome.css to customize #navigator-toolbox in Firefox. I want it to be partially hidden when not focused or hovered, and be shown otherwise. It should be partially hidden such that I can hover to it. Moreover, I am on Linux. When I press alt, #toolbar-menubar will show (that bar having File, Edit, View, History buttons).

The CSS hierarchy of #navigator-toolbox is

<toolbox id="navigator-toolbox">
    <toolbar id="toolbar-menubar"></toolbar>
    <toolbar id="TabsToolbar"></toolbar>
    <toolbar id="nav-bar"></toolbar> <!--url bar-->
    ...
</toolbox>

Currently I have the following CSS to hide #navigator-toolbox without considering state of #toolbar-menubar

#TabsToolbar {
  visibility: collapse;
}

#navigator-toolbox:not(:hover):not(:focus-within) {
    margin-top: -36px;
}

The problem with this CSS is that when I press alt, only #nav-bar shows as #toolbar-menubar is now active and pushes #nav-bar down while keeping margin-top: 36px;

Given that when #toolbar-menubar is hidden, inactive="true" attribute is set. When it is shown, the attribute will disappear.

How can I set #navigator-toolbox margin-top: -36px only when it is not hover, not focus within and #toolbar-menubar inactive="true" attribute is set?

I am editing userchrome.css to customize #navigator-toolbox in Firefox. I want it to be partially hidden when not focused or hovered, and be shown otherwise. It should be partially hidden such that I can hover to it. Moreover, I am on Linux. When I press alt, #toolbar-menubar will show (that bar having File, Edit, View, History buttons).

The CSS hierarchy of #navigator-toolbox is

<toolbox id="navigator-toolbox">
    <toolbar id="toolbar-menubar"></toolbar>
    <toolbar id="TabsToolbar"></toolbar>
    <toolbar id="nav-bar"></toolbar> <!--url bar-->
    ...
</toolbox>

Currently I have the following CSS to hide #navigator-toolbox without considering state of #toolbar-menubar

#TabsToolbar {
  visibility: collapse;
}

#navigator-toolbox:not(:hover):not(:focus-within) {
    margin-top: -36px;
}

The problem with this CSS is that when I press alt, only #nav-bar shows as #toolbar-menubar is now active and pushes #nav-bar down while keeping margin-top: 36px;

Given that when #toolbar-menubar is hidden, inactive="true" attribute is set. When it is shown, the attribute will disappear.

How can I set #navigator-toolbox margin-top: -36px only when it is not hover, not focus within and #toolbar-menubar inactive="true" attribute is set?

Share Improve this question asked Feb 8 at 4:10 AustinAustin 414 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

My friend solved it for me

#navigator-toolbox:not(:hover):not(:focus-within):has(#toolbar-menubar[inactive]) {
    margin-top: -36px;
}
发布评论

评论列表(0)

  1. 暂无评论