日常中記不住但又是要用的css
阿新 • • 發佈:2020-09-18
設定input 的placeholder的字型樣式
input::-webkit-input-placeholder { /* Chrome/Opera/Safari */ color: red; } input::-moz-placeholder { /* Firefox 19+ */ color: red; } input:-ms-input-placeholder { /* IE 10+ */ color: red; } input:-moz-placeholder { /* Firefox 18- */ color: red; }
設定input聚焦時的樣式
input:focus { background-color: red; }
取消input的邊框
border: none;
outline: none;
隱藏滾動條或更改滾動條樣式
/*css主要部分的樣式*//*定義滾動條寬高及背景,寬高分別對應橫豎滾動條的尺寸*/ ::-webkit-scrollbar { width: 10px; /*對垂直流動條有效*/ height: 10px; /*對水平流動條有效*/ } /*定義滾動條的軌道顏色、內陰影及圓角*/ ::-webkit-scrollbar-track{ -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3); background-color: rosybrown; border-radius: 3px; } /*定義滑塊顏色、內陰影及圓角*/ ::-webkit-scrollbar-thumb{ border-radius: 7px; -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3); background-color: #E8E8E8; } /*定義兩端按鈕的樣式*/ ::-webkit-scrollbar-button { background-color:cyan; } /*定義右下角匯合處的樣式*/ ::-webkit-scrollbar-corner{ background:khaki; }
文字超出隱藏並顯示省略號
單行(一定要有寬度)
width:200rpx;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
多行
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
控制div內的元素自動換行
word-wrap: break-word;
word-break:break-all;
純css畫三角形
#demo { width: 0; height: 0; border-width: 20px; border-style: solid; border-color: transparent transparent red transparent; }
絕對定位元素居中(水平和垂直方向)
#demo { width: 200px; height: 200px; position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%); background-color: green; }
表格邊框合併
table,tr,td{border: 1px solid #333;} table{ border-collapse: collapse; }
原作者姓名: kuangyaoqian
原出處:掘金
原文連結:那些你總是記不住但又總是要用的css - 掘金