HTML5,自定义d出对话框怎么设置居中

HTML5,自定义d出对话框怎么设置居中,第1张

<div class="mask"><div class="main">关闭</div></div>

.mask{position:fixedleft:0right:0top:0bottom:0font-size:0text-align:centerbackground:rgba(0,0,0,0.8)}

.mask:after{content:""height:100%}

.mask:after,.main{display:inline-blockvertical-align:middle}

.main{font-size:16px}

<!DOCTYPE html>

<html>

<head>

<title>框</title>

<meta charset="utf-8">

<style type="text/css">

*{

margin: 0px

padding: 0px

}

#ul1>li{

background: #555

color: #fff

float: left

list-style: none

width: 4em

margin: 1em

text-align: center

cursor: pointer

}

.popBox1{

margin: 50px auto

text-align: center

width: 30em

border: 1px solid red

background: rgb(245,230,230)

z-index: 1000

display: none

}

.popBox1 h4{

margin: 2em 0em

}

.popBox1 span{

display: inline-block

width: 4.5em

line-height: 2em

font-weight: bold

color: #fff

margin: 1em 1em

margin-bottom: 3em

font-size: 1em

background: rgb(201,65,65)

border-radius: 5px

cursor: pointer

}

.clear{

clear: both

}

</style>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>

</head>

<body>

<ul id="ul1">

<li>敌法</li>

<li>剑圣</li>

<li>蝮蛇</li>

<li>幻刺</li>

<li>娜迦</li>

<br class="clear"/>

</ul>

<div class="popBox1">

<h4>确定要干掉</h4>

<span onclick="sureDelete(this)">确定</span><span onclick="cancel(this)">取消</span>

</div>

<script type="text/javascript">

$(document).ready(function(){

$("#ul1>li").click(function(){

var txt=$(this).text()

$(".popBox1").children("h4").text('你确定要干掉:'+txt)

$(".popBox1").show()

})

})

function sureDelete(obj){

$(obj).parent().hide()

}

function cancel(obj){

$(obj).parent().hide()

}

</script>

</body>

</html>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7301190.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-04
下一篇 2023-04-04

发表评论

登录后才能评论

评论列表(0条)

保存