
css
平時(shí)在工作中遇到一些比較偏門的 css ,用過一兩次,但是老是記不住,于是又需要去 baidu、 google ,所以都積累起來,方便以后查看(持續(xù)更新...) ??
詳情,可查閱我的博客 lishaoy.net
outline 當(dāng)input選中的時(shí)候會(huì)出現(xiàn)一個(gè)邊框
/*一般設(shè)置成 none*/
textarea:focus, input:focus{
outline: none;
}
contenteditable 規(guī)定元素內(nèi)容是否可編輯
<div id="example-one" contenteditable="true">
#example-one {
margin-bottom: 10px;
}
[contenteditable="true"] {
padding: 10px; outline: 2px dashed #CCC;
}
[contenteditable="true"]:hover {
outline: 2px dashed #0090D2;
}
webkit-playsinline video 都可以在頁面中播放,而不是全屏播放
<video id="myvideo" src="test.mp4" webkit-playsinline="true"></video>
clearfix 清除浮動(dòng)
.clearfix {
zoom: 1;
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
user-select 禁止選中文本
p {
-webkit-user-select: none; /* Chrome, Opera, Safari */
-moz-user-select: none; /* Firefox 2+ */
-ms-user-select: none; /* IE 10+ */
user-select: none; /* Standard syntax */
}
webkit-scrollbar 自定義瀏覽器滾動(dòng)條
/*定義滾動(dòng)條寬高及背景,寬高分別對(duì)應(yīng)橫豎滾動(dòng)條的尺寸*/
div::-webkit-scrollbar {
width: 5px;
height: 5px;
background-color: rgba(245, 245, 245, 0.47);
}
/*定義滾動(dòng)條的軌道,內(nèi)陰影及圓角*/
div::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
border-radius: 10px;
background-color: #f5f5f5;
}
/*定義滑塊,內(nèi)陰影及圓角*/
div::-webkit-scrollbar-thumb {
/*width: 10px;*/
height: 20px;
border-radius: 10px;
-webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, .3);
background-color: rgba(85, 85, 85, 0.25);
}
webkit-appearance 去除默認(rèn)樣式
input, button, textarea, select {
*font-size: 100%;
-webkit-appearance:none;
}
使用CSS transforms 或者 animations時(shí)可能會(huì)有頁面閃爍的bug
elements {
-webkit-backface-visibility: hidden;
}
transform-style: preserve-3d 讓元素支持3D
elements {
-webkit-transform: rotateY(60deg); /* Chrome, Safari, Opera */
-webkit-transform-style: preserve-3d; /* Chrome, Safari, Opera */
transform: rotateY(60deg);
transform-style: preserve-3d;
}
perspective 這個(gè)屬性定義子元素會(huì)獲得透視效果,而不是元素本身
<div class="cube pers250">
<div class="face front">1</div>
<div class="face back">2</div>
<div class="face right">3</div>
<div class="face left">4</div>
<div class="face top">5</div>
<div class="face bottom">6</div>
</div>
.cube {
width: 100%;
height: 100%;
backface-visibility: visible;
perspective-origin: 150% 150%;
transform-style: preserve-3d;
-webkit-backface-visibility: visible;
-webkit-perspective-origin: 150% 150%;
-webkit-transform-style: preserve-3d;
}
.pers250 {
perspective: 250px;
-webkit-perspective: 250px;
}
.face {
display: block;
position: absolute;
width: 100px;
height: 100px;
border: none;
line-height: 100px;
font-family: sans-serif;
font-size: 60px;
color: white;
text-align: center;
}
css實(shí)現(xiàn)不換行、自動(dòng)換行、強(qiáng)制換行
/*不換行*/
white-space:nowrap;
/*自動(dòng)換行*/
word-wrap: break-word;
word-break: normal;
/*強(qiáng)制換行*/
word-break:break-all;
font-smoothing 設(shè)置字體平滑,會(huì)讓字體看起來比較舒服
h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6, p, .navbar, .brand, a, .td-name, td {
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
font-family: "Microsoft YaHei", "微軟雅黑", 'Muli', "Helvetica", Arial, sans-serif;
}
::selection 修改選中文本顏色
::selection {
color: white;
background-color: rgba(0, 0, 0, 0.8);
}
::-webkit-selection {
color: white;
background-color: rgba(0, 0, 0, 0.8);
}
::-moz-selection {
color: white;
background-color: rgba(0, 0, 0, 0.8);
}