码迷,mamicode.com
首页 > Web开发 > 详细

css重要学习经验

时间:2015-01-06 02:01:28      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

<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>

无css时候:

技术分享

首先在

.slider li {
display: inline-block;   //添加的inline-block使<li>元素成一行
width: 170px;
height: 130px;
margin-right: 15px;
}

技术分享

接着添加

.slider a {
display: inline-block;//行内元素
width: 170px;   
padding-top: 70px;  //填充上边距70px
padding-bottom: 20px;
position: relative;
cursor: pointer;
border: 2px solid #fff;   //外边框
border-radius: 5px;       
vertical-align: top;         //在inline-block行内元素里高对齐
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);                        //阴影
}技术分享

nth-of-type是个很重要的筛选函数

.wrapper > p:nth-of-type(2n){
  background: orange;
}
通过“:nth-of-type(2n)”选择器,将容器“div.wrapper”中偶数段数p的背景设置为橙色

.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;
}

 参照慕课网十天学会css第七节练习题

css重要学习经验

标签:

原文地址:http://www.cnblogs.com/yanz/p/4204926.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!