这是 HTML:
<div class="gallerybox">
<a href="/CustomContentRetrieve.aspx?ID=398791">
<img alt="" src="/Utilities/image.jpg" width="400" height="400" />
</a>
</div>
这是CSS:
.gallerybox {width:200px;height:200px;overflow:hidden;}
谁能告诉我一种方法来对齐 div.gallery 框内的链接图像中间(垂直)和中心(水平)?也许使用 javascript、jQuery 或者只是简单的 css?
也许像下面这样:
<div class="gallerybox">
<a href="/CustomContentRetrieve.aspx?ID=398791">
<img id="imgUtility" class="galleryImage" alt="" src="/Utilities/ShowThumbnail.aspx?USM=1&W=400&H=400&R=1&Img={tag_image_value}" />" />
</a>
</div>
.gallerybox {
width:200px;
height:200px;
overflow:hidden;
}
<!-- Edit Again -->
<script language="javascript">
window.onload = fixImage;
function fixImage() {
var img = document.getElementById('imgUtility');
var x = img.offsetWidth;
var y = img.offsetHeight;
img.style.left = -(x / 2);
img.style.top = -(y / 2);
}
</script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)