【问题标题】:Positioning a child behind his parent with his a fixed position以固定位置将孩子放在父母身后
【发布时间】:2012-12-21 22:19:50
【问题描述】:

所以这是我的问题,我有一个带有音量按钮的音乐播放器。当我按下音量按钮时,按钮下方会出现一个框。由于我的背景不是平坦的,我想把那个盒子放在背景后面。我尝试使用负 z-index,但没有奏效。你们能帮帮我吗?这是一个链接,音乐播放器在顶部屏幕(位置固定)http://hateittoo.com/?page=shows

PS:目前该网站与谷歌浏览器配合得更好。

【问题讨论】:

    标签: css position z-index fixed


    【解决方案1】:

    移动volume_controls,使其不嵌套在music_player 中。 z-index 不能低于父元素。

    <div id="music_player"><!-- has background image you're trying to hide controls under -->
        ... 
        <div class="content" id="volume_controls" style="display: block;">
            ...
        </div>
    </div>
    

    在没有z-index 的情况下将其隐藏在bg 后面,将volume_controls 元素移动到music_player 上方

    【讨论】:

    • 我想我不会有选择的^^谢谢回答
    【解决方案2】:

    您不能将孩子置于其父母之后。您需要从播放器 div 中取出音量 div,使它们都固定,然后使用 z-index

    【讨论】:

      猜你喜欢
      • 2014-08-27
      • 1970-01-01
      • 1970-01-01
      • 2019-06-20
      • 1970-01-01
      • 2012-12-17
      • 2021-10-17
      • 2022-01-12
      • 1970-01-01
      相关资源
      最近更新 更多