css

CSS HACK 整理

HACK1 #example {

margin:5px!important/* for Firefox */

margin:10px/* for IE6 */

margin /**/:11px/* for IE5 */

}

*+
html #example{margin:15px!important; }/* for IE7 */

说明:!important声明可以提升指定样式规则的应用优先权。上面“for Firefox” 有“!important”,“for IE7” 也要加“!important”,否则实际出来后IE7依然使用第一个maring值5px。
HACK2 #example {margin:5px; }/* for Firefox */

html #example {margin:10px;} /* for IE6 */

*+html #abc{margin:15px!important;} /* for IE7 */

说明:“for IE7”要加“!important”,“+html”能被ie7与ie5.01所识别,但ie5.01不识别important,所以*+html 再加!important 才只能被ie7识别。
HACK3 #example {

margin:5px/* For Firefox */

*margin:10px/* For IE7 & IE6*/

_margin:15px/* For IE6*/

}

说明:这样写css文件无法通过验证,但是代码可以写的比较少。
HACK4:使用IE专用的条件注释 <!--其他浏览器 -->

<
link rel="stylesheet" type="text/css" href="css.css" />

<!--[if 
IE 7]>

<!-- 
适合于IE7 -->

<
link rel="stylesheet" type="text/css" href="ie7.css" />

<![endif]-->

<!--[if 
lte IE 6]>

<!-- 
适合于IE6及以下 -->

<
link rel="stylesheet" type="text/css" href="ie.css" />

<![endif]-->

说明:条件注释的语法:
[*]gt /Greater than/大于/<!--[if gt IE 5.5]>
[*]gte /Greater than or equal to/大于等于/<!--[if gte IE 5.5]>
[*]lt /Less than/小于/<!--[if lt IE 5.5]>
[*]lte /Less than or equal to/小于等于/<!--[if lte IE 5.5]>
[*]! /Note/不等于/<!--[if !IE 5.5]>        
HACK5 example{

margin5px;/*FF*/

>margin10px;/*IE5*/

}

example/*IE5.5 */{

>
/*IE only*/margin15px;/*IE6*/

>/*IE only*/margin /*IE5.5*/20px;

}

说明:“margin”定义的顺序不能改变,即FF-IE5-IE6-IE5.5。对于IE的定义在属性前要加“>”,因为“example/**/{}”这个HACK在FF中可以识别。

Tags: css

CSS实现简单的图片防盗链代码

css中添加以下代码:

/*=========图片防盗链===========*/
img {
 filter:expression(
 this.不能去掉 ? "" :
 (
 (!this.complete) ? "" :
 this.runtimeStyle.filter = ("progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + this.src + "')") +
 String(this.不能去掉 = true).substr(0, 0) +
 (this.src = "http://www.xxx.com/xxx.gif").substr(0, 0)
 )
 );
}

然后随便找个图替换上面的图片路径,就OK了.PS:看源代码图片还是能保存的.

Tags: 盗链 , 代码 , css

显示11px及10px清晰汉字

首先要看过这篇文章:《如何使用11px及10px的清晰汉字》,这篇文章说明要得到11px的最佳效果就必需要用到Mingliu字体,基本上这个字体在所有的Windows机器中都有。

<span style="font-size:11px; font-family:Mingliu;">11px小字体清晰显示的方法</span>

总结:1、字体要用Mingliu。2、编码时要选择范围较广的UTF-8。

Tags: css

CSS 调用外部字体语法

css 调用外部字体语法:
@font-face { font-family : name; src: url ( url ); sRules }
name :  字体名称。任何可能的 font-family 属性的值
url ( url ) :  使用绝对或相对 url 地址指定OpenType字体文件
sRules :  样式表定义

Tags: 字体 , css

CSS裸奔节。。。

4月5号,是Annual css Naked Day,中国就叫“CSS裸奔节”。把CSS去掉一天。。

Tags: css

Total: 13Page 2 of 3‹ Prev123Next ›