授人以鱼,考人以鱽鱾鲀鱿鲃鲂鲉鲌鲄鲆鲅鲇鲏鲊鲋鲐鲈鲍鲎鲝鲘鲙鲗鲓鲖鲞鲛鲒鲚鲜鲟鲔鲕鲑鲧鲬鲪鲫鲩鲣鲨鲡鲢鲤鲠鲥鲦鲺鲯鲹鲴鲶鲳鲮鲭鲵鲲鲰鲱鲻鲷鲸鳋鳊鳁鳀鲾鲼鳈鳉鳃鳄鲿鳇鳂鳆鳅鲽鳌鳒鳎鳏鳑鳐鳍鳘鳛鳕鳓鳙鳗鳚鳔鳖鳜鳟鳞鳝鳡鳠鳢鳣鳤

代码如下:

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>before、after</title>
<style>
.box h3{
text-align:center;
position:relative;
top:80px;
}
.box {
width:70%;
height:200px;
background:#FFF;
margin:40px auto;
}

.effect{
position:relative;
-webkit-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
-moz-box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
box-shadow:0 1px 4px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 0, 0, 0.1) inset;
}
.effect::before, .effect::after{
content:""; //这里的内容为空
position:absolute;
z-index:-1;
-webkit-box-shadow:0 0 20px rgba(0,0,0,0.8);
-moz-box-shadow:0 0 20px rgba(0,0,0,0.8);
box-shadow:0 0 20px rgba(0,0,0,0.8);
top:50%;
bottom:0;
left:10px;
right:10px;
-moz-border-radius:100px / 10px;
border-radius:100px / 10px;
}
</style>
</head>
<body>
<div class="box effect">
<h3>Shadow Effect </h3>
</div>
</body>
</html>

效果如下:

选择器!!!重点!!!

其中:target是一个目标,表示被选中。在案例中,<a>标签的href值为#bg1、#bg2等,当点击下面的小图标的时候,就会跳到锚点处,那么触发了target事件,就有了动画。

  <!DOCTYPE HTML>
  <html lang="en-US">
  <head>
  <meta charset="UTF-8">
  <title>CSS3 Full Background Slider </title>
  <style type="text/css">
  @import url("http://www.w3cplus.com/demo/css3/base.css");
  @import url("http://fonts.googleapis.com/css?family=Yesteryear");
  html,body {
  height: 100%;
  }
  img.bg {
  min-height: 100%;
  min-width: 1024px;
  width: 100%;
  height: auto !important;
  height: 100%;
  position: fixed;
  top: 0;
  left: 50%;
  z-index:1;
  -webkit-transform: translateX(-50%);
  -moz-transform: translateX(-50%);
  -o-transform: translateX(-50%);
  -ms-transform: translateX(-50%);
  }
  .slider {
  position: absolute;
  width: 100%;
  text-align: center;
  z-index: 9999;
  bottom: 100px;
  }
  .slider li {
  display: inline-block;
  width: 170px;
  height: 130px;
  margin-right: 15px;
  }
  .slider a {
  display: inline-block;
  width: 170px;
  padding-top: 70px;
  padding-bottom: 20px;
  position: relative;
  cursor: pointer;
  border: 2px solid #fff;
  border-radius: 5px;
  vertical-align: top;
  color: #fff;
  text-decoration: none;
  font-size: 22px;
  font-family: 'Yesteryear', cursive;
  text-shadow: -1px -1px 1px rgba(0, 0, 0, 0.8),-2px -2px 1px rgba(0, 0, 0, 0.3),-3px -3px 1px rgba(0, 0, 0, 0.3);
  }
  .slider li:nth-of-type(1) a {
  background-color: #02646e;
  }
  .slider li:nth-of-type(2) a {
  background-color: #eb0837;
  }
  .slider li:nth-of-type(3) a {
  background-color: #67b374;
  }
  .slider li:nth-of-type(4) a {
  background-color: #e6674a;
  }
  .slider li:nth-of-type(5) a {
  background-color: #e61061;
  }
  .slider a::after {
  content:"";
  display: block;
  height: 120px;
  width: 120px;
  border: 5px solid #fff;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  margin-left: -60px;
  z-index: 9999;
  top: -80px;
  }
  .slider li:nth-of-type(1) a::after {
  background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg1.jpg) no-repeat center;
  }
  .slider li:nth-of-type(2) a::after {
  background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg2.jpg) no-repeat center;
  }
  .slider li:nth-of-type(3) a::after {
  background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg3.jpg) no-repeat center;
  }
  .slider li:nth-of-type(4) a::after {
  background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg4.jpg) no-repeat center;
  }
  .slider li:nth-of-type(5) a::after {
  background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg5.jpg) no-repeat center;
  }
  .slider a::before {
  content:"";
  display: block;
  height: 120px;
  width: 120px;
  border: 5px solid #fff;
  border-radius: 50%;
  position: absolute;
  left: 50%;
  margin-left: -60px;
  z-index: 99999;
  top: -80px;
  background: rgba(0,0,0,0.3);
  }
  .slider a:hover::before {
  opacity:0;
  }
  /* Slide Left */
   
  @-webkit-keyframes 'slideLeft' {
  0% { left: -500px; }
  100% { left: 0; }
  }
  @-moz-keyframes 'slideLeft' {
  0% { left: -500px; }
  100% { left: 0; }
  }
  @-o-keyframes 'slideLeft' {
  0% { left: -500px; }
  100% { left: 0; }
  }
  @-ms-keyframes 'slideLeft' {
  0% { left: -500px; }
  100% { left: 0; }
  }
  @keyframes 'slideLeft' {
  0% { left: -500px; }
  100% { left: 0; }
  }
   
  .slideLeft:target {
  z-index: 100;
  -webkit-animation-name: slideLeft;
  -webkit-animation-duration: 1s;
  -webkit-animation-iteration-count: 1;
  -moz-animation-name: slideLeft;
  -moz-animation-duration: 1s;
  -moz-animation-iteration-count: 1;
  -ms-animation-name: slideLeft;
  -ms-animation-duration: 1s;
  -ms-animation-iteration-count: 1;
  -o-animation-name: slideLeft;
  -o-animation-duration: 1s;
  -o-animation-iteration-count: 1;
  animation-name: slideLeft;
  animation-duration: 1s;
  animation-iteration-count: 1;
  }
   
   
  /* Slide Bottom */
   
  @-webkit-keyframes 'slideBottom' {
  0% { top: 350px; }
  100% { top: 0; }
  }
  @-moz-keyframes 'slideBottom' {
  0% { top: 350px; }
  100% { top: 0; }
  }
  @-ms-keyframes 'slideBottom' {
  0% { top: 350px; }
  100% { top: 0; }
  }
  @-o-keyframes 'slideBottom' {
  0% { top: 350px; }
  100% { top: 0; }
  }
  @keyframes 'slideBottom' {
  0% { top: 350px; }
  100% { top: 0; }
  }
   
  .slideBottom:target {
  z-index: 100;
   
  -webkit-animation-name: slideBottom;
  -webkit-animation-duration: 1s;
  -webkit-animation-iteration-count: 1;
  -moz-animation-name: slideBottom;
  -moz-animation-duration: 1s;
  -moz-animation-iteration-count: 1;
  -ms-animation-name: slideBottom;
  -ms-animation-duration: 1s;
  -ms-animation-iteration-count: 1;
  -o-animation-name: slideBottom;
  -o-animation-duration: 1s;
  -o-animation-iteration-count: 1;
  animation-name: slideBottom;
  animation-duration: 1s;
  animation-iteration-count: 1;
  }
   
  /* Zoom In */
   
  @-webkit-keyframes 'zoomIn' {
  0% { -webkit-transform: scale(0.1); }
  100% { -webkit-transform: none; }
  }
  @-moz-keyframes 'zoomIn' {
  0% { -moz-transform: scale(0.1); }
  100% { -moz-transform: none; }
  }
  @-ms-keyframes 'zoomIn' {
  0% { -ms-transform: scale(0.1); }
  100% { -ms-transform: none; }
  }
  @-o-keyframes 'zoomIn' {
  0% { -o-transform: scale(0.1); }
  100% { -o-transform: none; }
  }
  @keyframes 'zoomIn' {
  0% { transform: scale(0.1); }
  100% { transform: none; }
  }
  .zoomIn:target {
  z-index: 100;
  -webkit-animation-name: zoomIn;
  -webkit-animation-duration: 1s;
  -webkit-animation-iteration-count: 1;
  -moz-animation-name: zoomIn;
  -moz-animation-duration: 1s;
  -moz-animation-iteration-count: 1;
  -ms-animation-name: zoomIn;
  -ms-animation-duration: 1s;
  -ms-animation-iteration-count: 1;
  -o-animation-name: zoomIn;
  -o-animation-duration: 1s;
  -o-animation-iteration-count: 1;
  animation-name: zoomIn;
  animation-duration: 1s;
  animation-iteration-count: 1;
  }
   
  /* Zoom Out */
   
  @-webkit-keyframes 'zoomOut' {
  0% { -webkit-transform: scale(2); }
  100% { -webkit-transform: none; }
  }
  @-moz-keyframes 'zoomOut' {
  0% { -moz-transform: scale(2); }
  100% { -moz-transform: none; }
  }
  @-ms-keyframes 'zoomOut' {
  0% { -ms-transform: scale(2); }
  100% { -ms-transform: none; }
  }
  @-o-keyframes 'zoomOut' {
  0% { -o-transform: scale(2); }
  100% { -o-transform: none; }
  }
  @keyframes 'zoomOut' {
  0% { transform: scale(2); }
  100% { transform: none; }
  }
   
  .zoomOut:target {
  z-index: 100;
  -webkit-animation-name: zoomOut;
  -webkit-animation-duration: 1s;
  -webkit-animation-iteration-count: 1;
  -moz-animation-name: zoomOut;
  -moz-animation-duration: 1s;
  -moz-animation-iteration-count: 1;
  -ms-animation-name: zoomOut;
  -ms-animation-duration: 1s;
  -ms-animation-iteration-count: 1;
  -o-animation-name: zoomOut;
  -o-animation-duration: 1s;
  -o-animation-iteration-count: 1;
  animation-name: zoomOut;
  animation-duration: 1s;
  animation-iteration-count: 1;
  }
   
  /* Rotate */
   
  @-webkit-keyframes 'rotate' {
  0% { -webkit-transform: rotate(-360deg) scale(0.1); }
  100% { -webkit-transform: none; }
  }
  @-moz-keyframes 'rotate' {
  0% { -moz-transform: rotate(-360deg) scale(0.1); }
  100% { -moz-transform: none; }
  }
  @-ms-keyframes 'rotate' {
  0% { -ms-transform: rotate(-360deg) scale(0.1); }
  100% { -ms-transform: none; }
  }
  @-o-keyframes 'rotate' {
  0% { -o-transform: rotate(-360deg) scale(0.1); }
  100% { -o-transform: none; }
  }
  @keyframes 'rotate' {
  0% { transform: rotate(-360deg) scale(0.1); }
  100% { transform: none; }
  }
   
  .rotate:target {
  z-index: 100;
  -webkit-animation-name: rotate;
  -webkit-animation-duration: 1s;
  -webkit-animation-iteration-count: 1;
  -moz-animation-name: rotate;
  -moz-animation-duration: 1s;
  -moz-animation-iteration-count: 1;
  -ms-animation-name: rotate;
  -ms-animation-duration: 1s;
  -ms-animation-iteration-count: 1;
  -o-animation-name: rotate;
  -o-animation-duration: 1s;
  -o-animation-iteration-count: 1;
  animation-name: rotate;
  animation-duration: 1s;
  animation-iteration-count: 1;
  }
   
  /* Not Target */
   
  @-webkit-keyframes 'notTarget' {
  0% { z-index: 75; }
  100% { z-index: 75; }
  }
  @-moz-keyframes 'notTarget' {
  0% { z-index: 75; }
  100% { z-index: 75; }
  }
  @-ms-keyframes 'notTarget' {
  0% { z-index: 75; }
  100% { z-index: 75; }
  }
  @-o-keyframes 'notTarget' {
  0% { z-index: 75; }
  100% { z-index: 75; }
  }
  @keyframes 'notTarget' {
  0% { z-index: 75; }
  100% { z-index: 75; }
  }
   
  .bg:not(:target) {
  -webkit-animation-name: notTarget;
  -webkit-animation-duration: 1s;
  -webkit-animation-iteration-count: 1;
  -moz-animation-name: notTarget;
  -moz-animation-duration: 1s;
  -moz-animation-iteration-count: 1;
  -ms-animation-name: notTarget;
  -ms-animation-duration: 1s;
  -ms-animation-iteration-count: 1;
  -o-animation-name: notTarget;
  -o-animation-duration: 1s;
  -o-animation-iteration-count: 1;
  animation-name: notTarget;
  animation-duration: 1s;
  animation-iteration-count: 1;
  }
  </style>
  </head>
  <body>
  <div class="slider">
  <ul class="clearfix">
  <li><a href="#bg1">Hipster Fashion Haircut </a></li>
  <li><a href="#bg2">Cloud Computing Services &amp; Consulting</a></li>
  <li><a href="#bg3">My haire is sooo fantastic!</a></li>
  <li><a href="#bg4">Eat healthy &amp; excersice!</a></li>
  <li><a href="#bg5">Lips so kissable I could die ...</a></li>
  </ul>
  </div>
  <img src="http://www.w3cplus.com/demo/css3/CSS3Fullbackground/bg1.jpg" alt="" class="bgslideLeft" id="bg1" />
  <img src="http://www.w3cplus.com/demo/css3/CSS3Fullbackground/bg2.jpg" alt="" class="bgslideBottom" id="bg2" />
  <img src="http://www.w3cplus.com/demo/css3/CSS3Fullbackground/bg3.jpg" alt="" class="bgzoomIn" id="bg3" />
  <img src="http://www.w3cplus.com/demo/css3/CSS3Fullbackground/bg4.jpg" alt="" class="bgzoomOut" id="bg4" />
  <img src="http://www.w3cplus.com/demo/css3/CSS3Fullbackground/bg5.jpg" alt="" class="bg rotate" id="bg5" />
  </body>
  </html>
   

转载于:https://www.cnblogs.com/yimei/p/7691765.html

用伪类添加翘边阴影::before和::after相关推荐

  1. css使用伪类添加蒙版

    可以使用CSS伪类和背景色来制作蒙版.例如: .masked:before {content: "";display: block;position: absolute;top: ...

  2. html中after后面添加文字,使用CSS3伪类元素(::before|::after)对文字进行美化

    如果要想把一个文字的分成两半分别设置成不同的颜色,你是不是第一时间只想到通过PS来实现呢,不过有一个不好的地方就是图片会占用更多的资源.所以下面就给大家介绍一个通过CSS的伪类元素来美化文字的方法. ...

  3. html5伪类效果延缓,CSS3实现伪类hover离开时平滑过渡效果示例

    由于hover伪类添加的动画效果,仅当鼠标放在元素上时会被触发,而当鼠标离开时,效果会中断,会显得很生硬. 大多数人的想法都是使用js的onmouseover和onmouseleave事件来实现动画效 ...

  4. 使用CSS3伪类元素(::before|::after)对文字进行美化

    如果要想把一个文字的分成两半分别设置成不同的颜色,你是不是第一时间只想到通过PS来实现呢,不过有一个不好的地方就是图片会占用更多的资源.所以下面就给大家介绍一个通过CSS的伪类元素来美化文字的方法. ...

  5. CSS:hover伪类使用

    CSS:hover伪类使用 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 开发工具与关键技术:Adobe Dreamwe ...

  6. 图解CSS伪类和伪元素

    1 简介 伪类和伪元素都属于CSS选择器的附加关键字,在形式上,用单冒号:表示伪类,用双冒号::表示伪元素,如: // 伪类 div:hover {}// 伪元素 div::after {} 注意:由 ...

  7. CSS3 属性选择器 伪类选择器 盒模型 圆角 阴影 CSS定位和浮动

    HTML是网页的裸框架,但是现在已经是2020年了,你再做出一个80年代的网页来,恐怕是没HR要你了.所以学习CSS的重要性可想而知,CSS用途很广,是一门独立的编程语言,能美化网页,也能进一步提高自 ...

  8. CSS 伪类选择器详解:为网页添加交互与美感

    介绍 CSS 伪类选择器是一种非常有用的 CSS 选择器,它能够根据元素的状态.位置或其他属性来选择元素并应用样式.伪类选择器的语法为 :pseudo-class,其中 pseudo-class 是一 ...

  9. html父级添加伪类after,关于伪类after后续追加,实现js事件(如点击事件)

    实现情况为:点击"编辑"后,"编辑"文字变成"完成",再点击伪类元素后的"完成",此时的"完成"应该 ...

最新文章

  1. iOS 中socket的总结
  2. 快速学python爬虫_Python爬虫丨应当如何快速高效学习
  3. NIPS 2018 论文解读集锦(11月28日更新)
  4. python编程从入门到实战类的定义_Python编程:从入门到实践—类
  5. Similar Pairs CodeForces - 1360C(图匹配+简单贪心)
  6. java中u怎么用_Java中interrupt的使用
  7. eclipse导入后将普通项目变为java项目build path,no action avilia
  8. python源码中的学习笔记_第6章_元组
  9. JS获取鼠标的坐标和滚动条的位置
  10. 现代通信原理5.2:带通信号的(复包络)低通表示
  11. 【微信小程序+Python实现人脸识别】
  12. 博图PLC仿真时,CPU一直出于STOP状态,无法启动
  13. ( )可用来更改计算机系统的设置,2018年职称计算机考试考前冲刺练习及答案(9)...
  14. 编程老手的哪些特点,是值得新手程序员学习的?
  15. 80.90后新手开网店,经验分享,神马不见得都是浮云!
  16. 计算机常用术语中英对照
  17. Windows“自动修复”无法修复
  18. 硕士阶段总结《科苑行》之工作习惯
  19. c语言程序设计名片管理系统,《名片管理系统》 - C语言课程设计
  20. JavaScript prototype 使用介绍

热门文章

  1. 苹果iOS App上架流程,非iOS开发人员上架教程
  2. LCD6210字符型液晶显示器 (1)
  3. spring boot 三种类型事物实现说明
  4. Linux学习笔记(3)- 网络编程以及范例程序
  5. 数字模型制作规范(转自Unity3D群)
  6. 利用k8s集群部署第一个容器化应用
  7. MATLAB与数学建模:初阶绘图
  8. 中大近代物理实验实验报告(LaTeX实现)
  9. java砍价源码_(JAVA)仿拼多多砍价算法
  10. 2021-09-26 计科 许佳怡