gembin

OSGi, Eclipse Equinox, ECF, Virgo, Gemini, Apache Felix, Karaf, Aires, Camel, Eclipse RCP

HBase, Hadoop, ZooKeeper, Cassandra

Flex4, AS3, Swiz framework, GraniteDS, BlazeDS etc.

There is nothing that software can't fix. Unfortunately, there is also nothing that software can't completely fuck up. That gap is called talent.

About Me

 

CSS页码效果


不知道网上有没有做成这样的,纯粹是不小心做出来的。
最终效果说明:
页面结构是这样的

<li><a href="#">1</a></li>
最终看到的彩色下划线是根据li的背景色显示出来的
li{background:#f60;}

而鼠标移上去的色彩变化是根据

a:hover{background:#f93}
当然关键的地方在于
li{width:20px;height:20px}

定义li的高度时由于没有定义line-height:20px,所以会造成a标签在显示时下方会留空几个像素。正在由于这个错误,无意中产生了这个效果

请运行下段代码看效果。

以下为源代码 你可先修改部分代码,再测试:
<!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" lang="gb2312">
    
<head>
        
<title></title>
        
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

        
<style type="text/css">
            body
{
                font-size
:62.5%;
            
}
            h1
{
                font-size
:1.4em;
            
}
            h2
{
                clear
:both;
                font-size
:1.2em;
            
}
            #pageClass
{
                clear
:both;
                font-size
:1.2em;
            
}
            #pageClass ul
{
                list-style
:none;
            
}
            #pageClass li
{
                float
:left;
                width
:20px;
                height
:20px;
                line-height
:20px;
                border
:1px solid silver;
                margin
:0 3px;
            
}
            #pageClass a
{
                display
:block;
                text-align
:center;
            
}
            #pageClass a:link,#pageClass a:visited
{
                background
:white;
                text-decoration
: none;
                color
:gray;
            
}
            #pageClass a:hover,#pageClass a:active
{
                text-decoration
: none;
                background
:gray;
                color
:white;
            
}

        
/*第二个效果*/
            #pageClass2
{
                clear
:both;
                font-size
:1.2em;
            
}
            #pageClass2 ul
{
                list-style
:none;
            
}
            #pageClass2 li
{
                float
:left;
                width
:20px;
                height
:20px;
                border
:1px solid silver;
                margin
:0 3px;
            
}
            #pageClass2 a
{
                display
:block;
                text-align
:center;
            
}
            #pageClass2 a:link,#pageClass2 a:visited
{
                background
:white;
                text-decoration
: none;
                color
:gray;
            
}
            #pageClass2 a:hover,#pageClass2 a:active
{
                text-decoration
: none;
                background
:gray;
                color
:white;
                line-height
:14px;
            
}
        
/*第三个效果*/
            #pageClass3
{
                clear
:both;
                font-size
:1.2em;
            
}
            #pageClass3 ul
{
                list-style
:none;
            
}
            #pageClass3 li
{
                float
:left;
                width
:20px;
                height
:20px;
                border
:1px solid silver;
                background
:#f60;
                margin
:0 3px;
            
}
            #pageClass3 a
{
                display
:block;
                text-align
:center;
                line-height
:16px;
            
}
            #pageClass3 a:link,#pageClass3 a:visited
{
                background
:white;
                text-decoration
: none;
                color
:gray;
            
}
            #pageClass3 a:hover,#pageClass3 a:active
{
                text-decoration
: none;
                background
:#f93;
                color
:white;
                line-height
:16px;
                
}
        
</style>
    
</head>

    
<body>
        
<h1>页码效果</h1>
        
<h2>这是我原本想要去做的效果</h2>
        
<div id="pageClass">
            
<ul>
                
<li><href="#3">1</a></li>
                
<li><href="#4">2</a></li>
                
<li><href="#5">3</a></li>
                
<li><href="#6">4</a></li>
                
<li><href="#8">5</a></li>
                
<li><href="#9">6</a></li>
                
<li><href="http://www.iwcn.net/default.asp">7</a></li>
            
</ul>
        
</div>
        
<h2>做完之后成这样了</h2>
        
<div id="pageClass2">
            
<ul>
                
<li><href="#3">1</a></li>
                
<li><href="#4">2</a></li>
                
<li><href="#5">3</a></li>
                
<li><href="#6">4</a></li>
                
<li><href="#8">5</a></li>
                
<li><href="#9">6</a></li>
                
<li><href="http://www.iwcn.net/default.asp">7</a></li>
            
</ul>
        
</div>
        
<h2>改了改成这样了</h2>
        
<div id="pageClass3">
            
<ul>
                
<li><href="#3">1</a></li>
                
<li><href="#4">2</a></li>
                
<li><href="#5">3</a></li>
                
<li><href="#6">4</a></li>
                
<li><href="#8">5</a></li>
                
<li><href="#9">6</a></li>
                
<li><href="">7</a></li>
            
</ul>
        
</div>
    
</body>
</HTML>

posted on 2008-03-26 14:05 gembin 阅读(923) 评论(0)  编辑  收藏 所属分类: HTML


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(6)

随笔分类(440)

随笔档案(378)

文章档案(6)

新闻档案(1)

相册

收藏夹(9)

Adobe

Android

AS3

Blog-Links

Build

Design Pattern

Eclipse

Favorite Links

Flickr

Game Dev

HBase

Identity Management

IT resources

JEE

Language

OpenID

OSGi

SOA

Version Control

最新随笔

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜

free counters