css重要學習經驗

來源:互聯網
上載者:User

標籤:

<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重要學習經驗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.