手机
当前位置:查字典教程网 >网页设计 > Div+Css教程 >如何让图片相对于上层DIV始终保持水平、垂直都居中
如何让图片相对于上层DIV始终保持水平、垂直都居中
摘要:使图片相对于上层DIV始终水平、垂直都居中.thumbBox{width:260px;height:260px;text-align:cen...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>使图片相对于上层DIV始终水平、垂直都居中</title>

<style type="text/css">

.thumbBox {width:260px; height:260px; text-align:center; vertical-align:middle; display:table-cell; border:1px solid red;}

</style>

</head>

<body>

使图片相对于上层DIV始终水平、垂直都居中

<p>示例一</p>

<div>

<img src="http://www.baidu.com/img/bdlogo.gif" >

</div>

<p>示例二</p>

<div>

<img src="http://y2.ifengimg.com/mappa/2013/06/03/cb32ecdc7d0def4d123ae4c38c50050b.jpg" >

</div>

</body>

</html>

【如何让图片相对于上层DIV始终保持水平、垂直都居中】相关文章:

CSS line-height行高上下居中垂直居中样式属性

CSS图片垂直居中方法整理集合

css如何设置层透明

任意图片实现垂直居中的三种方法(兼容性还不错)

css中水平垂直居中对齐布局实例总结

CSS制作水平垂直居中对齐 多种方式各有千秋

CSS:使DIV 在浏览器窗口中水平垂直居中

css中元素水平垂直居中4种方法介绍

css实现body背景图片水平垂直居中方法

CSS布局:图片在DIV中上下左右居中(水平和垂直都居中)

精品推荐
分类导航