1. <i id="s6b2k"><small id="s6b2k"></small></i>
    <b id="s6b2k"><bdo id="s6b2k"></bdo></b>
  2. <wbr id="s6b2k"></wbr>

    CSS代碼檢查工具stylelint的使用方法詳解_CSS/HTML

    來源:腳本之家  責任編輯:小易  

    首先明白什么是靜態?什么是動態?靜態動態最根本的區別就在于“程序是否是運行的”。靜態就是不運行程序去測試,那么又要問了:不運行怎么測試呢?那最簡單的靜態測試方法就是“code review”也就是看代碼。看代碼有沒有什么地方明顯是錯誤的www.yu113.com防采集請勿采集本網。

    CSS不能算是嚴格意義的編程語言,但是在前端體系中卻不能小覷。 CSS 是以描述為主的樣式表,如果描述得混亂、沒有規則,對于其他開發者一定是一個定時炸彈,特別是有強迫癥的人群。CSS 看似簡單,想要寫出漂亮的 CSS 還是相當困難。所以校驗 CSS 規則的行動迫在眉睫。stylelint是一個強大的現代 CSS 檢測器,可以讓開發者在樣式表中遵循一致的約定和避免錯誤。本文將詳細介紹CSS代碼檢查工具stylelint

    刪除多余的css,首先我們需要明確是,確實不需要這個css樣式了,或者是這個css的樣式重復了,我們才會去刪除,刪除的方法就是找到多余的css代碼的位置,然后在選中用del刪除就行了,具體看代碼:

    概述

    CleanCSS本是為CSS減肥的工具,但也能檢查出拼寫錯誤。3.用刪除法確定錯誤發生的位置 如果錯誤影響了整體布局,則可以逐個刪除div塊,直到刪除某個div塊后顯示恢復正常,即可確定錯誤發生的位置。4.利用

    stylelint擁有超過150條的規則,包括捕捉錯誤、最佳實踐、控制可以使用的語言特性和強制代碼風格規范。它支持最新的CSS語法,并且靈活可配置

    Vue

    CSS是Cascading style Sheets的簡稱,中文譯作“層疊樣式表單”,我把它叫作“層疊樣式表”,我感到這樣順口一,沒別的意思。實際上它是一組樣式。你可能對CSS這個名詞比較陌生,實際上無論你用

    下面在Vue框架下安裝使用stylelint

    CSS問題檢查工具:CSS Lint CSS Lint是一個開源的校驗CSS文件質量的工具,最初是由 Nicholas C.Zakas和 Nicole Sullivan編寫的,最初版本在Velocity會議上于2011年6月發布。CSS Lint的檢測規則包括錯誤的

    1、安裝stylelint、stylint-config-standard和stylelint-order

    Css代碼*/ class1 {color:black;} class2 {color:red;} 而某個元素指定class時采用 class=\"class2 class1\"這種方式指定,此時雖然class1在元素中指定時排在class2的后面,但因為在樣式表文件中class1處于

    npm install stylelint --save-devnpm install stylelint-config-standard --save-devnpm install stylelint-order --save-dev

    其中,stylelint是運行工具,stylelint-config-standard是stylelint的推薦配置,stylelint-order是CSS屬性排序插件

    安裝完成后,package.json文件中會自動添加如下字段

    "stylelint": "^9.1.3","stylelint-config-standard": "^18.2.0","stylelint-order": "^0.8.1",

    2、在根目錄下創建.stylelintrc配置文件

    { "extends": "stylelint-config-standard", "plugins": ["stylelint-order"],"rules": {"order/order": ["declarations","custom-properties","dollar-variables","rules","at-rules"],"order/properties-order": ["position","z-index", "top","bottom","left", "right","float","clear","columns","columns-width","columns-count","column-rule","column-rule-width","column-rule-style","column-rule-color","column-fill","column-span","column-gap", "display","grid","grid-template-rows","grid-template-columns","grid-template-areas","grid-auto-rows","grid-auto-columns","grid-auto-flow","grid-column-gap","grid-row-gap","grid-template","grid-template-rows","grid-template-columns","grid-template-areas","grid-gap","grid-row-gap","grid-column-gap","grid-area","grid-row-start","grid-row-end","grid-column-start","grid-column-end","grid-column","grid-column-start","grid-column-end","grid-row","grid-row-start","grid-row-end", "flex","flex-grow","flex-shrink","flex-basis","flex-flow","flex-direction","flex-wrap","justify-content","align-content","align-items","align-self","order","table-layout","empty-cells","caption-side","border-collapse","border-spacing","list-style","list-style-type","list-style-position","list-style-image","ruby-align","ruby-merge","ruby-position","box-sizing","width","min-width","max-width","height","min-height","max-height","padding","padding-top","padding-right","padding-bottom","padding-left","margin","margin-top","margin-right","margin-bottom","margin-left", "border","border-width","border-top-width","border-right-width","border-bottom-width","border-left-width","border-style","border-top-style","border-right-style","border-bottom-style","border-left-style","border-color","border-top-color","border-right-color","border-bottom-color","border-left-color","border-image","border-image-source","border-image-slice","border-image-width","border-image-outset","border-image-repeat","border-top","border-top-width","border-top-style","border-top-color","border-top","border-right-width","border-right-style","border-right-color","border-bottom","border-bottom-width","border-bottom-style","border-bottom-color","border-left","border-left-width","border-left-style","border-left-color","border-radius","border-top-right-radius","border-bottom-right-radius","border-bottom-left-radius","border-top-left-radius","outline","outline-width","outline-color","outline-style","outline-offset","overflow","overflow-x","overflow-y","resize","visibility","font","font-style","font-variant","font-weight","font-stretch","font-size","font-family","font-synthesis","font-size-adjust","font-kerning", "line-height","text-align","text-align-last","vertical-align", "text-overflow","text-justify","text-transform","text-indent","text-emphasis","text-emphasis-style","text-emphasis-color","text-emphasis-position","text-decoration","text-decoration-color","text-decoration-style","text-decoration-line","text-underline-position","text-shadow", "white-space","overflow-wrap","word-wrap","word-break","line-break","hyphens","letter-spacing","word-spacing","quotes","tab-size","orphans","writing-mode","text-combine-upright","unicode-bidi","text-orientation","direction","text-rendering","font-feature-settings","font-language-override","image-rendering","image-orientation","image-resolution","shape-image-threshold","shape-outside","shape-margin","color","background","background-image","background-position","background-size","background-repeat","background-origin","background-clip","background-attachment","background-color","background-blend-mode","isolation","clip-path","mask","mask-image","mask-mode","mask-position","mask-size","mask-repeat","mask-origin","mask-clip","mask-composite","mask-type","filter","box-shadow","opacity","transform-style","transform","transform-box","transform-origin","perspective","perspective-origin","backface-visibility","transition","transition-property","transition-duration","transition-timing-function","transition-delay","animation","animation-name","animation-duration","animation-timing-function","animation-delay","animation-iteration-count","animation-direction","animation-fill-mode","animation-play-state","scroll-behavior","scroll-snap-type","scroll-snap-destination","scroll-snap-coordinate","cursor","touch-action","caret-color","ime-mode","object-fit","object-position","content","counter-reset","counter-increment","will-change","pointer-events","all","page-break-before","page-break-after","page-break-inside","widows"], "no-empty-source": null,"property-no-vendor-prefix": [true, {"ignoreProperties": ["background-clip"]}],"number-leading-zero": "never","number-no-trailing-zeros": true,"length-zero-no-unit": true,"value-list-comma-space-after": "always","declaration-colon-space-after": "always","value-list-max-empty-lines": 0,"shorthand-property-no-redundant-values": true,"declaration-block-no-duplicate-properties": true,"declaration-block-no-redundant-longhand-properties": true,"declaration-block-semicolon-newline-after": "always","block-closing-brace-newline-after": "always","media-feature-colon-space-after": "always","media-feature-range-operator-space-after": "always","at-rule-name-space-after": "always","indentation": 2,"no-eol-whitespace": true,"string-no-newline": null}}

    3、使用stylelint驗證CSS代碼即可,如驗證src目錄下的所有vue文件

    react

    react中使用styled-components來書寫CSS代碼,stylelint同樣提供了插件來校驗CSS

    1、安裝stylelint、stylelint-processor-styled-components、stylelint-config-styled-components、stylelint-config-recommend、stylelint-order

    npm install --save-dev stylelint@9.1.3npm install --save-dev stylelint-processor-styled-componentsnpm install --save-dev stylelint-config-styled-componentsnpm install --save-dev stylelint-config-recommendednpm install --save-dev stylelint-order

    注意: 由于stylelint更新到9.2版本后,導致styled-components中的CSS代碼無法正常校驗,所以穩妥起見,使用9.1.3版本的

    2、在根目錄下新建配置文件.stylelintrc

    {"processors": ["stylelint-processor-styled-components"],"extends": ["stylelint-config-recommended","stylelint-config-styled-components"],"plugins": ["stylelint-order"],"rules": {"order/order": ["declarations","custom-properties","dollar-variables","rules","at-rules"],...}

    3、同樣地,使用stylelint命令即可校驗

    注意事項

    1、fix命令

    在stylelint的150多條規則中,使用fix命令,可以自動修復一些命令。但是,該fix命令一定要慎用。筆者在使用fix命令后,stylelint將React工程中的所有js文件里的代碼全部清除,只留著了下可以識別的css部分

    stylelint '**/*.js' --fix

    2、配置scripts

    可以在package.json中配置stylelint的快捷方式

    "scripts": {"lintcss": "stylelint 'src/**/*.js'"}

    這樣,使用npm run lintcss 命令即可實現相同效果

    3、如果提示如下錯誤

    Error: No configuration provided for

    是因為在根路徑下沒有發現配置文件,如.stylelintrc

    更多關于CSS代碼檢查工具stylelint的使用方法請查看下面的相關鏈接

    IE9瀏覽器默認情況下隱藏了瀏覽器菜單欄,因此在打開IE9瀏覽器以后,需要按鍵盤上的ALT鍵來顯示瀏覽器工具欄。2在顯示出來的IE菜單欄上點擊菜單“查看”→“源文件”。3IE瀏覽器會自動打開一個新的窗口來顯示網頁源代碼。4哦~這份緣文件實在太難看懂了~別著急,其實IE9提供了一個更為強大的網頁源代碼查看工具—開發者工具。點擊IE9瀏覽器右上角的齒輪圖標,在下拉菜單中點擊“F12開發者工具”,或者直接按鍵盤上的快捷鍵F12也可以打開開發者工具。5IE9的開發者工具提供更為強大的網頁開發查看代碼和調試功能,你可以使用開發者工具更方便地查看網頁HTML代碼,CSS樣式代碼和腳本等信息。END使用Firefox火狐瀏覽器查看網頁源代碼1Windows Vista/7用戶:點擊Firefox瀏覽器左上角的快捷菜單,在下拉菜單中點擊“Web開發者”→“查看頁面源代碼”。Windows XP/Linux用戶:點擊Firefox瀏覽器的菜單“工具”→“Web開發者”→“查看頁面源代碼”。鍵盤快7a686964616fe78988e69d8331333361313330捷鍵:Ctrl+U2Firfox瀏覽器會打開網頁源代碼窗口顯示網頁HTML源代碼。3如果想要查看其中外聯的CSS源文件,可以用鼠標點擊源代碼中的CSS外聯文件鏈接網址。4不過自帶的之中網頁源文件查看器并不好用,你可以嘗試使用插件Firebug來獲取更好用的網頁開發功能。點擊“Web開發者”→“獲取更多工具”。5在彈出的Firefox新標簽頁中安裝插件“Firebug”。6安裝完成以后會在Firefox瀏覽器的右上角工具欄中添加Firebug的圖標,點擊它就可以使用Firebug網頁調試工具了。這個工具相當強大哦~END使用谷歌Chrome瀏覽器查看網頁源代碼點擊Chrome瀏覽器右上角的快捷菜單“工具”→“查看源代碼”。Chrome瀏覽器會打開一個網頁源代碼顯示窗口,這個源代碼顯示窗口好像也是不那么友好,一大堆網頁代碼實在不知道如何下手呀。如果你想要更好的網頁源代碼顯示和開發工具,那就點擊Chrome瀏覽器右上角的快捷菜單“工具”→“開發者工具”。看看,不需要下載任何插件,Chrome瀏覽器就已經為你提供了一個相當強大的網頁開發者工具了。使用Chrome瀏覽器開發者工具來查看和調試CSS也相當好用內容來自www.yu113.com請勿采集。


  3. 本文相關:
  4. vue單文件組件lint error自動fix與stylelint報錯自動fix詳解
  5. 使用 stylelint檢查css_stylelint
  6. windows的listview一樣,而且不能把表頭從表格里面獨立出來
  7. html中的圖象標簽屬性
  8. 在div+css排版中新聞列表的制作方法
  9. html標記
  10. 如何設置一個指定高度的div
  11. 自定義容器和字體大小
  12. 在線asc碼查詢
  13. 利用css控制select中的option是否不允許選
  14. firefox推薦與個人理解的css書寫順序
  15. 凸起的按鈕效果
  16. 怎樣使用瀏覽器查看網頁HTML和CSS源代碼
  17. 代碼為什么需要靜態代碼檢查工具
  18. 使用工具檢測網站,結果被要求合并幾個CSS文件,要怎么合并?
  19. css是什么意思
  20. 如何刪除 多余 css?
  21. 如何檢查調試CSS布局代碼
  22. CSS是什么
  23. Web 設計的CSS 工具有哪些
  24. css的auto-fill怎么清楚
  25. 用什么軟件檢查CSS錯誤
  26. 網站首頁網頁制作腳本下載服務器操作系統網站運營平面設計媒體動畫電腦基礎硬件教程網絡安全javascriptasp.netphp編程ajax相關正則表達式asp編程jsp編程編程10000問css/htmlflex腳本加解密web2.0xml/rss網頁編輯器相關技巧安全相關網頁播放器其它綜合dart首頁css/htmlvue單文件組件lint error自動fix與stylelint報錯自動fix詳解使用 stylelint檢查css_stylelintwindows的listview一樣,而且不能把表頭從表格里面獨立出來html中的圖象標簽屬性在div+css排版中新聞列表的制作方法html標記如何設置一個指定高度的div自定義容器和字體大小在線asc碼查詢利用css控制select中的option是否不允許選firefox推薦與個人理解的css書寫順序凸起的按鈕效果漂亮的表格頁面遮罩層,并且阻止頁面body滾相對路徑與絕對路徑的區別html清除浮動的6種方法示例css透明屬性詳解代碼css繪制五角星文字或圖片元素在div中垂直居中css如何使div層居中css3+js實現響應式導航條css圖文混排的幾種方案css之自動換行對display:inline;與float:left;的認識w3c技術架構介紹文字應用css濾鏡集錦div+css排版的樣例china.com網站開發規范css實現的對聯廣告代碼頁面遮罩層,并且阻止頁面body滾動。boot文字或圖片元素在div中垂直居中如何以及何時使用sifr
    免責聲明 - 關于我們 - 聯系我們 - 廣告聯系 - 友情鏈接 - 幫助中心 - 頻道導航
    Copyright © 2017 www.yu113.com All Rights Reserved
    战天txt全集下载