CSS 相关效果

充分利用CSS伪类实现链接提示




演示效果截图

链接提示

CSS代码

<style type="text/css">
body {font:normal 12px Verdana}
a#tip {position:relative;left:75px; font-weight:bold;}
a#tip:link,a#tip:hover {text-decoration:none;color:#000;display:block}
a#tip span {display:none;text-decoration:none;}
a#tip:visited {color:#000;text-decoration:underline;}
a#tip:hover #tip_info {display:block;border:1px solid #F96;
background:#FFEFEF;padding:10px 20px;position:absolute;
top:0px;left:120px;color:#009933}
</style>

HTML代码

<a id="tip" href="http://www.865171.cn">
鼠标移到上面试试!
<span id="tip_info">www.865171.cn</span>
</a>

三中不同形式的CSS滑动门之选项卡效

演示效果截图

 三中不同形式的CSS滑动门之选项卡效果

CSS代码

<style type="text/css">
<!--
* { margin:0; padding:0; font-size:12px; font-weight:normal; }
.jj { font-weight:bolder!important; }
.box { border-top-color:#c00!important; }
.pr { color:#060!important; }
#tab01 { position:relative; width:336px; height:88px;
padding-top:15px; margin:50px; overflow:hidden; }
#tab01 h3 { position:relative; z-index:2; float:left;
height:14px; padding:0 7px 0 8px; margin-left:-1px;
border-left:solid 1px #ccc; border-right:solid 1px #fff;
text-align:center; background:#fff; cursor:pointer; }
#tab01 h3.up { height:18px; padding:5px 7px 0 7px;
margin:-6px 0 0 0; border:solid #ccc;
border-width:1px 1px 0; color:#c00; }
#tab01 div { display:none; position:absolute; left:0;
top:32px; z-index:1; width:324px; height:54px;
padding:5px; border:solid 1px #ccc; color:#666; }
#tab01 div.up { display:block; }
#tab02 { position:relative; width:200px; margin:50px;
border:solid #ccc; border-width:0 1px 1px; }
#tab02 h4 { height:18px; line-height:18px; border:solid #ccc;
border-width:1px 0; margin-bottom:-1px; text-align:center;
background:#f6f6f6; cursor:pointer; }
#tab02 h4.up { color:#c00; }
#tab02 ol { display:none; height:54px; padding:5px; color:#666; }
#tab02 ol.up { display:block; }
#tab03 { position:relative; width:100px; margin:50px; }
#tab03 h3 { position:relative; z-index:1; height:16px;
padding-top:4px; margin-bottom:-1px; border:solid #ccc;
border-width:1px 0 1px 1px; text-align:center;
font-family:宋体;background:#eee; cursor:pointer; }
#tab03 h3.up { z-index:3; color:#c00; background:#fff; }
#tab03 div.tab { display:none; position:absolute; left:99px;
top:0; z-index:2; width:300px; height:200px; padding:5px;
border:solid 1px #ccc; color:#666; }
#tab03 div.tab.up { display:block; }
-->
</style>

HTML代码

<div id="tab01">
<h3>首页</h3>
<div class="jj"><p>嘿嘿,无视div原始class值。</p></div>
<h3 class="pr">测试</h3>
<div><p>继续无视h3原始class值。</p></div>
<h3>无聊</h3>
<div><p>h3没有值也可以~</p></div>
<h3 class="box">内容</h3>
<div><p>div没有值一样可以~</p></div>
</div>
<h1 style="font-size:16px;padding-left:20px;">www.865171.cn</h1>
<div id="tab02">
<h4>首页</h4>
<ol class="pr"><li>嘿嘿,无视容器原始class值。</li></ol>
<h4 class="box">测试</h4>
<ol><li>继续无视h3原始class值。</li></ol>
<h4>无聊</h4>
<ol><li>h3没有值也可以~</li></ol>
<h4 class="bb">内容</h4>
<ol><li>div没有值一样可以~</li></ol>
</div>
<h1 style="font-size:16px;padding-left:20px;">www.865171.cn</h1>
<div id="tab03">
<h3>首页</h3>
<div class="tab"><p>嘿嘿,无视h3原始class值。</p></div>
<h3>测试</h3>
<div class="tab wushi"><p>继续无视div原始class值。</p></div>
<h3>无聊</h3>
<div class="tab"><p>h3没有值也可以~</p></div>
<h3 class="box">内容</h3>
<div class="tab tab123"><p>class值相似一样也可以~</p><div>
<p>指定class后,即时再多一个div也行。</p></div></div>
</div>

JavaScript代码

<script type="text/javascript">
<!--
function Pid(id,tag){
if(!tag){
return document.getElementById(id);
}
else{
return document.getElementById(id).getElementsByTagName(tag);
}
}
// 选项卡 - [id],[hx=标题],[box=容器标记],
//[iClass=容器样式],[s=事件],[pr=序列]
function tab(id,hx,box,iClass,s,pr){
var hxs=Pid(id,hx);
var boxs=Pid(id,box);
if(!iClass){ // 如果不指定class,则:
boxsClass=boxs; // 直接使用box作为容器
}
else{ // 如果指定class,则:
var boxsClass = [];
for(i=0;i<boxs.length;i++){
if(boxs[i].className.match(//btab/b/)){
// 判断容器的class是否匹配
boxsClass.push(boxs[i]);
}}}
if(!pr){ // 如果不指定预展开容器,则:
go_to(0); // 默认展开序列
yy();}
else {
go_to(pr);
yy();}
function yy(){
for(var i=0;i<hxs.length;i++){
hxs[i].temp=i;
if(!s){// 如果不指定事件,则:
s="onmouseover"; // 使用默认事件
hxs[i][s]=function(){
go_to(this.temp);
}}
else{
hxs[i][s]=function(){
go_to(this.temp);
}}}}
function go_to(pr){
for(var i=0;i<hxs.length;i++){
if(!hxs[i].tmpClass){
hxs[i].tmpClass=hxs[i].className+=" pr1984_com";
boxsClass[i].tmpClass=boxsClass[i].className+=" pr1984_com";
}
if(pr==i){
hxs[i].className+=" up";
// 展开状态:标题
boxsClass[i].className+=" up";
// 展开状态:容器
}
else {
hxs[i].className=hxs[i].tmpClass;
boxsClass[i].className=boxsClass[i].tmpClass;
}}}}
tab("tab01","h3","div","","onclick",2);
// 使用div为容器,指定事件,指定序列。
tab("tab02","h4","ol");
// 使用ol为容器,默认事件,默认序列。
tab("tab03","h3","div","tab");
// 使用div.tab为容器,默认事件,默认序列。
//-->
</script>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值