10 個 GitHub 上超火的 CSS 項目,找到寫 CSS 的靈感!
今天給大家?guī)淼氖?nbsp;GitHub 上超火的 10 個 CSS 項目 ,希望你在這里面找到寫 CSS 的靈感!
喵~ 喵~ 喵~ 正文開始了,上車坐穩(wěn)扶好了~
You-need-to-know-css
該項目是 CSS 的各種效果實現(xiàn),尤其是動畫效果。
筆者把自己的收獲和工作中常用的一些 CSS 小樣式總結(jié)成這份文檔。
目前文檔一共包含 43 個 CSS 的小樣式(持續(xù)更新…),所以還是很不錯的學(xué)習(xí) CSS 的項目來的。
比如: 打字效果
- <style>
- main {
- width: 100%; height: 229px;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- span {
- display: inline-block;
- width: 21ch;
- font: bold 200% Consolas, Monaco, monospace; /*等寬字體*/
- overflow: hidden;
- white-space: nowrap;
- font-weight: 500;
- border-right: 1px solid transparent;
- animation: typing 10s steps(21), caret .5s steps(1) infinite;
- }
- @keyframes typing{
- from {
- width: 0;
- }
- }
- @keyframes caret{
- 50% { border-right-color: currentColor}
- }
- </style>
- <template>
- <main class="main">
- <span>前端GitHub</span>
- </main>
- </template>
- <script>
- </script>
https://lhammer.cn/You-need-to-know-css/#/zh-cn/
CSS-Inspiration
這里可以讓你尋找到使用或者是學(xué)習(xí) CSS 的靈感,以分類的形式,展示不同 CSS 屬性或者不同的課題使用 CSS 來解決的各種方法。
包含了:布局(Layout)、陰影(box-shadow、drop-shadow)、偽類/偽元素、濾鏡(fliter)、邊框(border)、背景/漸變(linear-gradient/radial-gradient/conic-gradient)、混合模式(mix-blend-mode/background-blend-mode)、3D、動畫/過渡(transition/animation)、clip-path、文本類、綜合、CSS-Doodle、SVG 等內(nèi)容。
比如: 巧用 CSS 實現(xiàn)酷炫的充電動畫
https://github.com/chokcoco/CSS-Inspiration
css_tricks
該項目總結(jié)了一些常用的 CSS 樣式,記錄一些 CSS 的新屬性和一點奇技淫巧。
比如 提示氣泡的效果
- <div class="poptip btn" aria-controls="彈出氣泡">poptip</div>
- $poptipBg: #30363d;
- $color: #fff;
- $triangle: 8px;
- $distance: -12px;
- .poptip {
- position: relative;
- z-index: 101;
- &::before,
- &::after {
- visibility: hidden;
- opacity: 0;
- transform: translate3d(0, 0, 0);
- transition: all 0.3s ease 0.2s;
- box-sizing: border-box;
- }
- &::before {
- content: "";
- position: absolute;
- width: 0;
- height: 0;
- border-style: solid;
- border-width: $triangle $triangle 0 $triangle;
- border-color: $poptipBg transparent transparent transparent;
- left: calc(50% - #{$triangle});
- top: 0px;
- transform: translateX(0%) translateY($distance);
- }
- &::after {
- font-size: 14px;
- color: $color;
- content: attr(aria-controls);
- position: absolute;
- padding: 6px 12px;
- white-space: nowrap;
- z-index: -1;
- left: 50%;
- bottom: 100%;
- transform: translateX(-50%) translateY($distance);
- background: $poptipBg;
- line-height: 1;
- border-radius: 2px;
- }
- &:hover::before,
- &:hover::after {
- visibility: visible;
- opacity: 1;
- }
- }
- .btn {
- min-width: 100px;
- line-height: 1.5;
- padding: 5px 10px;
- color: #fff;
- background: #00adb5;
- border-radius: 4px;
- text-align: center;
- cursor: pointer;
- }
效果:
https://github.com/QiShaoXuan/css_tricks
animista
該項目里面有各種 CSS 實現(xiàn)的效果,還有代碼演示,方便直接復(fù)制代碼,還可以復(fù)制壓縮后的代碼,如果你在找某個 CSS 的效果的話,可以到這里找找看。
http://animista.net/
spinkit
匯集了實現(xiàn)各種加載效果的 CSS 代碼片段。
SpinKit 僅使用( transform
和 opacity
)CSS 動畫來創(chuàng)建平滑且易于自定義的動畫。
https://tobiasahlin.com/spinkit/
十天精通 CSS3
這是前端大佬大漠出的一個免費的 CSS3 教程,對于有一定 CSS2 經(jīng)驗的伙伴,能讓您系統(tǒng)的學(xué)習(xí) CSS3,快速的理解掌握并應(yīng)用于工作之中。
里面的內(nèi)容有講解,還有代碼演習(xí),學(xué)完之后,可以練習(xí)所學(xué)的 api ,真的很不錯。
超級貓入門前端時,也學(xué)習(xí)過里面的內(nèi)容呢,雖然現(xiàn)在忘記的差不多了 :joy:,但是學(xué)過!。
https://www.imooc.com/learn/33
Animate
是一個有趣的,跨瀏覽器的 css3 動畫庫,內(nèi)置了很多典型的 css3 動畫,兼容性好使用方便。
animate.css 的使用非常簡單,因為它是把不同的動畫綁定到了不同的類里,所以想要使用哪種動畫,只需要把通用類 animated 和相應(yīng)的類添加到元素上就行了。
做為一個前端開發(fā),如果不知道這個庫就真的很失敗了。
https://animate.style/
sass
Sass 是一種 CSS 的預(yù)編譯語言,Sass 為 CSS 賦予了更強大的功能。
它提供了 變量(variables)、嵌套(nested rules) [混合(mixins)、函數(shù)(functions)等功能,并且完全兼容 CSS 語法。
Sass 能夠幫助復(fù)雜的樣式表更有條理, 并且易于在項目內(nèi)部或跨項目共享設(shè)計。
https://sass.bootcss.com/documentation
less
Less 是一門 CSS 預(yù)處理語言,它擴展了 CSS 語言,增加了變量、Mixin、函數(shù)等特性。
Less 可以運行在 Node 或瀏覽器端。
https://less.bootcss.com/
stylus
富有表現(xiàn)力、動態(tài)、健壯的 CSS。
它提供了一種高效,動態(tài)和表達(dá)方式來生成 CSS。同時支持縮進(jìn)語法和常規(guī) CSS 樣式。
https://stylus-lang.com/
CSS 預(yù)處理器技術(shù)已經(jīng)非常的成熟了,而且也涌現(xiàn)出了越來越多的 CSS 的預(yù)處理器框架。
對于 sass 、less 和 stylus,都是在現(xiàn)在的 vue 和 react 項目中經(jīng)常用到的,用法也很簡單,只要學(xué)會一種,其他兩種都很容易上手,項目中用哪一種就要看自己的喜歡了。