讓人不得不佩服的CSS效果

來源:互聯網
上載者:User

作者:eoe
1.尋尋覓覓
先要找個到好效果~才能抄
如http://www.cssplay.co.uk/
http://www.cssbeauty.com
等都能常常看到

今天不小心路過cssplay
http://www.cssplay.co.uk/ menus/magnifier2.html
好像好好玩滴樣子

自己開起topstyle來試一下
建議大家看到好玩的樣式~不要急著看他的CSS~沒意義

2.自己動手~豐衣足食
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>a</title>
<style type="text/css">
ul#hovershow{
list-style-type: none;
margin: 50px;
float: left;
display: inline;
clear: both;
}
ul#hovershow li{
float: left;
display: inline;
width:64px;
height: 64px;
margin: 2px;
}
ul#hovershow li a {
display: block;width:64px;
height: 64px;

}
ul#hovershow li a img{
border:1px #666 solid;
width:100%;
height:100%;

}
ul#hovershow li a:hover{
position: absolute;
z-index:100;
margin: -32px 0 0 -32px;

}
ul#hovershow li a:hover img{
width:128px;
height:128px;
border:1px red solid;

}

</style>
</head>

<body>
<ul id="hovershow">
<li><a href="1#" title="test"><img src="http://www.rotui.net/lab/a/zoom/images/1.jpg" width="128" height="128" alt="test" /></a></li>
<li><a href="2#" title="test"><img src="http://www.rotui.net/lab/a/zoom/images/2.jpg" width="128" height="128" alt="test" /></a></li>
<li><a href="3#" title="test"><img src="http://www.rotui.net/lab/a/zoom/images/3.jpg" width="128" height="128" alt="test" /></a></li>
<li><a href="4#" title="test"><img src="http://www.rotui.net/lab/a/zoom/images/4.jpg" width="128" height="128" alt="test" /></a></li>
<li><a href="5#" title="test"><img src="http://www.rotui.net/lab/a/zoom/images/5.jpg" width="128" height="128" alt="test" /></a></li>
<li><a href="6#" title="test"><img src="http://www.rotui.net/lab/a/zoom/images/6.jpg" width="128" height="128" alt="test" /></a></li>
<li><a href="7#" title="test"><img src="http://www.rotui.net/lab/a/zoom/images/7.jpg" width="128" height="128" alt="test" /></a></li>
</ul>

</body>
</html>
提示:你可以先修改部分代碼再運行

做完自我感覺還不錯~~~

主要就是a:hover position: absolute; margin 三個~
不過做後才發現~IE5的A失效了

3.取找補短
是時候看人家的CSS的~`雖然同樣也是IE5的A失效
#enlarge {padding:0; margin:2em auto; list-style-type:none; width:240px; height:40px;}
#enlarge li {display:block; float:left; width:40px; height:40px; position:relative;}
#enlarge li a {display:block; width:40px; height:40px; background:transparent; overflow:hidden; position:relative;}
#enlarge li a img {width:100%; height:100%; border:0;}
#enlarge li a:hover {position:absolute; left:-20px; top:-20px; width:80px; height:80px; z-index:100;}
提示:你可以先修改部分代碼再運行

FT ~寫得比人家多了一個定義~~
他的方法是用position:relative 配合left top 都是一樣用負值來搞的~

4.舉一反三
突然想到最近要寫的擦車論壇~文章下面的分頁可以用這樣來玩~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>a</title>
<style type="text/css">

ul#hovershow2{
list-style-type: none;
margin: 50px;
width:200px;
float: left;
display: inline;
clear: both;
}
ul#hovershow2 li{
float: left;
display: inline;
width:20px;
height: 20px;
margin: 2px;

}
ul#hovershow2 li a {
text-decoration: none;
display: block;
width:20px;
height:20px;
border:1px red solid;
background-color: White;
line-height: 20px;
font-size: 12px;
text-align: center;
}

ul#hovershow2 li a:hover{
position: absolute;
width:40px;
height: 40px;
line-height: 40px;
font-size: 32px;
z-index:100;
margin: -10px 0 0 -10px;
}

</style>
</head>

<body>

<ul id="hovershow2">
<li><a href="1#" title="test"><span>1</span></a></li>
<li><a href="2#" title="test"><span>2</span></a></li>
<li><a href="3#" title="test"><span>3</span></a></li>
<li><a href="4#" title="test"><span>4</span></a></li>
<li><a href="5#" title="test"><span>5</span></a></li>
<li><a href="6#" title="test"><span>6</span></a></li>
<li><a href="7#" title="test"><span>7</span></a></li>
</ul>

</body>
</html>
提示:你可以先修改部分代碼再運行

好了更好玩~放棄IE了~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>a</title>
<style type="text/css">

ul#hovershow2{
list-style-type: none;
margin: 50px;
width:200px;
float: left;
display: inline;
clear: both;
}
ul#hovershow2 li{
float: left;
display: inline;
width:20px;
height: 20px;
margin: 2px;

}
ul#hovershow2 li a {
text-decoration: none;
display: block;
width:20px;
height:20px;
border:1px red solid;
background-color: White;
line-height: 20px;
font-size: 12px;
text-align: center;
}

ul#hovershow2 li a:hover{
position: absolute;
width:40px;
height: 40px;
line-height: 40px;
font-size: 32px;
z-index:100;
margin: -10px 0 0 -10px;
}
ul#hovershow2 li:hover + li a{
position: absolute;
width:30px;
height: 30px;
line-height: 30px;
font-size: 24px;
z-index:99;
margin: -5px 0 0 -5px;
}

</style>
</head>

<body>

<ul id="hovershow2">
<li><a href="1#" title="test"><span>1</span></a></li>
<li><a href="2#" title="test"><span>2</span></a></li>
<li><a href="3#" title="test"><span>3</span></a></li>
<li><a href="4#" title="test"><span>4</span></a></li>
<li><a href="5#" title="test"><span>5</span></a></li>
<li><a href="6#" title="test"><span>6</span></a></li>
<li><a href="7#" title="test"><span>7</span></a></li>
</ul>

</body>
</html>
提示:你可以先修改部分代碼再運行

效果不是很是很理想
試過把後面的A寬改成到剛好擋到左邊的~可是看不到數字~不好看
也試過一邊用原來的方法
一邊用:after加了圖片在左邊~可是~一邊有數字一邊沒有~更不好看~~又不可能做N張有數位圖片~擴充性不好

也許這就是css本身所限
或許~用JS可以更簡單的解決~````

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.