讀書筆記 —— 《css秘密花園》

來源:互聯網
上載者:User

標籤:ref   自動   bsp   context   indicator   技巧   one   gif   elements   

瀏覽器安全色性有效性資訊查詢 : Can I Use?

http://caniuse.com/

自動為css添加瀏覽器廠商首碼

https://autoprefixer.github.io/

線上編輯HTML/CSS/JavaScript與即時預覽的工作台

https://jsfiddle.net/http://codepen.io/pens/

http://runjs.cn/

 

簡易的DOM擷取工具函數

function $$(selector,context) {    context = context || document;    var elements = context.querySelectorAll(selector);    //我們知道,Array.prototype.slice.call(arguments)能將具有length屬性的對象轉成數組
  // 除了IE下的節點集合(因為ie下的dom對象是以com對象的形式實現的,js對象與com對象不能進行轉換) return Array.prototype.slice.call(elements);}

 

 

 通過js判斷樣式屬性是否被支援

/* 檢測單個屬性 */
var root = document.documentElement;if (‘textShadow‘ in root.style) { root.classList.add(‘textshadow‘);} else { root.classList.add(‘no-textshadow‘);}/* 上例函數化 */function testProperty(property) { var root = document.documentElement; if (property in root.style) { root.classList.add(property.toLowerCase()); return true; } root.classList.add(‘no-‘ + property.toLowerCase()); return false;}
/* 檢測某個具體的屬性值是否支援: */function testValue(id, value, property) { var dummy = document.createElement(‘p‘); dummy.style[property] = value; if (dummy.style[property]) { root.classList.add(id); return true; } root.classList.add(‘no-‘ + id); return false;}

 

demo1——css編輯技巧:

http://runjs.cn/detail/hul3lwuq

/* 如果字型變化,這段代碼改動的幅度會非常大 */.button{  padding:6px 16px;  border:1px solid #446d88;  background:#58a linear-gradient(#77a0bb,#58a);  border-radius:4px;    box-shadow:0 1px 5px gray;  color:white;    text-shadow:0 -1px 1px #335166;    font-size:20px;    line-height:30px;    }/* 字型改大,其他地方也跟著變大,知識點在於em單位,但依然存在問題,就是顏色 */.button-2{  padding:.3em .8em;  border:1px solid #446d88;  background:#58a linear-gradient(#77a0bb,#58a);  border-radius:.2em;    box-shadow:0 .05em .25em gray;  color:white;    text-shadow:0 -.05em .05em #335166;    font-size:225%;    line-height:1.5;    }/* 只需要覆蓋背景顏色,就可以動態改變了 */.button-3{  padding:.3em .8em;  border:1px solid #446d88;  background:#58a linear-gradient(hsla(0,0%,100%,.2),transparent);  border-radius:.2em;    box-shadow:0 .05em .25em gray;  color:white;    text-shadow:0 -.05em .05em #335166;    font-size:225%;    line-height:1.5;    }.ok { background-color:#6b0;}.warn{ background-color:#c00;}
View Code

 

 

讀書筆記 —— 《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.