use*_*460 1 html css click button
我有一个div上的按钮,它位于另一个div后面.第二个div通过使用css重叠第一个div:
position: absolute;
Run Code Online (Sandbox Code Playgroud)
因此该按钮不可点击.有什么方法可以让它像普通按钮一样点击吗?
示例:jsfiddle
HTML:
<div class="stack">
<div class="background" onclick="alert('background clicked');">
<button onclick="alert('bg-button clicked');" style="left:65px; top:65px; position: absolute;">This is a background button</button>
<div class="card">
<button onclick="alert('card-button clicked');">This is a card button</button>
<textarea style="left:100px; top:100px; position: absolute;">This is a card textarea</textarea>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
CSS:
body {
background-color: blue;
}
.stack {
width: 320px;
height: 240px;
position: absolute;
top: 50%;
left: 50%;
background-color: white;
margin-top:-120px;
margin-left:-160px;
}
.background {
width: 320px;
height: 240px;
background-image:url('http://www.userlogos.org/files/logos/ps1d3r/apple-black-i.png');
top:0px;
left:0px;
position: absolute;
}
.card {
pointer-events:none;
width: 320px;
height: 240px;
background-image:url('http://2.bp.blogspot.com/-OIHQM4x8l0U/UEiDLQyiTRI/AAAAAAAAHFs/i1a6rkqQ8tQ/s320/floral+swirl.png');
top:0px;
left:0px;
position: absolute;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7175 次 |
| 最近记录: |