今天在CSSPLaY淘到了一个不错的效果,可惜IE不支持。越来越觉得IE不爽了!!
-------------------------------css代码---------------------------------
<style type="text/css">
<!--
#change:target {
color: #C00;/*字体颜色:红色*/
}
#wrapper:target {
background: #F0C992;/*背景颜色:土黄*/
}
#inf:target {/*在标题下面添加横线*/
border-bottom: 5px solid #697210;
color: #697210;
padding-bottom: 5px;
}
#inf:target :before {/*在标题前面添加"MY "字符*/
color: #697210;
content: "MY ";
font-size: 1em;
}
#inf:target :after {/*在标题前面添加" PAGE"字符*/
color: #697210;
content: " PAGE";
font-size: 1em;
}
#head:target {/*图片名:back3.gif*/
background: url(back3.gif) #FFFFFF no-repeat 345px 5px;
}
#info li {
line-height: 1.7em;
}
-->
</style>
------------------------------------------------------------------------
-----------------------------html代码---------------------------------
<div id="change">
<div id="wrapper">
<div id="head">
<h2 id="inf">TARGET PRACTISE</h2>
<ol>
<li><a href="#change">改变文字颜色为红色</a></li>
<li><a href="#wrapper">改变背景颜色为土黄</a></li>
<li><a href="#inf">改变标题文字</a></li>
<li><a href="#head">改变标题图片</a></li>
</ol>
</div>
</div>
</div>
------------------------------------------------------------------------
只需要在链接上用锚点就可以实现类似JScript的效果。
这个功能不能在IE和Opera中实现。
今天在网上看到的一个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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>FireFox / Mozilla / Opera / IE 适用</title>
<style type="text/css" by tesion.>
/* CSS v.02 by tesion.
CopyRight: http://www.netjoin.net
Contact: renziweb@hotmail.com
原创表单变色
*/
/*定义全局样式 */
input,select,textarea,div {
font: 12px Arial
/* 此部分为表单和容器的字体定义 */
}
/* 所有表单定义默认 */
input,select,textarea {
border: 1px solid #EFEFEF;
}
/* 利用鼠标事件 :hover 来定义当鼠标经过时样式 */
input:hover,select:hover,textarea:hover {
background: #F0F9FB;
border: 1px solid #1D95C7;
}
/* 由于 :hover 事件只有 Mozilla 支持,因此为方便IE使用 expression 批量定义 */
input,select,textarea {
tesion:expression(onmouseover=function()
{this.style.backgroundColor="#F0F9FB";this.style.border="1px solid #1D95C7"},
onmouseout=function()
{this.style.backgroundColor="#FFFFFF";this.style.border="1px solid #EFEFEF"})
}
/* 如上 */
div {
background: #EFEFEF;
padding: 10px; /* 填充 */
cursor: pointer /* 鼠标 */
}
div:hover {
background: #F0F9FB
}
div {
tesion:expression(onmouseover=function()
{this.style.backgroundColor="#F0F9FB"},
onmouseout=function()
{this.style.backgroundColor="#EFEFEF"})
}
/* 不错吧? */
</style>
</head>
<body>
<p>
<input type="text" size="20" maxlength="16" />
<br />
<select name="select">
</select>
<br />
<textarea name="textarea"></textarea>
</p>
<div>这么简单</div>
</body>
</html>
---------------------------------------------------------------
转自特别的表单定义
[ 2005-07-29 11:04:52 | Author: 一叶千鸟 ]
大部分定义根据项目需求定制,并不适合每个网站,提出一种思路,抛砖引玉。
1,主要兼容MOZ & IE6。好多年不用IE5.x了,而且也没测试环境,工作和自己项目都已不考虑IE5;
2,定义名主要采用单字母识别。主要是自己使用,减少代码,语意描述显然不是很好;
3,大量采用包含选择符增加定义重用,定义写法上重复都为合写,可读性同样不是那么好;
4,链接部分定义适用于触发不换色,只增加下划线;
欢迎提出意见。可能部分定义对兼容有潜在的影响,个人使用不断更新。
语言定义
常被忽略,但我总喜欢加上
@charset "gb2312";
全局宏观定义
html,body标签,以及MOZ的模块兼容
html,body { margin:0 auto; font:12px Arial,Helvetica,sans-serif,宋体; line-height:150%; TEXT-ALIGN:center; overflow-x:hidden; color:#000;}
body>table,body>div { margin-left:auto; margin-right:auto; clear:both;} /* M0Z */
全局微观定义
各容器和表单,主要控制文字、图片
table,div,tr,th,td,ul,li,img,form,h2,h3,h4 { font:12px Arial,Helvetica,sans-serif,宋体; margin:0; padding:0; border:0; color:#000;}
div,td,ul,li,h2,h3,h4 { LIST-STYLE-TYPE: none; word-break:break-all; Width:fixed; text-align:justify; text-justify:inter-ideograph; line-height:150%; border:0;}
input,select,textarea { color:#000; font:12px Arial,Helvetica,sans-serif,宋体;}
全局链接定义
触发出现下划线,链接颜色不变
a { font:12px Arial,Helvetica,sans-serif,宋体; color:#000; text-decoration: none;}
a:hover { text-decoration:underline;}
文字-标题
h2,h2 a { font-size:16px; font-weight:bold;}
h3,h3 a { font-size:14px; font-weight:bold;}
h4,h4 a { font-size:12px; font-weight:bold;}
文字-加粗与下划线
.f_b {}
.fs_b,.f_b * { font-weight:bold;}
.f_u {}
.fs_u,.f_u * { text-decoration:underline;}
文字-链接下划线效果
.a_vl a:link,.a_vl a:visited { text-decoration:underline;}
.a_vl a:hover{ text-decoration:none;} /* 触发无 */
.a_hl a:link,.a_hl a:visited { text-decoration:none;}
.a_hl a:hover{ text-decoration:underline;} /* 触发有 */
.a_nl a:link,.a_nl a:visited { text-decoration:none;}
.a_nl a:hover{ text-decoration:none;} /* 永久无 */
文字-大小
.f_s_10,.f_s_10 * { font-size:10px;}
.f_s_12,.f_s_12 * { font-size:12px;}
.f_s_14,.f_s_14 * { font-size:14px;}
.f_s_16,.f_s_16 * { font-size:16px;}
文字-颜色
.a_c_black,.a_c_black * { color:#000;}
.a_c_gray,.a_c_gray * { color:#666;}
.a_c_white,.a_c_white * { color:#fff;}
.a_c_red,.a_c_red * { color:#f00;}
图片-边框
.b_black {}
.bs_black,.b_black img { border:1px #000 solid;}
.b_gray {}
.bs_gray,.b_gray img { border:1px #999 solid;}
.b_white {}
.bs_white,.b_white img { border:1px #fff solid;}
图片-通栏广告
常用宽度通栏,包含纵向外补丁,兼容MOZ
.ban,.ban_white,.ban_black { width:760px;}
.ban img { margin:5px auto;}
.ban_white img { margin:5px auto; border:1px #fff solid;}
.ban_black img { margin:5px auto; border:1px #000 solid;}
列表-行高
.l_16,.l_16 * { line-height:16px;}
.l_18,.l_18 * { line-height:18px;}
.l_20,.l_20 * { line-height:20px;}
.l_22,.l_22 * { line-height:22px;}
.l_24,.l_24 * { line-height:24px;}
.l_26,.l_26 * { line-height:26px;}
.l_28,.l_28 * { line-height:28px;}
.l_30,.l_30 * { line-height:30px;}
列表-高度
.l_h_18,.l_h_18 * { height:18px;}
.l_h_20,.l_h_20 * { height:20px;}
.l_h_22,.l_h_22 * { height:22px;}
列表-单元格宽
.l_t_20 {}
.l_t_20 td { width:20%;}
.l_t_25 {}
.l_t_25 td { width:25%;}
列表-补丁
列表的横向内补丁
.l_p_5 {}
.l_p_5 * { padding-left: 5px;padding-right: 5px;}
.l_pr_5 {}
.l_pr_5 * { padding-right: 5px;}
浮动-位置,偏移,对齐
组合定义,控制位置左中右,控制左右浮动列表,单元格居顶,图片、表单的横向对齐
.t_l,.t_l * { text-align:left;}
.t_c,.t_c * { text-align:center;}
.t_r,.t_r *,.f_la,.f_lb,.f_ld,.f_ls { text-align:right;}
.f_l,.f_la a,.f_lb b,.f_ld div,.f_ls span { float:left;} /* f_la f_lb f_ld f_ls */
.f_r { float:right;}
.v_t { vertical-align:top;}
.v_m,.v_m_o,.v_m_o * { vertical-align:middle;}
间隔-内补丁
常用内补丁组合定义
.p_5 { padding: 5px;}
.p_t_5 { padding-top: 5px;}
.p_l_5 { padding-left: 5px;}
.p_r_5 { padding-right: 5px;}
.p_ape_5 { padding-top: 5px;padding-bottom: 5px;} /* apeak */
.p_lev_5 { padding-left: 5px;padding-right: 5px;} /* level */
.p_10 { padding: 10px;}
.p_t_10 { padding-top: 10px;}
.p_l_10 { padding-left: 10px;}
.p_r_10 { padding-right: 10px;}
.p_ape_10 { padding-top: 10px;padding-bottom: 10px;} /* apeak */
.p_lev_10 { padding-left: 10px;padding-right: 10px;} /* level */
间隔-外补丁
常用外补丁组合定义
.m_t_5 { margin:5px auto 0 auto;}
.m_a_5 { margin:5px auto;}
兼容
MOZ层自动延伸,清除浮动,MOZ居中
.h_h { height:0; clear:both; overflow:hidden; margin:0 auto;} /* M0Z */
.c_c { clear:both;}
.c_m,.c_l_m,.c_l_m div { margin:0 auto;} /* M0Z */
对容器border四个方向定义不同的颜色,会得到一种边框倾斜效果,叫做“Slants”。通过边框不同值的组合可以得到各种多彩边框,配合底色的组合得到各种多边形。
本例子IE6和FF1.5测试通过。
出处Mozilla,可以参看Mozilla.org网站上随意一个css
不得不承认这是一个好的规范,而且有必要
/* mozilla.org Base Styles
* maintained by fantasai
* (classes defined in the Markup Guide - http://mozilla.org/contribute/writing/markup )
*/
/* Suggested order:
//显示属性
* display
* list-style
* position
* float
* clear
//自身属性
* width
* height
* margin
* padding
* border
* background
//文本属性
* color
* font
* text-decoration
* text-align
* vertical-align
* white-space
* other text
* content
*
*/