我正在尝试将覆盖整个图像的 div 居中。我有一个 jQuery 脚本,它假设检查文档的大小(宽度和高度),划分它,并设置 div 的宽度。我认为应该将内容放在页面中间。
<head>
<style type="text/css">
.boxWrapper{
min-width:640px;
min-height:480px;
margin-left:auto;
margin-right:auto;
vertical-align:center;
padding: 15px 10px 10px 30px;
z-index:8;
}
.box {
margin-left:auto;
margin-right:auto;
vertical-align:center;
z-index:8;
}
.blackOut {
position: absolute;
top:0px;
left:0px;
z-index: 5;
width:100%;
height:100%;
background-color: rgba(0,0,0,.8);
}
</style>
</head>
<body bgcolor="#DCDCDC">
<div class="pageWrapper">
<div class="binShadow">
<div class="bin">
<table id="tableBin" border="0">
<tr>
<th>name</th>
<th>description</th>
<th>location</th>
<th>duration</th>
</tr>
<tbody>
<tr>
<td><a href='A001C010_111129_R1VL.mov'>A001C010_111129_R1VL.mov</a></td>
<td>dolor sit amet, consectetur adipiscing elit. Fusce bibendum, leo non.</td>
<td>dr101</td>
<td>:60</td>
</tr>
<tr>
<td><a href="A001C011_111129_R1VL.mov">A001C011_111129_R1VL.mov</a></td>
<td>Lorem ipsum dolor sit amet, consectetur adipiscing elit</td>
<td>dr101</td>
<td>:60</td>
</tr>
</tbody>
</div>
</table>
</div>
</div>
</div>
<script>
$("#tableBin a").on("click", function(e) {
e.preventDefault();
var url = $(this).attr("href");
var overlay = jQuery('<div class="blackOut"><div class="boxWrapper"><div class="box"><video src="'+url+'" /></video></div></div></div>');
var left = "width:"+width($document)/2+"px";
var top = "hieght:"+hieght($document)/2+"px";
$('</span>').text(data).css('width', left).appendTo('#boxWrapper');
$('</span>').text(data).css('height', top).appendTo('#boxWrapper');
overlay.appendTo(document.body);
});
</script>