未知大小图片在已知容器中的垂直和水平居中等

1.未知大小图片在已知容器中的垂直和水平居中
来自:http://www.loaoao.com/lab/?offset=8&limit=8
HTML代码
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>未知大小图片在已知容器中的垂直和水平居中</title><title>不会自己会动的书 - Beautiful Style « 样式之美 » loaoao.com </title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="KEYWords" content="img,align,vertical-align ,middle,css,xhtml,effect" /><meta name="DEscription" content="未知大小图片的垂直居中,一直是比较头疼的问题,前些天看到forest翻译的解决方式,顺手修改了,嘿嘿。我的写法一直是比较讨厌IE的。这回用IE的空格bug解决IE7的问题。IE5还有小问题,有空再去算IE5的。" /><meta name="author" content="aoao" /><meta content="all" name="robots" /><link rel="start" href="http://www.loaoao.com" title="Home" /><style type="text/css" media="screen"><!--#imgList{width: 650px;margin: 0 auto;} .box{ height:200px; width:200px; border: solid 1px #666; text-align:center; line-height:200px; font-size:12px; float: left; margin-right: 10px; overflow: hidden; } * html .box{ font-size: 180px } *>html body .box{ /*font-size: 195px;*/ font-size: 180px; } *>html body .box img{ /*margin: -45px 0 0;*/ margin: -35px 0 0; } img{ vertical-align:middle; }--> </style></head><body><h1>未知大小图片在已知容器中的垂直和水平居中</h1><p>未知大小图片的垂直居中,一直是比较头疼的问题,前些天看到<a herf="http://www.forest53.com/tutorials/tutorials_show.asp?sortid=1&id=67">forest</a>翻译的解决方式,顺手修改了,嘿嘿。我的写法一直是比较讨厌IE的。。这回用IE的空格bug解决IE7的问题。IE5还有小问题,有空再去算IE5的。</p><div id="imgList"> <div <img src="img1.gif" alt="test" /> </div> <div <img alt="test" src="img2.jpg" /> </div> <div <img alt="test" src="img3.jpg" /> </div></div><p style="clear:both">reference <a href="http://www.forest53.com/tutorials/tutorials_show.asp?sortid=1&lid=67" title="未知大小图片在已知容器中的垂直和水平居中问题">http://www.forest53.com/tutorials/tutorials_show.asp?sortid=1&id=67</a></p><p id="copyright">Copyright © 2006 <a rel="me" href="http://www.loaoao.com/" title="Beautiful Style « 样式之美 » www.loaoao.com">aoao</a> . <a rel="license" href="http://creativecommons.org/licenses/by/2.5/" title="知识共享组织">Some rights reserved</a>.</p><script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> <script type="text/javascript"> _uacct = "UA-600690-2"; urchinTracker();</script></body></html>

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]


2.高宽自适用100%,又有部分高宽固定的例子
来自:http://www.loaoao.com/lab/?offset=8&limit=8

HTML代码
<!-- hi IE,please go to Quirks Mode--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>X-Links 一个高宽自适用100%,又有部分高宽固定的例子</title><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><meta name="KEYWords" content="layout,auto,100,css" /><meta name="DEscription" content="本来是以前一个朋友要做收藏夹让我抄的,live的方式不错...只在一屏显示全部内容,部分内容要固定高宽,所以用了比较垃圾的方式...比如把IE骗进乱七八糟木模式(Quirks Mode)。" /><meta name="author" content="aoao" /><meta content="all" name="robots" /><link rel="stylesheet" href="style/layout.css" type="text/css" media="all" /><style type="text/css"><!--@import url(c_blue.css);*{ padding:0; margin:0; }html {height:100%; max-height:100%; background:#fff; font-size:12px; }body {height:100%; line-height: 1.6em; max-height:100%;overflow: hidden;}h3{ font-size: 14px;}img{ border-style:none;}#header {position:absolute;top:0; left:0; display:block; width:100%; height:80px; z-index: 21;}#footer {position:absolute;bottom:0; left:0; display:block; width:100%; height:60px; z-index: 21;}#innerHeader{ margin:12px 15px; height: 48px; background-color: #efefef;}#innerFooter{ margin:12px 15px;padding:8px;border-width:1px;border-style: solid;}#sortList,#selector {position:absolute;left:15px;width:180px;}#tools,#status,#gird,#pages {position:absolute;left: 200px; right: 15px;}#xbar{position: absolute; top:70px; bottom: 60px; left: 195px;width:5px; cursor: e-resize;}#sortList{top:70px;height:46px;z-index: 19;}#sortList li{}#selector{top:126px; bottom:68px; z-index: 16;}#tools{top:70px; z-index: 15;}#status{top:110px; z-index: 14;}#gird{top:150px; bottom: 102px; z-index: 9;}#pages{bottom: 60px;z-index: 12;}#selector .inner{ height: 100%;}#status .inner,#tools .inner,#pages .inner{line-height:24px; height:24px;}#gird .inner{height: 100%;overflow: auto;}.inner{border-width:1px;border-style: solid;padding:3px;background-color:#fff;overflow:auto;}#sortList .inner{ padding: 0px;}* html #sortList .inner{height:48px}#sortList li{ float: left; width: 100%;}#sortList li a{ line-height: 20px; display: block; padding:3px 0 0px 25px; text-decoration: none; font-weight: bold; font-size: 14px;}.folder a{ background: url(../images/folder.gif) no-repeat 5px 3px; }.tags a{ background: url(../images/tags.gif) no-repeat 5px 3px; }#pages{ text-align: right;}* html #selector{height:100%; top:0; bottom:0; border-top:126px solid #fff; border-bottom:60px solid #fff;}* html #gird{height:100%; top:0; bottom:0; border-top:150px solid #fff; border-bottom:96px solid #fff;}* html #xbar{height:100%; top:0; bottom:0; border-top:70px solid #fff; border-bottom:60px solid #fff;}* html #tools .inner,* html #status .inner,* html #pages .inner{height:34px}--></style></head><body><div id="header"> <div id="innerHeader">一个高宽自适用100%,又有部分高宽固定的例子</div></div> <div id="sortList"> <div <ul> <li href="#">显示文件夹</a></li> <li href="#">显示标签</a></li> </ul> </div> </div> <div id="selector"> <div <h3>您的标签</h3> test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test </div> </div> <div id="xbar"></div> <div id="tools"> <div </div> <div id="status"> <div <div id="gird"> <div Mode)。</p><p>所有主布局的元素都是用position:absolute流出来body后..根据不同浏览器写不同的定位方式<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test<br />test</p> </div></div> <div id="pages"> <div <a href="#"><img src="images/f.gif" /></a> <a href="#"><img src="images/p.gif" /></a> <span>1/1 页</span> <a href="#"><img src="images/n.gif" /></a> <a href="#"><img src="images/e.gif" /></a> </div></div><div id="footer"> <div id="innerFooter">copyright 2006 loaoao.com <script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> <script type="text/javascript"> _uacct = "UA-600690-2"; urchinTracker(); </script></div></div></body></html>

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]


2-1.修改后的
HTML代码
<!-- hi IE,please go to Quirks Mode--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>X-Links 一个高宽自适用100%,又有部分高宽固定的例子</title><meta http-equiv="Content-Type" content="text/html;charset=utf-8" /><meta name="KEYWords" content="layout,auto,100,css" /><meta name="DEscription" content="本来是以前一个朋友要做收藏夹让我抄的,live的方式不错...只在一屏显示全部内容,部分内容要固定高宽,所以用了比较垃圾的方式...比如把IE骗进乱七八糟木模式(Quirks Mode)。" /><meta name="author" content="aoao" /><meta content="all" name="robots" /><link rel="stylesheet" href="style/layout.css" type="text/css" media="all" /><style type="text/css"><!--* { padding:0; margin:0;}html { height:100%; max-height:100%; background:#fff; font-size:12px;}body { height:100%; line-height: 1.6em; max-height:100%; overflow: hidden;}h3 { font-size: 14px;}img { border-style:none;}#header { position:absolute; top:0; left:0; display:block; width:100%; height:80px; z-index: 21;}#footer { position:absolute; bottom:0; left:0; display:block; width:100%; height:60px; z-index: 21;}#innerHeader { margin:12px 15px; height: 48px; background-color: #efefef;}#innerFooter { margin:12px 15px; padding:8px; border-width:1px; border-style: solid; border-top:5px solid}#sortList, #selector { position:absolute; left:15px; width:180px;}#tools, #status, #gird, #pages { position:absolute; left: 15px; right: 15px;}#xbar { position: absolute; top:70px; bottom: 60px; left: 195px; width:5px; cursor: e-resize;}#sortList { top:70px; height:46px; z-index: 19;}#sortList li {}#selector { top:126px; bottom:68px; z-index: 16;}#tools { top:70px; z-index: 15;}#status { top:110px; z-index: 14;}#gird { top:80px; bottom: 80px; z-index: 9;}#pages { bottom: 60px; z-index: 12;}#selector .inner { height: 100%;}#status .inner, #tools .inner, #pages .inner { line-height:24px; height:24px;}#gird .inner { height: 100%; overflow: auto;}.inner { border-width:1px; border-style: solid; padding:3px; background-color:#fff; overflow:auto;}#sortList .inner { padding: 0px;}* html #sortList .inner { height:48px}#sortList li { float: left; width: 100%;}#sortList li a { line-height: 20px; display: block; padding:3px 0 0px 25px; text-decoration: none; font-weight: bold; font-size: 14px;}.folder a { background: url(../images/folder.gif) no-repeat 5px 3px;}.tags a { background: url(../images/tags.gif) no-repeat 5px 3px;}#pages { text-align: right;}* html #selector { height:100%; top:0; bottom:0; border-top:126px solid #fff; border-bottom:60px solid #fff;}* html #gird { height:100%; top:0; bottom:0; border-top:80px solid #fff; border-bottom:80px solid #fff;}* html #xbar { height:100%; top:0; bottom:0; border-top:70px solid #fff; border-bottom:60px solid #fff;}* html #tools .inner, * html #status .inner, * html #pages .inner { height:34px}--></style></head><body><div id="header"> <div id="innerHeader">一个高宽自适用100%,又有部分高宽固定的例子</div></div><div id="gird"> <div <p>本来是以前一个朋友要做收藏夹让我抄的,live的方式不错...只在一屏显示全部内容,部分内容要固定高宽,所以用了比较垃圾的方式...比如把IE骗进乱七八糟木模式(Quirks Mode)。</p> <p>所有主布局的元素都是用position:absolute流出来body后..根据不同浏览器写不同的定位方式 <br /> test<br /> test<br /> test<br /> test<br /> test<br /> test<br /> <br /> </p> </div></div><div id="footer"> <div id="innerFooter">copyright 2006 loaoao.com</div></div></body></html>

[Ctrl+A 全部选择 提示:你可先修改部分代码,再按运行]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值