对齐背景图像中间和中心 [英] Align background image middle and center

查看:184
本文介绍了对齐背景图像中间和中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是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.gallerybox中间(垂直)和中心(horizo​​ntaly)的链接图像?也许使用javascript,jQuery或只是简单的css?

Can anyone tell me a way to align the linked image inside div.gallerybox middle (vertically) and center (horizontaly)? Maybe using javascript, jQuery or just plain css?

推荐答案

尝试:

<style type="text/css">
  .gallerybox {text-align:center;vertical-align:middle;height:400px;line-height:400px;}
  .gallerbox img {display:inline; vertical-align:middle;}
</style>

<div class="gallerybox">
   <a href="/CustomContentRetrieve.aspx?ID=398791">
   <img alt="" src="/Utilities/image.jpg" />
</a>

这篇关于对齐背景图像中间和中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆