5、css学习5(链接、列表)

1、css可以设置链接的四种状态样式。

  • a:link - 正常,未访问过的链接
  • a:visited - 用户已访问过的链接
  • a:hover - 当用户鼠标放在链接上时
  • a:active - 链接被点击的那一刻

2、 a:hover 必须在 a:link 和 a:visited 之后, a:active 必须在 a:hover 之后,需要严格按顺序才能看到效果。

3、text-decoration 属性主要用于删除链接中的下划线。

html 复制代码
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>CSS学习之链接</title>
        <style>
            a:link {color: #000000;text-decoration: none;background-color: #B2FF99;}
            a:visited {color: #00FF00;text-decoration: none;background-color: #FFFF85;}
            a:hover{color: #FF00FF;text-decoration: underline;background-color: #FF704D;}
            a:active{color: #0000FF;text-decoration: underline;background-color: #FF704D;}
        </style>
    </head>
    <body>
        <p><b><a href="/css/" target="_blank">这是一个链接</a></b></p>
        <p><b>注意:</b> a:hover 必须在 a:link 和 a:visited 之后,需要严格按顺序才能看到效果。</p>
        <p><b>注意:</b>a:active 必须在 a:hover 之后。</p>
    </body>
</html>

运行结果:

html 复制代码
<!DOCTYPE html>
<html>
    <head>
        <meta charset="uft-8">
        <title>有序、无序列表</title>
        <style>/*根据类名定义样式*/
            ul.a {list-style-type: circle;}
            ul.b{list-style-type: square;}
            ol.c{list-style-type: upper-roman;}
            ol.d{list-style-type: lower-alpha;}
            ul.cut{
                list-style-type: none;
                margin: 0;
                padding: 0;
            }
        </style>
    </head>

    <body>
        <p>无序列表实例:</p>

        <ul class="a">
            <li>PHP</li>
            <li>JAVA</li>
            <li>PYTHON</li>
        </ul>
        <ul class="b">
            <li>PHP</li>
            <li>JAVA</li>
            <li>python</li>
        </ul>

        <p>有序列表实例:</p>
        <ol class="c">
            <li>PHP</li>
            <li>JAVA</li>
            <li>python</li>
        </ol>
        <ol class="d">
            <li>PHP</li>
            <li>JAVA</li>
            <li>python</li>
        </ol>
        <p>移除列表默认前标:</p>
        <ul class="cut">
            <li>PHP</li>
            <li>JAVA</li>
            <li>python</li>
        </ul>
    </body>
</html>            

运行结果:

相关推荐
春风解人意8 小时前
从零开始学习嵌入式P32----网络基础之TCP
c语言·网络·学习·tcp/ip
传奇开心果编程10 小时前
【Rust入门知识点学与练】第21课:Trait 进阶 Advanced Traits
开发语言·学习·rust
水巷石子10 小时前
备考系统架构设计师第一天
学习·架构·软考·设计·考试
是隼人11 小时前
buuctf-pwn inndy_echo(32位fmt)题解(学习过程持续更新)
c语言·学习·安全·pwn入门·ctf入门
xian_wwq11 小时前
【学习笔记】深度认知系列-第16讲-提示词工程
人工智能·笔记·学习
洛阳纸贵11 小时前
MATLAB-matlab基础知识
学习·算法·matlab
Vcaker12 小时前
Linux学习25-harbor私有仓库部署
linux·运维·学习
留白_12 小时前
【tableau入门学习】5、筛选器、参考线和集
学习·tableau
youm200312 小时前
认识Redis
redis·笔记·学习
里欧跑得慢12 小时前
Flutter主题与样式详解
前端·css·flutter·web