1. 程式人生 > >Markdown here CSS配置詳細解讀

Markdown here CSS配置詳細解讀

MarkDown Here的CSS配置詳解

為了熟悉MarkDown Here的配置檔案,本文以一個典型的配置檔案作為例子把其中的css屬性和選擇器進行了註釋,以加深理解,幫助更好的配置對應的屬性。

css配置檔案附註釋

.markdown-here-wrapper {/*markdown here 的全域性配置*/
  font-size: 16px;  
  line-height: 1.8em;   
  /*em指的是相對單位,當前物件內字型的尺寸,預設瀏覽器16px*/
  /*http://www.w3school.com.cn/cssref/css_units.asp*/
  letter-spacing
: 0.1em
; }
pre, code { /*,逗號連線是並集選擇器*/ font-size: 14px; font-family: Roboto, 'Courier New', Consolas, Inconsolata, Courier, monospace; margin: auto 5px; } /*設定pre 和code的整體屬性,pre可以把div中的/r/n儲存下來顯示,而code則用瀏覽器的方式渲染*/ code { white-space: pre-wrap; border-radius: 2px; display: inline; } /*display 的屬性為指定元素框的型別*/
/*margin: 0為預設值,auto為瀏覽器自動計算的外邊距,外邊距屬性*/ /*border-radius: div元素的圓角框*/ /*write-space:如何處理元素內空白行,回車or忽略,nowrap不換行,pre-wrap換行*/ /*http://www.w3school.com.cn/cssref/pr_text_white-space.asp*/ pre { /*pre 元素可定義預格式化的文字。被包圍在 pre 元素中的文字通常會保留空格和換行符。而文字也會呈現為等寬字型。*/ font-size: 15px; line-height: 1.4em; display: block
; !important; /*在ie6以上的瀏覽器中,設定優先順序,覆蓋預先設定的屬性 !important*/ } pre code { /*空格連線是後代選擇器,外層在前內層在後; >連線是子元素選擇器*/ white-space: pre; overflow: auto; /*內容益處元素框時候的行為*/ border-radius: 3px; padding: 1px 1px; display: block !important; }
/*各種選擇器:https://blog.csdn.net/m0_38070602/article/details/69950795*/ /*pre code 的解釋:http://www.cnblogs.com/lizonghui/archive/2012/09/18/2692355.html*/ strong, b{ /*strong表示強調,用<b>粗體顯示,也可以自定義自己的強調方式*/ color: #BF360C; } em, i { /*em表示強調,用<i>標籤斜體顯示,也可以自定義自己的強調方式*/ color: #009688; } hr { /*水平線分割---*/ border: 1px solid #BF360C; margin: 1.5em auto; } p { /*段落選擇器*/ margin: 1.5em 5px !important; /*顏色*/ color:#d6a841; /*字型*/ font-family:'微軟雅黑'; /*字號*/ font-size:15px; /*行間距,可用百分比,數值倍數,畫素設定,還包括text-indent縮排、letter-spacing字間距、*/ line-height:100% 2 100px; /*段間距,一般用margin屬性調整*/ margin-bottom:20px; /*頁邊距用padding屬性調整*/ } /*表格和*/ table, pre, dl, blockquote, q, ul, ol { margin: 10px 5px; /*並集選擇器:表格、預格式化、定義列表、塊引用、短引用、無序列表、有序列表*/ } ul, ol { /*無序、有序列表*/ padding-left: 15px; } li { /* 定義列表中的專案*/ margin: 10px; } li p { /*li列表元素中的後代選擇器,包含選擇器,應用於li中的p*/ margin: 10px 0 !important; } ul ul, ul ol, ol ul, ol ol { /*各個後代選擇器一起新增屬性*/ margin: 0; padding-left: 10px; } ul { list-style-type: circle; } /*無序列表的字首,circle,square,好多種,同樣有序列表ol也可以設定不同的標記*/ /*http://www.w3school.com.cn/cssref/pr_list-style-type.asp*/ dl { padding: 0; } dl dt { font-size: 1em; font-weight: bold; /*加粗 義大利斜體*/ font-style: italic; } dl dd { margin: 0 0 10px; padding: 0 10px; } /*各種表格的包含選擇器定義,用空格連線*/ blockquote, q { border-left: 2px solid #009688; padding: 0 10px; /*上右下左的排序,可輸入四個值*/ color: #777; quotes: none; margin-left: 1em; } /*塊引用和短引用的樣式*/ blockquote::before, blockquote::after, q::before, q::after { content: none; } /*before 和after屬於css偽元素,:before在元素之前插入相應。:after在之後插入*/ /*偽元素用::,偽類用:參考ref。。https://blog.csdn.net/qq_25292481/article/details/52577320*/ /*--------同時設定六級標題的屬性,其中!important用於指定優先順序>ie6--------------*/ h1, h2, h3, h4, h5, h6 { margin: 20px 0 10px; padding: 0; font-style: bold !important; color: #009688 !important; text-align: center !important; margin: 1.5em 5px !important; padding: 0.5em 1em !important; } h1 { font-size: 24px !important; border-bottom: 1px solid #ddd !important; } h2 { font-size: 20px !important; border-bottom: 1px solid #eee !important; } h3 { font-size: 18px; } h4 { font-size: 16px; /*可以針對自己的標題做出個性化設定*/ color:#d6a841 /*16進位制顏色*/ font-style: bold /*加粗?傾斜*/ /*---------各種居中方式---------*/ margin: 0, auto; /*塊級元素居中*/ text-align: center; /*行內居中*/ justify-content: center; /*對齊*/ vertical-align: middle; /*垂直居中*/ /*ref: https://www.jianshu.com/p/61c431fd924a*/ } /*-------------表格元素的設定-----------------*/ table { padding: 0; border-collapse: collapse; /*合併邊框屬性*/ border-spacing: 0; font-size: 1em; font: inherit; border: 0; margin: 0 auto; } tbody { margin: 0; padding: 0; border: 0; } table tr { border: 0; border-top: 1px solid #CCC; background-color: white; margin: 0; padding: 0; } table tr:nth-child(2n) { background-color: #F8F8F8; } table tr th, table tr td { font-size: 16px; border: 1px solid #CCC; margin: 0; padding: 5px 10px; } table tr th { /*表格。tableraw,tableheader*/ font-weight: bold; color: #eee; border: 1px solid #009688; background-color: #009688; } ---------- 可根據markdown的實現自己的**個性化**標記 @strong-char: "**"; /*可以將著重符號替換為自己的個性化符號*/ strong:before, strong:after { content: @strong-char; display: inline; } @em-char: "*"; em:before, em:after { content: @em-char; display: inline; } /*https://github.com/mrcoles/markdown-css/blob/master/markdown.less*/ /*http://www.jb51.net/css/357685.html*/ /*<span>行內封裝,<div>塊級封裝*/ /*copy from jianshu*/ /*source code:https://www.jianshu.com/p/7bda360950ce*/

馬克飛象的css詳解

馬克飛象也是常用的markdown編輯器,這裡以一個典型的例子DB_Liu來對其中的語法標記進行解釋,以便實現自己的個性化配置


/*----------配置主體、標題、段落、列表等元素的樣式-------------*/
body {
    font-family: "Avenir Next", Helvetica, Arial, sans-serif;
    padding:1em;
    margin:auto;
    max-width:42em;
    background:#fefefe;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: bold;
}

h1 {
    color: #000000;
    font-size: 28pt;
        border-bottom: 1px solid #CCCCCC;
}

h2 {
    color: #000000;
    font-size: 24px;
}

h3 {
    font-size: 18px;
}

h4 {
    font-size: 16px;
}

h5 {
    font-size: 14px;
}

h6 {
    color: #777777;
    background-color: inherit;
    font-size: 14px;
}

hr {
    height: 0.2em;
    border: 0;
    color: #DC143C;
    background-color: #DC143C;
}

p, blockquote, ul, ol, dl, li, table, pre {
    margin: 15px 0;
}
/*----------配置主體、標題、段落、列表、引用等元素的樣式-------------*/
/*--------------body,h1~h6,p,ol\ul\dl\li\table\p\blockquote-----*/


/*-------a標籤配置連結屬性----------*/
a, a:visited {
    color: #4183C4;
    background-color: inherit;
    text-decoration: none;
}


/**------#號標記id,作為id選擇器來配置屬性------**/
#message {
    border-radius: 6px;
    border: 1px solid #ccc;
    display:block;
    width:100%;
    height:60px;
    margin:6px 0px;
}

button, #ws {
    font-size: 10pt;
    padding: 4px 6px;
    border-radius: 5px;
    border: 1px solid #bbb;
    background-color: #eee;
}

code, pre, #ws, #message {
    font-family: Consolas;  /*程式碼字型樣式*/
    font-size: 12pt;
}

code {
    border: 1px solid #EAEAEA;
    margin: 0 2px;
    padding: 0 5px;
}

pre {
    border: 1px solid #CCCCCC;
    overflow: auto;
    padding: 2px 2px;
}

pre > code {   /*子選擇器*/
    border: 0;
    margin: 0;
    padding: 0;
}

#ws { background-color: #DC143C; }

/*類選擇器設定*/
.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }

table tr:nth-child(2n) {/*包含選擇器,:為偽類*/
  background-color: #DC143C;
}



/*
Monokai style - ported by Luigi Maselli - http://grigio.org
*/
/*____________highlight.js 的屬性配置,主要用於程式碼高亮___________________*/
.hljs {
  display: block;
  overflow-x: auto;
  padding: 0.5em;
  background: #272822; color: #ddd;
}

.hljs-tag,
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-strong,
.hljs-name {
  color: #f92672;
}

.hljs-code {
  color: #66d9ef;
}

.hljs-class .hljs-title {
  color: white;
}

.hljs-attribute,
.hljs-symbol,
.hljs-regexp,
.hljs-link {
  color: #bf79db;
}

.hljs-string,
.hljs-bullet,
.hljs-subst,
.hljs-title,
.hljs-section,
.hljs-emphasis,
.hljs-type,
.hljs-built_in,
.hljs-builtin-name,
.hljs-selector-attr,
.hljs-selector-pseudo,
.hljs-addition,
.hljs-variable,
.hljs-template-tag,
.hljs-template-variable {
  color: #a6e22e;
}

.hljs-comment,
.hljs-quote,
.hljs-deletion,
.hljs-meta {
  color: #75715e;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-doctag,
.hljs-title,
.hljs-section,
.hljs-type,
.hljs-selector-id {
  font-weight: bold;
}

highlight.js官網,中文參考文件