MarkDown-Here 的樣式分享


最近在使用MarkDown寫公眾號文章,並使用MarkDown Here進行排版。發現效果還不錯,這邊分享一個 MarkDown Here的CSS樣式。

/*markdown here 的全局配置*/
.markdown-here-wrapper {
  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 #B3B3B3 !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;
}

代碼樣式:HyBrid

/*

vim-hybrid theme by w0ng (https://github.com/w0ng/vim-hybrid)

*/

/*background color*/
.hljs {
  display: block;
  overflow-x: auto;
  padding: 0.5em;
  background: #1d1f21;
  -webkit-text-size-adjust: none;
}

/*selection color*/
.hljs::selection,
.hljs span::selection {
	background: #373b41;
}
.hljs::-moz-selection,
.hljs span::-moz-selection {
	background: #373b41;
}

/*foreground color*/
.hljs,
.hljs-setting .hljs-value,
.hljs-expression .hljs-variable,
.hljs-expression .hljs-begin-block,
.hljs-expression .hljs-end-block,
.hljs-class .hljs-params,
.hljs-function .hljs-params,
.hljs-at_rule .hljs-preprocessor {
  color: #c5c8c6;
}

/*color: fg_yellow*/
.hljs-title,
.hljs-function .hljs-title,
.hljs-keyword .hljs-common,
.hljs-class .hljs-title,
.hljs-decorator,
.hljs-tag .hljs-title,
.hljs-header,
.hljs-sub,
.hljs-function {
  color: #f0c674;
}

/*color: fg_comment*/
.hljs-comment,
.hljs-javadoc,
.hljs-output .hljs-value,
.hljs-pi,
.hljs-shebang,
.hljs-template_comment,
.hljs-doctype {
  color: #707880;
}

/*color: fg_red*/
.hljs-number,
.hljs-symbol,
.hljs-literal,
.hljs-deletion,
.hljs-link_url,
.hljs-symbol .hljs-string,
.hljs-argument,
.hljs-hexcolor,
.hljs-input .hljs-prompt,
.hljs-char {
 color: #cc6666
}

/*color: fg_green*/
.hljs-string,
.hljs-special,
.hljs-javadoctag,
.hljs-addition,
.hljs-important,
.hljs-tag .hljs-value,
.hljs-at.rule .hljs-keyword,
.hljs-regexp,
.hljs-attr_selector {
  color: #b5bd68;
}

/*color: fg_purple*/
.hljs-variable,
.hljs-property,
.hljs-envar,
.hljs-code,
.hljs-expression,
.hljs-localvars,
.hljs-id,
.hljs-variable .hljs-filter,
.hljs-variable .hljs-filter .hljs-keyword,
.hljs-template_tag .hljs-filter .hljs-keyword {
 color: #b294bb;
}

/*color: fg_blue*/
.hljs-statement,
.hljs-label,
.hljs-keyword,
.hljs-xmlDocTag,
.hljs-function .hljs-keyword,
.hljs-chunk,
.hljs-cdata,
.hljs-link_label,
.hljs-bullet,
.hljs-class .hljs-keyword,
.hljs-smartquote,
.hljs-method,
.hljs-list .hljs-title,
.hljs-tag {
 color: #81a2be;
}

/*color: fg_aqua*/
.hljs-pseudo,
.hljs-exception,
.hljs-annotation,
.hljs-subst,
.hljs-change,
.hljs-cbracket,
.hljs-operator,
.hljs-horizontal_rule,
.hljs-preprocessor .hljs-keyword,
.hljs-typedef,
.hljs-template_tag,
.hljs-variable,
.hljs-variable .hljs-filter .hljs-argument,
.hljs-at_rule,
.hljs-at_rule .hljs-string,
.hljs-at_rule .hljs-keyword {
  color: #8abeb7;
}


/*color: fg_orange*/
.hljs-type,
.hljs-typename,
.hljs-inheritance .hljs-parent,
.hljs-constant,
.hljs-built_in,
.hljs-setting,
.hljs-structure,
.hljs-link_reference,
.hljs-attribute,
.hljs-blockquote,
.hljs-quoted,
.hljs-class,
.hljs-header {
  color: #de935f;
}

.hljs-emphasis
{
  font-style: italic;
}

.hljs-strong
{
  font-weight: bold;
}

工具推薦

上面的MarkDown Here使用起來很方便,但是在使用過程中發現一個問題:就是文章格式在保存后會亂掉。也沒找到好的解決方法。

所以在網上又找了一個工具,使用起來也比較方便。具體地址見:http://md.aclickall.com

我選擇了一個標題居中的主題,自己進行了小范圍修改。

/*可任意修改樣式,或恢復預設值,保存后生效
相對“默認樣式”而作的修改會用  紅色 標注*/

.output_wrapper
{
     /*此屬性為全局*/
     font-size: 16px;
     color: #3e3e3e;
     line-height: 1.8em;
     word-spacing:0px; 
     letter-spacing:0px;
     font-family: "Helvetica Neue",Helvetica,"Hiragino Sans GB","Microsoft YaHei",Arial,sans-serif;   
}
.output_wrapper *
{
  font-size: inherit  ;
  color: inherit;
  line-height: inherit;
  margin: 0px;
  padding:0px;
}

p {
  /*段落*/
  margin: 1.5em 10px;
}

h1,h2,h3,h4,h5,h6 {
  margin: 1.5em 12px;
  font-weight:bold;
  color:#159957;        /*改變了其默認的標題顏色*/
  text-align: center;   /*改變了其默認值,使其標題居中*/
}

h1 {
  font-size: 1.6em  ;
   border-bottom: 1px solid #ddd !important;
}
h2 {
  font-size: 1.5em;
  border-bottom: 1px solid #eee !important;
}
}
h3 {
  font-size: 1.4em;
}
h4 {
  font-size: 1.2em;
}
h5 {
  font-size: 1.3em;
}
h6 {
  font-size: 1.2em;
}

ul, ol {
  padding-left: 32px;
}
ul{ /*無序列表*/
    list-style-type: disc;
}
ol { /*有序列表*/
  list-style-type: decimal;
}
li *  
{
 /* color: #3e3e3e;*/
} 

li{  /*在公眾號下,改變不了li符號的屬性(如顏色),並會影響其子元素的屬性;而在其它博客平台中,則能正常使用*/ 
    margin-bottom: 0.5em;
/*  color:#159957; */    
}
.code_size_default  /*代碼塊默認size*/
{
  line-height: 18px;
  font-size: 14px; 
  font-weight:normal;
  word-spacing:0px; 
  letter-spacing:0px; 
}
.code_size_tight /*代碼塊緊湊size*/
{
   line-height: 15px; 
   font-size: 11px; 
   font-weight:normal;
   word-spacing:-3px; 
   letter-spacing:0px; 
}
pre code /*代碼塊*/
{           
     font-family: Consolas, Inconsolata, Courier, monospace;
     border-radius: 0px;
}
blockquote { /*引用塊*/
  display: block;
  padding: 15px 1rem;
  font-size: 0.9em;
  padding-right: 15px;
  margin: 1em 10px;
  color: #819198;
  border-left: 6px solid #dce6f0;
  background: #f2f7fb;
  overflow: auto;
  overflow-scrolling: touch; 
  word-wrap: normal;
  word-break: normal;  
}
blockquote p {
    margin: 10px;
}

a { /*超鏈接*/
  text-decoration: none;
  color: #1e6bb8;
  word-wrap:break-word;
}

strong  /*強調*/
{
  font-weight: bold;
}
em /*斜體*/
{
 font-style:italic;
}
del /*刪除線*/
{
 font-style:italic;
}
strong em/*強調的斜體*/
{
font-weight: bold;
}

hr {  /*分隔線*/
  height: 1px;
  margin: 1.5rem 10px;
  border: none;
  border-top: 1px dashed #A5A5A5;
}

code /*行內代碼*/
{
    word-wrap: break-word;
    padding: 2px 4px;
    border-radius: 4px;
    margin:0 10px;
    color:#e96900;
    background:#f8f8f8;
}
img
{
  display: block;
  margin:0 auto;  /*圖片水平居中*/
  /* margin:0 0;  */ /*圖片水平居左,如需要請打開*/
  max-width:100%;
}
figcaption/*圖片描述文字*/
{
  margin-top:10px;
  text-align:center;
   /* text-align:left;  */ /*當圖片水平居左時,請打開*/
  color:#999;
  font-size: 0.7em;
}

/*================表格開始================*/
table
{
 display:table;
 width: 100% ;
 text-align: left;
}
tbody {
  border: 0;
}

table tr {
  border: 0;
  border-top: 1px solid #CCC;
  background-color: white;
 
}

/*隔行改變行的背景色,如需要請打開*/
/*
table tr:nth-child(2n) {
  background-color: #F8F8F8;
}
*/

table tr th, table tr td {
  font-size: 1em;
  border: 1px solid #CCC;
  padding: 0.5em 1em;
  text-align: left;
}
/*表頭的屬性*/
table tr th {
 font-weight: bold;
  background-color: #F0F0F0;
}
/*================表格結束================*/

/*================數學公式開始================*/
.katex-display {/*塊公式*/
  font-size:1.22em; 
}
.katex
{/*行內公式*/
  padding:8px 3px;
}
.katex-display > .katex
{/*塊公式*/
   display:inline-block;
   text-align:center;
   padding:3px;
}
.katex img
{/*行內公式對應的圖片*/
  display:inline-block;
  vertical-align:middle;
}
/*================數學公式結束================*/

a[href^="#"] sup
{/*注腳*/
  vertical-align:super;
  margin:0 2px;  
  padding:1px 3px; 
  color: #ffffff;
  background:#666666;
  font-size:0.7em;
}

/*================任務列表開始================*/
.task-list-list {
  list-style-type: none;
}
.task-list-list.checked {/*已完成*/
  color: #3e3e3e;
}

.task-list-list.uncheck {/*未完成*/
  color: #bfc1bf;
}
.task-list-list .icon_uncheck, .task-list-list .icon_check {
  display: inline-block;
  vertical-align: middle;
  margin-right: 10px;
}
.task-list-list .icon_check:before
{/*已完成*/
    content: "√";
    border: 2px solid #3e3e3e;
    color:red;
}
.task-list-list .icon_uncheck:before
{/*未完成*/
   content: "x";
   border: 2px solid #bfc1bf;
    color: #bfc1bf;
}
.task-list-list .icon_check:before, .task-list-list .icon_uncheck:before
{/*標志框*/
  padding:2px;
  padding-left: 5px;
  padding-right: 8px;
  border-radius:5px;
}
/*================任務列表結束================*/


.toc
{/*總目錄*/
  margin-left:25px;
}
.toc_item
{/*每條目錄*/
  display:block;

}
.toc_left
{/*每級目錄的縮進*/
  margin-left:25px;
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM