標籤:
<body>
<div class="slider">
<ul class="clearfix">
<li><a href="#bg1">Hipster Fashion Haircut </a></li>
<li><a href="#bg2">Cloud Computing Services & Consulting</a></li>
<li><a href="#bg3">My haire is sooo fantastic!</a></li>
<li><a href="#bg4">Eat healthy & 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重要學習經驗