html - 表单输入显示在图像后面

标签 html css

表单/输入一直显示在 img #iphone 后面。我尝试调整 z-index 并将位置更改为相对位置。 JSfiddle 上的 z-index 是正确的:jsfiddle.net/3uLUj,但在我的站点或本地不正确:evanwknight.com/United-Redesign 谢谢!

<div id="form">
    <form action="index.php" method="post">
       <input type="text" name="name" placeholder="enter first and last name" >
       <br />
       <input type="image" value="Submit" src="submit-1.gif" id="submit"/>
    </form>
</div>
#iphone {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -350px; /* Half the height */
    margin-left: -266px; /* Half the width */
    z-index: -100;
}
#form {
    position: absolute;
    z-index: 9999;
} 
input {
    position: absolute;
    text-align: center;
    font-size: 30px;
    width: 200px;
    border-top: none;
    border-right: none;
    border-left: none;
    border-bottom: 5px solid #cccccc;
    padding: 15px;
    background: rgba(255,255,255,0.5);
    -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    border-radius: 2px; /* future proofing */
    -khtml-border-radius: 2px; /* for old Konqueror browsers */
    z-index: 9999;
}

最佳答案

我查看了您的网站,如果我对您的理解正确的话,您希望表单出现在 iPhone 内部和图像之上。如果是这样,请尝试用这些替换 style.css 文件中的相关样式声明:

#form {
    text-align: center;
    color: #193485;
    font-family: Arial;
}


#iphone {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -350px; /* Half the height */
    margin-left: -266px; /* Half the width */
    z-index: -100;
}

#plain {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -200px; /* Half the height */
    margin-left: -177px; /* Half the width */
    z-index: 100;
}

#form {
    position: absolute;
    z-index: 9999;
    height: 600px;
    width: 354px;
    top: 50%;  left: 50%;  margin-top: -200px;  margin-left: -177px;  
}

input {
    text-align: center;
    font-size: 30px;
    width: 200px;
    border-top: none;
    border-right: none;
    border-left: none;
    border-bottom: 5px solid #cccccc;
    padding: 15px;
    background: rgba(255,255,255,0.5);
    -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    border-radius: 2px; /* future proofing */
    -khtml-border-radius: 2px; /* for old Konqueror browsers */
    z-index: 9999;
}

你可以在这个fiddle 上测试

关于html - 表单输入显示在图像后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18995790/

相关文章:

javascript - 如何在更改幻灯片之前设置延迟?

html - 移动浏览器的文本动画营养问题

javascript - ul li items shuffle random position fade 一个接一个

javascript背景水平/垂直滚动到元素站点:beyond 911

html - 将图像与 1 行内联元素对齐

html/css 列

javascript - 移动时在 div 之后创建虚线 "trail"

javascript - 使图像占据 100% 的高度,但不是 100% 的高度(并在缩小时保持图像相同的尺寸)

c# - 如何在Winform中使用CSS格式化 Crystal 报表?

javascript - div 容器的宽度不同于 100%