Background-position的用法

<!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>
    <title></title>
    <style type="text/css">
        ul
        {
            width: 300px;
            height: 300px;
            margin: 0px auto;
            padding: 0px;
            overflow: hidden;
            background: transparent url(images/menu_gray.jpg);
        }
        li
        {
            list-style-type: none;
            width: 100px;
            height: 100px;
            float: left;
        }
        li a
        {
            display: block;
            width: 100px;
            height: 100px;
            text-decoration: none;
            background: transparent url(images/menu_color.jpg) no-repeat 500px 500px;
        }
        a#item1:hover
        {
            background-position: 0 0;
        }
        a#item2:hover
        {
            background-position: -100px 0;
        }
        a#item3:hover
        {
            background-position: -200px 0;
        }
        a#item4:hover
        {
            background-position: 0 -100px;
        }
        a#item5:hover
        {
            background-position: -100px -100px;
        }
        a#item6:hover
        {
            background-position: -200px -100px;
        }
        a#item7:hover
        {
            background-position: 0 -200px;
        }
        a#item8:hover
        {
            background-position: -100px -200px;
        }
        a#item9:hover
        {
            background-position: -200px -200px;
        }
    </style>
</head>
<body>
    <ul>
        <li><a id="item1" href="#" title="Item 1"></a></li>
        <li><a id="item2" href="#" title="Item 2"></a></li>
        <li><a id="item3" href="#" title="Item 3"></a></li>
        <li><a id="item4" href="#" title="Item 4"></a></li>
        <li><a id="item5" href="#" title="Item 5"></a></li>
        <li><a id="item6" href="#" title="Item 6"></a></li>
        <li><a id="item7" href="#" title="Item 7"></a></li>
        <li><a id="item8" href="#" title="Item 8"></a></li>
        <li><a id="item9" href="#" title="Item 9"></a></li>
    </ul>
</body>
</html>
情况是这样的,我们希望将一个图片切割为9个部分,每个部分当鼠标滑过的时候,都可以实现单独地变成灰色的效果。
我们有两张图片
2006619215956692 2006619215957116
我们首先需要显示第一张照片,然后当用户将鼠标滑过某一个方块的时候,应该将图片切换为灰色的部分。
image 
image 
由此可见,css是多么强大并且有创造力
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值