第七章利用CSS和多媒体美化页面


7.1 CSS链接的美化
通过对超链接的CSS样式设置,来达到理想的视觉效果。


7.1.1.文字链接的美化
为了改变最基本的超链接样式,利用伪类选择器,按照“a: link→a: visited→a: hover→a: active→”的顺序,设置不同的链接访问状态效果,为文本超链接添加复杂而多样的样式。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>示例7.1</title>
        <style type="text/css">
            #manu {
                text-align: center;
            }
            a{
                margin: 10px;
            }
            a:link {
                font-size: 20px;
            }
            a:hover {
                font-size: 18px;
                color: red;
                text-decoration: overline underline;
            }
            a:active {
                font-size: 20px;
                color: green;
                text-decoration: none;
            }
        </style>
    </head>
    <body>
        <div id="manu">
            <h2>服务中心菜单栏</h2>
            <a href="#" target="_blank">加入我们</a>
            <a href="#" target="_blank">媒体报道</a>
            <a href="#" target="_blank">官方微博</a>
            <a href="#" target="_blank">帮助中心</a>
        </div>
    </body>
</html>

7.1.2.按钮链接的美化
为了让链接外观看起来像按钮特效,可以为来链接加上不同的边框阴影和相同的背景颜色加以实现。

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>示例7.2</title>
        <style type="text/css">
            #manu {
                text-align: center;
            }
            a{
                font-size: 20px;
                font-weight: 700;
                text-decoration: none;
                background-color: lightcyan;
                color: red;
                margin: 5px;
                padding: 10px 15px;
                border-radius: 30px;
            }
            a:link,a:visited {
                box-shadow: -5px -5px 10px black;
            }
            a:hover {
                font-size: 26px;
            }
            a:active {
                font-size: 20px;
                box-shadow: 6px 6px 10px black;
            }
        </style>
    </head>
    <body>
        <div id="manu">
            <h2>服务中心菜单栏</h2>
            <a href="#" target="_blank">加入我们</a>
            <a href="#" target="_blank">媒体报道</a>
            <a href="#" target="_blank">官方微博</a>
            <a href="#" target="_blank">帮助中心</a>
        </div>
    </body>
</html>

7.1.3背景链接的美化
设置不同的背景颜色或者背景图片,实现背景链接。

1.设置背景颜色

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>示例7.3</title>
        <style type="text/css">
            #manu {
                text-align: center;
            }
            a{
                font-size: 20px;
                text-decoration: none;
                margin: -3px;
                padding: 10px 15px;
            }
            a:link,a:visited {
                background-color: lightgrey;
                color: red;
            }
            a:hover {
                background-color: brown;
                color: white;
            }
            a:active {
                font-weight: 700;
                color: lawngreen;
            }
        </style>
    </head>
    <body>
        <div id="manu">
            <h2>服务中心菜单栏</h2>
            <a href="#" target="_blank">加入我们</a>
            <a href="#" target="_blank">媒体报道</a>
            <a href="#" target="_blank">官方微博</a>
            <a href="#" target="_blank">帮助中心</a>
        </div>
    </body>
</html>、

7.2 CSS列表的美化
在CSS样式中,主要通过list-style-type、list-style-image、list-style-position这三个属性改变列表修饰符类型

7.2.1.列表项类型(list-style-type)
此属性用来设置或检索对象的列表项所使用的标记类型。


<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8" />
        <title>示例7.3</title>
        <style type="text/css">
            div {
                width: 200px;
                height: 200px;
                border: 1px solid red;
                float: left;
            }
            ol.one{
                l

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值