伪类是元素不同状态表现的不同样式
伪元素是文档结构中没有出现的元素
1.静态伪类
<!doctype html><html lang="zh"><head><meta charset="UTF-8"><title>test</title><style type="text/css">a:link{/*link:超链接在点击之前样式*/color: deepskyblue;}a:visited{/*visited:超链接在点击之后样式*/color: skyblue;}</style></head><body><a href="#">点击下载</a></body></html>
2.动态伪类
<!doctype html><html lang="zh"><head><meta charset="UTF-8"><title>test</title><style type="text/css">div:hover{/*hover:鼠标放在元素上显示的样式*/color: skyblue;}div:active{/*active:鼠标点击时显示的样式*/color: red;}input:focus{/*focus:输入框获得焦点时的状态*/color: red;}</style></head><body><div>点击下载</div><input type="text" value="请输入....."/></body></html>
3.伪元素
<!doctype html><html lang="zh"><head><meta charset="UTF-8"><title>test</title><style type="text/css">div::first-letter{/*first-letter:选择元素中的第一个文字*/color: red;}div::first-line{/*first-line:选择元素中的第一行文字*/color: skyblue;}div::before{/*before:在元素内容前加入内容*/content: "作者:陶渊明";}div::after{/*after:在元素内容后加入内容*/content: "晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。........";}</style></head><body><div>作品:《桃花源记》<hr /></div></body></html>
