css隨筆記

來源:互聯網
上載者:User

標籤:code   rgb   img   sha   read   out   ack   控制   blur   

使用偽類寫邊框部分三角

  右上方三角形

border-top:6px solid #c1ddf7border-left:6px solid transparent

  右下角三角形

border-bottom:6px solid #c1ddf7border-left:6px solid transparent

  左上方三角形

border-top:6px solid #c1ddf7border-right:6px solid transparent

  左下角三角形

border-bottom:6px solid #c1ddf7border-right:6px solid transparent

 

圓形邊框

  border-radius:以百分比定義圓角的形狀。-webkit-border-radius是chrome,Safari私人屬性。

img{    border-radius: 100%;    -webkit-border-radius: 100%;}

 

 手機密度比

/*裝置最小寬度321px到最大寬度1080px之間且最大密度比為2*/@media (min-width:321px) and (max-width:1080px) and (-webkit-max-device-    pixel-ratio: 2) {}

  

/*裝置最小寬度321px到最大寬度1080px之間且最小密度比為2*/@media (min-width:321px) and (max-width:1080px) and (-webkit-min-device-pixel-ratio: 2) {}

  

/*裝置最小寬度321px到最大寬度1080px之間且最小密度比為1到最大密度比為2*/@media (min-width:321px) and (max-width:1080px) and (-webkit-min-device-pixel-ratio: 1) and(-webkit-max-device-pixel-ratio: 2) {}

  

/*裝置最小寬度321px到最大寬度1080px之間且密度比為2*/@media (min-width:321px) and (max-width:1080px) and (-webkit-device-pixel-ratio: 2) {}

 

手機端全屏蒙層置中彈窗樣式

  css樣式

.pop{width:100%;background-color:rgba(0,0,0,.6);position:fixed;left:0;top:0;z-index:999;height:100%;display:block;}.outside{width:100%;height:100%;display:-webkit-box;display:-moz-box;display:-ms-flexbox;display:-webkit-flex;display:flex;}.inside{width:100%;display:-webkit-box;display:-webkit-flex;display:flex;-webkit-box-pack:center;-webkit-justify-content:center;justify-content:center;-webkit-box-align:center;-webkit-align-items:center;align-items:center;}.inPops{margin:0 auto;background-color:#fff;/*width:68%;可以根據要求改變寬度*/position:relative;text-align:center;border-radius:5px;-webkit-border-radius:5px;}

  html結構

 <div class="pop">     <div class="outside">         <div class="inside">             <div class="inPops">                 ...your html code             </div>         </div>     </div> </div>

  

規定段落中的文本單行且溢出部分顯示...

p{     white-space:nowrap;text-overflow:ellipsis;overflow:hidden; }

 

文本控制顯示行

p{/*這個是想顯示幾行就寫幾*/-webkit-line-clamp:3;overflow:hidden;text-overflow:ellipsis;-webkit-box-orient:vertical;}

 

英文字型允許換行

p{word-break:break-word;}

 

box-sizing盒子寬度

 div{       box-sizing:border-box;-moz-box-sizing:border-box;/* Firefox */-webkit-box-sizing:border-box;/* Safari */  }  /*content-box:      這是由 CSS2.1 規定的寬度高度行為。      寬度和高度分別應用到元素的內容框。      在寬度和高度之外繪製元素的內邊距和邊框  border-box:      為元素設定的寬度和高度決定了元素的邊框盒。     就是說,為元素指定的任何內邊距和邊框都將在已設定的寬度和高度內進行繪製。     通過從已設定的寬度和高度分別減去邊框和內邊距才能得到內容的寬度和高度。*/

 

css3旋轉角度

div{transform:rotate(90deg);-webkit-transform:rotate(90deg);-o-transform:rotate(90deg);-moz-transfomr:rotate(90deg);}

 

css3漸層

 /*最簡單的寫法:*/ background:-webkit-linear-gradient(left,#ffffff,#ffffff); /*漸層顏色*/ -webkit-linear-gradient(left,startColor,endColor); /*left位置,startColor起始顏色,endColor結束顏色background-image:-webkit-linear-gradient(left,rgba(255,255,255,0),rgba(255,255,255,1));*/

 

css3陰影shadow

 img{     -moz-box-shadow:2px 2px 5px e69696;/*firefox*/-webkit-box-shadow:2px 2px 5px e69696;/*webkit*/box-shadow:2px 2px 5px e69696;/*opera或ie9*/     } /*文法box-shadow: h-shadow v-shadow blur spread color inset;*/

 

段落的行縮排

 p{     text-indent:20px; } /*這是相容寫法與text-indent一樣*/ p:empty{     padding-left:2%; }

 

盒子模型分布,與自適應佔位

 /*  box-flex:      子容器將父容器的寬度等份分,有幾個li就幾個等份寬度的li;      如果其中一個li設定了固定的寬度而別的li沒有設定,則父容器的寬度減去固定li的寬度後在進行等份分;  */  ul li{      box-flex:1;-webkit-box-flex:1;-moz-box-flex:1;display:block;  }  ul{     display:box;display:-webkit-box;display:-moz-box; }

 

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.