首页 | 源码下载 | 网站模板 | 网页特效 | 广告代码 | 网页素材 | 字体下载 | 书库 | 站长工具
会员投稿 投稿指南 RSS订阅
当前位置:主页>设计在线>CSS教程>资讯:最常用的12种CSS BUG解决方法与技巧

最常用的12种CSS BUG解决方法与技巧

www.jz123.cn  2009-11-20   来源:   中国建站    责任编辑(袁袁)    我要投递新闻

  十、图片替换技术

  用文字总比用图片做标题好一些. 文字对屏幕阅读机和SEO都是非常友好的.

  Example Source Code

  HTML:

  <h1><span>Main heading one</span></h1>

  CSS:

  h1 { background: url(heading-image.gif) no-repeat; }

  h1 span {

  position:absolute;

  text-indent: -5000px;

  }

  你可以看到我们对标题使用了标准的<h1>作为标签并且用css来将文本替换为图片. text-indent属性将文字推到了浏览器左边5000px处, 这样对于浏览者来说就看不见了.

  关掉css,然后看看头部会是什么样子的.本文由52CSS.com整理,转载请注明出处!

  十一、 最小宽度

  IE6另外一个bug就是它不支持 min-width 属性. min-width又是相当有用的, 特别是对于弹性模板来说, 它们有一个100%的宽度,min-width 可以告诉浏览器何时就不要再压缩宽度了.

  除IE6以外所有的浏览器你只需要一个 min-width: Xpx; 例如:

  Example Source Code

  .container {

  min-width:300px;

  }

  为了让他在IE6下工作, 我们需要一些额外的工作. 开始的时候我们需要创建两个div, 一个包含另一个:

  Example Source Code

  <div class="container">

  <div class="holder">Content</div>

  </div>

  然后你需要定义外层div的min-width属性,本文由52CSS.com整理,转载请注明出处!

  Example Source Code

  .container {

  min-width:300px;

  }

  这时该是IE hack大显身手的时候了. 你需要包含如下的代码:

  Example Source Code

  * html .container {

  border-right: 300px solid #FFF;

  }

  * html .holder {

  display: inline-block;

  position: relative;

  margin-right: -300px;

  }

  As the browser window is resized the outer div width reduces to suit until it shrinks to the border width, at which point it will not shrink any further. The holder div follows suit and also stops shrinking. The outer div border width becomes the minimum width of the inner div.

  十二、隐藏水平滚动条

  为了避免出现水平滚动条, 在body里加入 overflow-x:hidden .

  Example Source Code

  body { overflow-x: hidden; }

  当你决定使用一个比浏览器窗口大的图片或者flash时, 这个技巧将非常有用

上一篇:纯CSS无图打造圆角Table 下一篇:CSS代码:控制IE滚动条

评论总数:0 [ 查看全部 ] 网友评论


关于我们隐私版权广告服务友情链接联系我们网站地图