DIV内部图片垂直水平居中例子
2012-10-28 05:00
274 查看
<!--
DIV盒子内部图片垂直水平居中例子
-->
<!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=gb2312" />
<title></title>
<style type="text/css">
.img_v {
/*
IE6 IE7设置
display:block 将元素将显示为块级元素。
position:relative 生成相对定位的元素。
其他浏览器
display:table-cell; 此元素会作为一个表格<td>元素显示。
position:static; 默认值。没有定位。
*/
display:table-cell; *display:block; _display:block;
position:static; *position:relative; _position:relative;
vertical-align:middle;
text-align:center;
overflow:hidden;
width:400px;
height:400px;
border:1px solid #000;
}
.img_v a {
/*
IE6 IE7设置
display:block 将元素将显示为块级元素。
position:absolute; 生成绝对定位的元素。
top:50% 元素的顶部边缘。
left:50% 元素的左部边缘。
其他浏览器
display:table-cell; 此元素会作为一个表格<td>元素显示。
position:static; 默认值。没有定位。
*/
display:table-cell; *display:block; _display:block;
position:static; *position:absolute; _position:absolute;
*top:50%;_top:50%;
left:50%;_left:50%;
width:400px;
}
.img_v img {
/*
IE6 IE7设置
position:relative 生成相对定位的元素。
top:-50% 元素的顶部边缘。
left:-50% 元素的左部边缘。
其他浏览器
position:static 默认值。没有定位。
*/
position:static; *position:relative; _position:relative;
*top:-50%; _top:-50%;
*left:-50%; _left:-50%;
}
</style>
</head>
<body>
<div class="img_v">
<a href="#"><img src="你的图片地址.jpg"></a>
</div>
</body>
</html>
DIV盒子内部图片垂直水平居中例子
-->
<!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=gb2312" />
<title></title>
<style type="text/css">
.img_v {
/*
IE6 IE7设置
display:block 将元素将显示为块级元素。
position:relative 生成相对定位的元素。
其他浏览器
display:table-cell; 此元素会作为一个表格<td>元素显示。
position:static; 默认值。没有定位。
*/
display:table-cell; *display:block; _display:block;
position:static; *position:relative; _position:relative;
vertical-align:middle;
text-align:center;
overflow:hidden;
width:400px;
height:400px;
border:1px solid #000;
}
.img_v a {
/*
IE6 IE7设置
display:block 将元素将显示为块级元素。
position:absolute; 生成绝对定位的元素。
top:50% 元素的顶部边缘。
left:50% 元素的左部边缘。
其他浏览器
display:table-cell; 此元素会作为一个表格<td>元素显示。
position:static; 默认值。没有定位。
*/
display:table-cell; *display:block; _display:block;
position:static; *position:absolute; _position:absolute;
*top:50%;_top:50%;
left:50%;_left:50%;
width:400px;
}
.img_v img {
/*
IE6 IE7设置
position:relative 生成相对定位的元素。
top:-50% 元素的顶部边缘。
left:-50% 元素的左部边缘。
其他浏览器
position:static 默认值。没有定位。
*/
position:static; *position:relative; _position:relative;
*top:-50%; _top:-50%;
*left:-50%; _left:-50%;
}
</style>
</head>
<body>
<div class="img_v">
<a href="#"><img src="你的图片地址.jpg"></a>
</div>
</body>
</html>
相关文章推荐
- div,li内部图片自适应水平垂直居中
- css实现div内图片的垂直、水平居中
- CSS布局:图片在DIV中上下左右居中(水平和垂直都居中)
- 纯CSS实现图片水平垂直居中于DIV(图片未知宽高)
- CSS实现图片水平垂直居中于DIV
- 纯CSS实现图片水平垂直居中于DIV(图片未知宽高)
- 让图片在DIV容器里面水平垂直居中的方法
- 纯css实现未知尺寸图片在DIV中垂直水平居中(超简单)
- 纯CSS设计div内部元素水平垂直居中
- 如何让图片相对于上层DIV始终保持水平、垂直都居中
- div内图片和文字水平垂直居中
- 图片在DIV中水平与垂直居中<转>
- 图片水平垂直居中于DIV(图片未知宽高)
- 纯css实现DIV以及图片水平垂直居中兼容多种浏览器(实现过程)
- div下的图片水平居中和垂直居中
- 我有个DIV层,里面放一张图片,我如何让这张图片水平和垂直方向都居中呢???
- 如何使图片在DIV 中水平垂直居中
- 如何让图片在垂直方向与 div的底部对齐 水平居中
- 关于div中图片水平垂直居中的问题
- table-cell实现未知宽高图片,文本水平垂直居中在div