原创设计 · PhotoShop · AI/CD · Fireworks · AutoCAD · 3DMAX · Flash · 网页教学 · 高精图库 · 笔刷滤镜 · 矢量素材 · 图片素材 · 模板素材 · 会员相册
加入VIP,下载精美素材 · 原创设计欣赏第七期· QQ空间代码 · QQ空间代码 · QQ空间站· 非主流图片 · QQ头像 · 繁体字非主流图片 · QQ个性签名 · QQ空间播放器

2009年最新设计图书素材低价热销
设计优秀作品第九期/新手学习贴
加入VIP,即送3000缘分币,每月500
 下载素材,加入VIP,享受更多权限
发新话题
打印

[Css+Div] CSS让图片垂直居中和底端对齐的代码

CSS让图片垂直居中和底端对齐的代码

来源:网页教学网

本CSS教程提供了两种对齐方式即垂直居中对齐和底端对齐!更多内容请参考本站的CSS视频教程。

CSS使图片垂直居中的代码:
复制内容到剪贴板
代码:
<!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" lang="zh-CN">
<head>
<title>图片垂直居中</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css" media="all">
div,img{margin: 0;padding: 0;border: 0;}#content{width: 303px;height: 404px;background: #F63;color: #000;font: 12px Arial,Helvetica,sans-serif;position: relative;}#content[id]{display: table;position: static;}#middle{position: absolute;left: 0;top: 50%;}#middle[id]{display: table-cell;vertical-align: middle;position: static;}#inner{position: relative;left: 0;top: -50%;}
</style>
</head>
<body>
<div id="content">
<div id="middle">
<div id="inner">垂直居中

<img src="http://www.webjx.com/images/logo.gif" _fcksavedurl="http://www.webjx.com/images/logo.gif" alt="网页教学网logo" title="网页教学网logo" /></div>
</div>
</div>
</body>
</html>
CSS使图片底端对齐的代码:
复制内容到剪贴板
代码:
<!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" lang="zh-CN">
<head>
<title>图片底端对齐</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css" media="all">
div,img{margin: 0;padding: 0;border: 0;}#content{width: 303px;height: 404px;background: #F63;color: #000;font: 12px Arial,Helvetica,sans-serif;position: relative;}#content div{position: absolute;left: 0;bottom: 0;}
</style>
</head>
<body>
<div id="content">
<div>底端对齐

<img src="http://www.webjx.com/images/logo.gif" _fcksavedurl="http://www.webjx.com/images/logo.gif" alt="网页教学网logo" title="网页教学网logo" /></div>
</div>
</body>
</html>




加入论坛VIP,下尽您想要的素材,点击进入!

如果您在做图或者看教程(PHOTOSHOP方面),遇到任何问题请到问题交流区提问,地址:http://www.missyuan.com/forum-41-1.html;我们会在第一时间帮助您解决问题,如果在教程后面跟帖,一律不给予解决!~


TOP

发新话题



关于本站 广告服务 联系我们 版权隐私 合作站点 网站地图 免责申明 管理团队

Powered by Discuz!6.0.0 Copyright © 2008 www.missyuan.com All rights reserved.