css撰写的日志

用标准的CSS定义你的表格样式

原文链接:A CSS styled table version 2

CSS Hack – IE注释篇

IE特有注释格式:

  1. <!--[if *condition IE *version]>contend<![endif]-->

*condition 值说明:

gt: greater than,选择条件版本以上版本,不包含条件版本
lt: less than,选择条件版本以下版本,不包含条件版本
gte: greater than or equal,选择条件版本以上版本,包含条件版本
lte : less than or equal,选择条件版本以下版本,包含条件版本

  1. <!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
  2. <!--[if IE]> 所有的IE可识别 <![endif]-->
  3. <!--[if IE 5.0]> 只有IE5.0可以识别 <![endif]-->
  4. <!--[if IE 5]> 仅IE5.0与IE5.5可以识别 <![endif]-->
  5. <!--[if gt IE 5.0]> IE5.0以及IE5.0以上版本都可以识别 <![endif]-->
  6. <!--[if IE 6]> 仅IE6可识别 <![endif]-->
  7. <!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->
  8. <!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
  9. <!--[if IE 7]> 仅IE7可识别 <![endif]-->
  10. <!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->
  11. <!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->

CSS+JS方法去除点击链接,按钮时出现的虚线框

做前台开发时肯定会遇到使用button,a标签的时候,每次点击相关这些标签的时候,我们会经常看到有一个虚线框出现,从视觉效果来看,有虚线框会很刺眼,形象到用户浏览的视觉中心,所以我们有必要将这个刺眼的虚线框去掉。利用google和百度,整理一下相关的方法,方便以后开发当中使用。
继续阅读 »

Javascript操作css属性的写法

使用js操作css属性和css中的写法不同:

1、对于没有中划线的css属性一般直接使用style.属性名即可;

如:obj.style.margin,obj.style.width,obj.style.left,obj.style.position等。

2、对于含有中划线的css属性,将每个中划线去掉并将每个中划线后的第一个字符换成大写即可;

如:obj.style.marginTop,obj.style.borderLeftWidth,obj.style.zIndex,obj.style.fontFamily等。

这个规律我想大多数的前端开发者也都熟知。对在css中有一个特殊的属性其js使用方法确比较特殊。

因为 float 是javascript的保留字,那怎么在js中书写样式表中的 float 呢?

我们不能直接使用obj.style.float来使用,这样操作是无效的。

其正确的使用方法是为:IE:obj.style.styleFloat,其他浏览器Mozilla(gecko),ff等用 styleFloat:obj.style.cssFloat。

给个例子让大家好理解:

  1. <div onclick="alert(this.style.float);this.style.float='left';alert(this.style.float);">测试1</div>
  2. <div onclick="alert(this.style.float);if(this.style.cssFloat) {this.style.cssFloat='left';}else{this.style.styleFloat='left';}alert(this.style.float);"& gt;测试2</div>

CSS控制DIV层固定在浏览器底部

使用CSS控制DIV层,使这个DIV层一直在浏览器底部,代码如下:

  1. #foot{
  2.   width:100%;
  3.   height:50px;
  4.   position:absolute;
  5.   top:100%;
  6.   margin-top:-50px;
  7.   background:Blue;
  8.   color:white;
  9. }

首先要设置定位为绝对定位,并设置top为100%,当div的height为N数值时,其div层就必须设margin-top为-N值。IE,FF通过测试。