標籤:font idt ast ext otto 切割 ade over ntc
currentColor屬性讓hr和段落相同的顏色:
div {
color: red;
}
hr {
background: currentColor;
/* 一定要設定高度*/
height: 0.1rem;
}
<div>
<p><hr>p裡面的hr標籤不變色<hr></p>
<hr>
</div>
background-origin:padding-box是背景圖片的預設原點,background-position:right 10px bottom 10px;可以讓圖片位移,如果不支援這個屬性,可以這樣background:url() no-repeat right bottom;
記憶border-image類似background,第一個屬性是顏色可以是漸層,第二個是映像地址,第三個是切割位置 第四個是平鋪方式 (預設stretch展開。repeat,round比較常用)
想把一個矩形盒子變成橢圓,只需要設定border-radius:50%;如果是一個正方形就會變成圓
關於border-radius圓角半形的詳細理解:border-radius:50% / 100% 100% 0 0;就相當於border-radius:50% 50% 50% 50% / 100% 100% 0 0;左邊是半徑r1相當於x座標,右邊半徑r2相當於y座標,兩個座標確定一個圓心點,以這個點畫出的圓角可能是四分之一圓(當r1,r2相等時),可能是四分之一的橢圓(r2是r1的二倍時),總結一下就是兩點確定圓角地區,理解的時候可以想象把一個盒子放到了x座標上。
快速記憶半圓角規則:11確定單角,51確定二上,15確定二右
圖片應用半透明遮罩層:
<div class="layer">
<a href="#"><img src="demo.jpg"></a>
</div>
<style type="text/css">
.layer {
background-color:#000;
}
a {
transtion:opacity .5s;
}
a:hover {
opacity: .5;
}
</style>
為某個字元指定特殊的字型樣式:
@font-face {
font-family: Ampersand;
src: local(‘Baskerville-Italic‘),
local(‘GoudyOldStyleT-Italic‘),
local(‘Garamond-Italic‘),
local(‘Palatino-Italic‘);
<!-- 指定使用字型的Unicode碼位,可以是區間 -->
unicode-range: U+26;
}
h1 {
font-family: Ampersand, Helvetica, sans-serif;
}
<!-- 標題中的&符號會應用Ampersand字型,其他文字會應用Helvetica字型 -->
<h1>html & css</h1>
浮動元素的水平置中:
.box {
float: left;
position: relative;
left: 50%;
}
.box p {
float: right;
position: relative;
right: 50%;
}
<div class="box">
<p>我是浮動的</p>
<p>浮動置中</p>
</div>
進階選取器的組合使用:
這個選取器選中li為n的所有清單項目
li:first-child:nth-last-child(n),
li:first-child:nth-last-child(n)~li{}
這個選取器選中li大於4的所有清單項目
li:first-child:nth-last-child(n+4),
li:first-child:nth-last-child(n+4)~li{}
這個選取器選中li最大為4的所有清單項目
li:first-child:nth-last-child(-n+4),
li:first-child:nth-last-child(-n+4)~li{}
這個選取器選中li為2到6個的所有清單項目
li:first-child:nth-last-child(n+2):nth-last-child(-n+6),
li:first-child:nth-last-child(n+2):nth-last-child(-n+6)~li{}
頁尾固定到底部的解決方案
<header>這是頭部</header>
<main>這是主要區域</main>
<footer>這是頁尾</footer>
<style type="text/css">
mian{
min-height:calc(100vh - hh-fh);
box-sizing:border-box;
}
<!-- 另外一種完美的方法 -->
body{
display:flex;
min-height:100vh;
flex-flow:column;
}
main {
flex:1;
}
</style>
頭部和頁尾寬屏布局:
<footer>這是內容地區</footer>
<style type="text/css">
footer {
padding:20px;<!--回退機制-->
width:960px;
padding:20px clac(50% - 960px);
background:#ccc;
}
</style>
css揭秘讀書筆記