【问题标题】:One div in footer interfering with another页脚中的一个 div 干扰另一个
【发布时间】:2012-11-23 05:46:16
【问题描述】:

我在页脚中有以下代码,出于某种原因这部分:

<!-- save -->
        <div id="saveWrapper">  
            <div id="save">  
                <img src="img/save.png" alt="Save Image" width="32" height="32" id="saveButton" title="Save Image" />  
            </div>  
            <div id="textdownload">   
                <img src="img/cancel.png" alt="Cancel" width="32" height="32" id="resetButton" title="Continue Drawing" /> 
                Right click the image to download.  
            </div>  
        </div>

它正在干扰它正下方的这个部分。

        <!-- brush colour options -->
        <input type="radio" name="colour" id="red" value="red" />
        <label for="red"><img src="img/red.png" alt="Red"></label>
        <input type="radio" name="colour" id="green" value="#00ff00" />
        <label for="green"><img src="img/green.png" alt="Green" /></label>
        <input type="radio" name="colour" id="blue" value="blue" />
        <label for="blue"><img src="img/blue.png" alt="Blue" /></label>
        <input type="radio" name="colour" id="black" value="black" />
        <label for="black"><img src="img/black.png" alt="Black" /></label>
        <input type="radio" name="colour" id="white" value="white" />
        <label for="white"><img src="img/white.png" alt="White" /></label>
        <input type="radio" name="colour" id="random" value="random" />
        <label for="random"><img src="img/random.png" alt="Random" /></label>

        <img src="img/spacer.png" width="32" height="32">

        <!-- brush size options -->
        <input type="radio" name="size" id="1" value="1" />
        <label for="1"><img src="img/1p.png" alt="1 Point"></label>
        <input type="radio" name="size" id="2" value="2" />
        <label for="2"><img src="img/2p.png" alt="2 Point" /></label>
        <input type="radio" name="size" id="3" value="3" />
        <label for="3"><img src="img/3p.png" alt="3 Point" /></label>
        <input type="radio" name="size" id="4" value="4" />
        <label for="4"><img src="img/4p.png" alt="4 Point" /></label>
        <input type="radio" name="size" id="10" value="10" />
        <label for="10"><img src="img/10p.png" alt="10 Point" /></label>

        <img src="img/spacer.png" width="32" height="32">

        <!-- clear canvas -->
        <input type="image" id="clear" value="Clear" src="img/clear.png">
        </div>

问题是上面的单选按钮不可点击或选择,我不知道为什么。

这是这两个项目的随附 css:

/* Styling for radio buttons */
.input_hidden {
position: absolute;
left: -9999px;
}

.selected {
background-color: #ccc;
}

#colour label {
display: inline-block;
cursor: pointer;
}

#colour label:hover {
background-color: #efefef;
}

#colour label img {
padding: 3px;

}

/* Footer styling */
footer{
background-color: #323232;
bottom: 0;
box-shadow: 0 -1px 20px rgba(0,0,0,0.4);
height: 42px;
left: 0;
position: fixed;
width: 100%;
z-index: 100000;
}

#saveWrapper { 
position: absolute;
 }  

#saveButton {  
float: right;  
margin-left: 590px;
margin-top: 5px;  
position: relative;  
z-index: 9999;  
cursor: pointer;  
overflow: hidden;  
}  

#textdownload {  
display: none;  
position: absolute;  
font-family: Verdana, Geneva, sans-serif;  
color: #FFFFFF;  
font-size: 12px;  
float: right;  
margin-top: 5px;  
margin-left: 630px;  
width: 300px;  
overflow: hidden;  
}

如果我删除页脚外的第一个代码 sn-p 单选按钮可以正常工作吗?

任何帮助表示赞赏!

【问题讨论】:

    标签: html css radio-button footer


    【解决方案1】:

    试试这个添加 z-index:-1;

    #saveWrapper { 
      z-index:-1;
     } 
    

    Live demo

    ------------

    或者 第二个选项是

    在您的按钮中添加一个 div

    并像这样定义z-index

    CSS

    #saveWrapper { 
          z-index:1;
         }
        .form_bt{
        position:relative;
          z-index:2;
        }
    

    HTML

    <!-- save -->
            <div id="saveWrapper">  
                <div id="save">  
                    <img src="img/save.png" alt="Save Image" width="32" height="32" id="saveButton" title="Save Image" />  
                </div>  
                <div id="textdownload">   
                    <img src="img/cancel.png" alt="Cancel" width="32" height="32" id="resetButton" title="Continue Drawing" /> 
                    Right click the image to download.  
                </div>  
            </div>
    
    
    <div class="form_bt"> <!-- brush colour options -->
            <input type="radio" name="colour" id="red" value="red" />
            <label for="red"><img src="img/red.png" alt="Red"></label>
            <input type="radio" name="colour" id="green" value="#00ff00" />
            <label for="green"><img src="img/green.png" alt="Green" /></label>
            <input type="radio" name="colour" id="blue" value="blue" />
            <label for="blue"><img src="img/blue.png" alt="Blue" /></label>
            <input type="radio" name="colour" id="black" value="black" />
            <label for="black"><img src="img/black.png" alt="Black" /></label>
            <input type="radio" name="colour" id="white" value="white" />
            <label for="white"><img src="img/white.png" alt="White" /></label>
            <input type="radio" name="colour" id="random" value="random" />
            <label for="random"><img src="img/random.png" alt="Random" /></label>
    
            <img src="img/spacer.png" width="32" height="32">
    
            <!-- brush size options -->
            <input type="radio" name="size" id="1" value="1" />
            <label for="1"><img src="img/1p.png" alt="1 Point"></label>
            <input type="radio" name="size" id="2" value="2" />
            <label for="2"><img src="img/2p.png" alt="2 Point" /></label>
            <input type="radio" name="size" id="3" value="3" />
            <label for="3"><img src="img/3p.png" alt="3 Point" /></label>
            <input type="radio" name="size" id="4" value="4" />
            <label for="4"><img src="img/4p.png" alt="4 Point" /></label>
            <input type="radio" name="size" id="10" value="10" />
            <label for="10"><img src="img/10p.png" alt="10 Point" /></label>
    
            <img src="img/spacer.png" width="32" height="32">
    
            <!-- clear canvas -->
            <input type="image" id="clear" value="Clear" src="img/clear.png">
    
              </div>
    

    Demo for this

    【讨论】:

    • 嗨,谢谢你做得很好。但只有一个问题。我有一些简单的javascript,通过点击保存/取消现在不触发的图像来显示和隐藏其中一个div?它仅在 z-index 为正时触发
    • 答案中的第二个选项不需要负 z-index。你可以使用它。
    猜你喜欢
    • 1970-01-01
    • 2013-09-13
    • 1970-01-01
    • 2018-08-25
    • 1970-01-01
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多