为了账号安全,请及时绑定邮箱和手机立即绑定
课程 \ 十天精通CSS3

十天精通CSS3

6-5 CSS3 结构性伪类选择器—target
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>结构性伪类选择器—target</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="menuSection" id="brand">
<h2><a href="#brand">Brand</a></h2>
<p>content for Brand</p>
</div>
</body>
</html>
2015-06-21 查看完整代码
6-6 CSS3 结构性伪类选择器—first-child
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>结构性伪类选择器—first-child</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<ul>
<li><a href="##">Link1</a></li>
<li><a href="##">Link2</a></li>
<li><a href="##">Link3</a></li>
<li><a href="##">Link4</a></li>
<li><a href="##">Link5</a></li>
</ul>
</body>
</html>
2015-06-24 查看完整代码
6-7 CSS3 结构性伪类选择器—last-child
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>结构伪类选择器——last-child</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<ul>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
<li>Item5</li>
<li>Item6</li>
</ul>
</body>
</html>
2015-06-24 查看完整代码
6-8 CSS3 结构性伪类选择器—nth-child(n)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>结构性伪类选择器—nth-child(n)</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<ol>
<li>item1</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
<li>item5</li>
<li>item6</li>
<li>item7</li>
<li>item8</li>
<li>item9</li>
<li>item10</li>
</ol>
</body>
</html>
2015-06-24 查看完整代码
6-9 CSS3 结构性伪类选择器—nth-last-child(n)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>结构性伪类选择器—nth-last-child(n)</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<ol>
<li>item1</li>
<li>item2</li>
<li>item3</li>
<li>item4</li>
<li>item5</li>
<li>item6</li>
<li>item7</li>
<li>item8</li>
<li>item9</li>
<li>item10</li>
</ol>
</body>
</html>
2015-06-24 查看完整代码
6-10 CSS3 first-of-type选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>:first-of-type</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="wrapper">
<p>我是第一个段落</p>
<p>我是第二个段落</p>
<div>我是第一个Div元素</div>
<div>我是第二个Div元素</div>
<p>我是第三个段落</p>
<p>我是第四个段落</p>
<div>我是第三个Div元素</div>
<div>我是第四个Div元素</div>
</div>
</body>
</html>
2015-06-24 查看完整代码
6-11 CSS3 nth-of-type(n)选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="wrapper">
<div>我是一个Div元素</div>
<p>我是一个段落元素</p>
<div>我是一个Div元素</div>
<p>我是一个段落</p>
<div>我是一个Div元素</div>
<p>我是一个段落</p>
<div>我是一个Div元素</div>
<p>我是一个段落</p>
<div>我是一个Div元素</div>
<p>我是一个段落</p>
<div>我是一个Div元素</div>
<p>我是一个段落</p>
<div>我是一个Div元素</div>
<p>我是一个段落</p>
<div>我是一个Div元素</div>
<p>我是一个段落</p>
</div>
</body>
</html>
2015-06-24 查看完整代码
6-12 CSS3 last-of-type选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="wrapper">
<div>我是第一个Div元素</div>
<div>我是第二个Div元素</div>
<div>我是第三个Div元素</div>
<p>我是第一个段落</p>
<p>我是第二个段落</p>
<p>我是第三个段落</p>
</div>
</body>
</html>
2015-06-26 查看完整代码
6-13 CSS3 nth-last-of-type(n)选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>nth-last-of-type(n)</title>
<link type="text/css" href="style.css">
</head>
<body>
<div class="wrapper">
<p>我是第一个段落</p>
<p>我是第二个段落</p>
<div>我是第一个Div元素</div>
<div>我是第二个Div元素</div>
<div>我是第三个Div元素</div>
<p>我是第三个段落</p>
<p>我是第四个段落</p>
<p>我是第五个段落</p>
<div>我是第四个Div元素</div>
<div>我是第五个Div元素</div>
<p>我是第六个段落</p>
</div>
</body>
</html>
2015-06-26 查看完整代码
6-14 CSS3 only-child选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<ul>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
</ul>
<ul>
<li>Item1</li>
</ul>
<ol>
<li>Item1</li>
</ol>
<ol>
<li>Item1</li>
<li>Item2</li>
<li>Item3</li>
</ol>
</body>
</html>
2015-06-27 查看完整代码
6-15 CSS3 only-of-type选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="wrapper">
<p>我是一个段落</p>
<p>我是一个段落</p>
<p>我是一个段落</p>
</div>

<div class="wrapper">
<p>我是一个段落</p>
</div>

<div class="wrapper">
<div>我是一个Div元素</div>
<p>我是一个段落</p>
<div>我是一个Div元素</div>
</div>
</body>
</html>
2015-06-27 查看完整代码
7-1 CSS3选择器 :enabled选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="#">

<div>
<label for="enabled">可用输入框:</label>
<input type="text" id="enabled" />
</div>

<div>
<label for="disabled">禁用输入框:</label>
<input type="text" id="disabled" disabled="disabled" />
</div>

</form>
</body>
</html>
2015-06-28 查看完整代码
7-2 CSS3选择器 :disabled选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="#">
<div><input type="text" /></div>

<div>
<input type="submit" value="我要回到上一步" />
<input type="submit" value="禁止点下一步" disabled />
</div>
</form>
</body>
</html>
2015-06-28 查看完整代码
7-3 CSS3选择器 :checked选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="#">
<div class="wrapper">
<div class="box">
<input type="radio" checked="checked" id="boy" name="1" /><span></span>
</div>
<label for="boy">男</label>
</div>

<div class="wrapper">
<div class="box">
<input type="radio" id="girl" name="1" /><span></span>
</div>
<label for="girl">女</label>
</div>
</form>
</body>
</html>
2015-06-28 查看完整代码
7-4 CSS3选择器 ::selection选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>::selection选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<p>“::selection”伪元素是用来匹配突出显示的文本。浏览器默认情况下,选择网站文本是深蓝的背景,白色的字体,
有的设计要求不使用上图那种浏览器默认的突出文本效果,需要一个与众不同的效果,此时“::selection”伪元素就非常的实用。不过在Firefox浏览器还需要添加前缀。</p>
</body>
</html>
2015-06-28 查看完整代码
7-5 CSS3选择器 :read-only选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="#">
<div>
<label for="name">姓名:</label>
<input type="text" name="name" id="name" placeholder="大漠" />
</div>
<div>
<label for="address">地址:</label>
<input type="text" name="address" id="address" placeholder="中国上海" readonly="readonly" />
</div>
<div>
<label for="comment">评论:</label>
<textarea name="comment" id="" cols="30" rows="10" readonly="readonly"></textarea>
</div>
</form>
</body>
</html>
2015-06-28 查看完整代码
7-6 CSS3选择器 :read-write选择器
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>属性选择器</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<form action="#">
<div>
<label for="name">姓名:</label>
<input type="text" name="name" id="name" placeholder="大漠" />
</div>
<div>
<label for="address">地址:</label>
<input type="text" name="address" id="address" placeholder="中国上海" readonly="readonly" />
</div>
</form>
</body>
</html>
2015-06-28 查看完整代码
7-7 CSS3选择器 ::before和::after
<!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>
2015-06-28 查看完整代码
7-8 切换背景图像综合练习题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS3 Full Background Slider</title>
<style type="text/css">
@importurl("http://www.w3cplus.com/demo/css3/base.css");
@importurl("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: 0;
z-index:1;
-webkit-transform: translateX(0);
-moz-transform: translateX(0);
-o-transform: translateX(0);
-ms-transform: translateX(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; }
}
/*设置背景图像从底部向顶部移入的动画效果*/
/* 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; }
}
/*设置背景图片由小到大放大动画效果*/
/* 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; }
}
/*设置背景图像由大到小缩小动画效果*/
/* 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; }
}
/*背景图像旋转出现动画效果*/
/* 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; }
}
/*设置背景图像不显示动画效果*/
@-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; }
}



.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);
}
/*任务一、设置不同列表的背景色*/
li:nth-of-type(1) a{
background-color: #02646e;
}
li:nth-of-type(2) a{
background-color: #eb0837;
}
li:nth-of-type(3) a{
background-color: #67b374;
}
li:nth-of-type(4) a{
background-color: #e6674a;
}
li:nth-of-type(5) a{
background-color: #e61061;
}
/*任务二、设置缩略图形状*/
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;
}
/*任务三、设置缩略图背景图像*/
li:nth-of-type(1) a::after{
background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg1.jpg) no-repeat center;
}
li:nth-of-type(2) a::after{
background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg2.jpg) no-repeat center;
}
li:nth-of-type(3) a::after{
background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg3.jpg) no-repeat center;
}
li:nth-of-type(4) a::after{
background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg4.jpg) no-repeat center;
}
li:nth-of-type(5) a::after{
background: url(http://www.w3cplus.com/demo/css3/CSS3Fullbackground/sbg5.jpg) no-repeat center;
}
/*任务四、给缩略图添加蒙板效果*/
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);
}
/*任务五、鼠标悬浮时,修改缩略图蒙板透明度*/
a:hover::before{
opacity: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;
}
/*背景图从下向上出现*/
.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;
}
/*背景图由小到大出现*/
.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;
}

/*背景图由大到小出现*/
.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: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 */

.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="bg slideLeft" id="bg1" />
<img src="http://www.w3cplus.com/demo/css3/CSS3Fullbackground/bg2.jpg" alt="" class="bg slideBottom" id="bg2" />
<img src="http://www.w3cplus.com/demo/css3/CSS3Fullbackground/bg3.jpg" alt="" class="bg zoomIn" id="bg3" />
<img src="http://www.w3cplus.com/demo/css3/CSS3Fullbackground/bg4.jpg" alt="" class="bg zoomOut" id="bg4" />
<img src="http://www.w3cplus.com/demo/css3/CSS3Fullbackground/bg5.jpg" alt="" class="bg rotate" id="bg5" />
</body>
</html>
2015-07-23 查看完整代码
8-1 CSS3变形--旋转 rotate()
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>变形与动画</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="wrapper">
<div><span>我不想旋转(^_^)</span></div>
</div>
</body>
</html>
2015-06-28 查看完整代码
意见反馈 帮助中心 APP下载
官方微信