最近在使用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-100%;
}
figcaption/*图片描述文字*/
{
margin-top:10px;
text-align:center;
/* text-align:left; */ /*当图片水平居左时,请打开*/
color:#999;
font-size: 0.7em;
}
/*================表格开始================*/
table
{
display:table;
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;
}