200字范文,内容丰富有趣,生活中的好帮手!
200字范文 > 4种css超链接伪类的作用是什么

4种css超链接伪类的作用是什么

时间:2022-03-10 19:47:12

相关推荐

4种css超链接伪类的作用是什么

web前端|前端问答

css,超链接,伪类

web前端-前端问答

当地门户网站源码,ubuntu安装sdl库,Python爬虫判断重复,php mysql ajax一对一聊天,域名结尾seolzw

因为我们要定义链接样式,所以其中必不可少的就是超级链接中的锚标签–a,锚标签和伪类链接起来书写的方法就是定义链接样式的基础方法,它们的写法如下:

小图标源码下载,ubuntu 改驱动后,爬虫execjs的使用,php pgpool,seo搜索avlzw

a:link,定义正常链接的样式;

易语言使用次数源码,ubuntu如何设置汉语,爬虫时内存不够,php php_zip,常州baidu seolzw

a:visited,定义已访问过链接的样式;

a:hover,定义鼠标悬浮在链接上时的样式;

a:active,定义鼠标点击链接时的样式。

其中::link和:visited只能适用于设置超链接a,:hover和:active则可适用所有元素

:hover 用来表示鼠标移入的状态

:active 用来表示鼠标点击

超链接的伪类没访问过的链接

访问过的链接

/* 没访问过的链接状态 */a:link{ font-size: 20px; color: hotpink;}/* 访问过的链接状态 */a:visited{ color: green;}/* 鼠标移入链接时的状态 */a:hover{ color: rgb(0, 217, 255);}/* 鼠标点击链接时的状态 */a:active{ color: rgb(255, 0, 0);}

注意:只要曾经搜索过都算访问过的,除非清除历史浏览缓存数据。

伪元素

伪元素,页面中一些特殊的并不真实存在的元素,伪元素表示一些特殊的位置。伪元素使用 :: 开头

::first-letter 表示第一个字母

::first-line 表示第一行

::selection 表示选中的内容

::before 元素的开始

::after 元素的最后

注意:

1、因为设置::before和::after没有任何效果,所以::before和::after必须结合content属性来使用。 2、content内添加的内容鼠标无法选中。

3、html中的q标签表示短引用,有增加双引号效果,原理是运用了::before和::after属性,content中加上了双引号,所以q标签的双引号也无法选中。

伪元素

WHERE THERE IS A WILL, THERE IS A WAY

The secret of success (The key to success) is not so much money as a strong will. A great man is one who has a strong will and an indomitable spirit. In other words, if a man does not have a strong will to win (get) the final victory, he will never succeed in his life. He is no more than a failure.It is quite obvious that there is no difficult thing (nothing difficult) in the world. if you make up your mind to do it, you will certainly accomplish your end. That stands to reason.

/* 第一个字母设置像素为50px */::first-letter{ font-size: 50px;}/* 第一行设置绿色 */::first-line{ color: green;}/* 鼠标选中的字体背景设置为橙色 */::selection{ background-color: sandybrown;}/* 元素p内容开始之前添加符号 ☛,结尾添加符号☚,注意该符号鼠标无法被选中*/p::before{ content: "☛";}p::after{ content: "☚";}

(学习视频分享:css视频教学)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。