CSS 和 R 降价(bookdown)。如何在不更改整体模板的情况下使用 CSS 构建 css 框?
CSS and R markdown (bookdown). How can I use a CSS to build css boxes without changing the overall template?
好的,我认为这可能是一个非常幼稚的问题,但我没有找到任何有用的解决方案。
我有一个用于教学统计的“R markdown”,我在其中使用 CSS 文件为我所有的问题自定义一些外观。我已经导入了这个 CSS file from here,它非常酷,因为我可以轻松创建一个问题框,例如这个:
但是,现在,在我的 R Markdown 文件中,每次输入“1.”“2.”等时,它都会变成一个问题框。
如何修改 CSS 以防止将我的所有列表转换为“问题框”?
谢谢。
请检查下面的 CSS 文件:
body {
counter-reset: li; /* initialize counter named li */
}
h1 {
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
}
h2 {
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
margin-top: 24px;
}
ol {
margin-left:0; /* Remove the default left margin */
padding-left:0; /* Remove the default left padding */
}
ol > li {
position:relative; /* Create a positioning context */
margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */
padding:10px 80px; /* Add some spacing around the content */
list-style:none; /* Disable the normal item numbering */
border-top:2px solid #317EAC;
background:rgba(49, 126, 172, 0.1);
}
ol > li:before {
content:"Exercise " counter(li); /* Use the counter as content */
counter-increment:li; /* Increment the counter by 1 */
/* Position and style the number */
position:absolute;
top:-2px;
left:-2em;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
width:7em;
/* Some space between the number and the content in browsers that support
generated content but not positioning it (Camino 2 is one example) */
margin-right:8px;
padding:4px;
border-top:2px solid #317EAC;
color:#fff;
background:#317EAC;
font-weight:bold;
font-family:"Helvetica Neue", Arial, sans-serif;
text-align:center;
}
li ol,
li ul {margin-top:6px;}
ol ol li:last-child {margin-bottom:0;}
.oyo ul {
list-style-type:decimal;
}
hr {
border: 1px solid #357FAA;
}
div#boxedtext {
background-color: rgba(86, 155, 189, 0.2);
padding: 20px;
margin-bottom: 20px;
font-size: 10pt;
}
div#template {
margin-top: 30px;
margin-bottom: 30px;
color: #808080;
border:1px solid #808080;
padding: 10px 10px;
background-color: rgba(128, 128, 128, 0.2);
border-radius: 5px;
}
div#license {
margin-top: 30px;
margin-bottom: 30px;
color: #4C721D;
border:1px solid #4C721D;
padding: 10px 10px;
background-color: rgba(76, 114, 29, 0.2);
border-radius: 5px;
}
如果有人遇到同样的问题,这就是解决方案。
在 CSS 文件中,以特定字符串(如下)开始命令,然后在 Markdown 上使用 div 符号。如:
<div class="question">
1. My first question
1. My second question
</div>
/* -----------Question counter ---------*/
body {
counter-reset: li;
}
h1 {
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
}
h2 {
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
margin-top: 24px;
}
.question ol {
margin-left:0; /* Remove the default left margin */
padding-left:0; /* Remove the default left padding */
}
.question ol>li {
position:relative; /* Create a positioning context */
margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */
padding:10px 80px; /* Add some spacing around the content */
list-style:none; /* Disable the normal item numbering */
border-top:2px solid #317EAC;
background:rgba(49, 126, 172, 0.1);
}
.question ol>li:before,
.question ol>p>li:before {
content:"Questão " counter(li); /* Use the counter as content */
counter-increment:li; /* Increment the counter by 1 */
/* Position and style the number */
position:absolute;
top:-2px;
left:-2em;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
width:7em;
/* Some space between the number and the content in browsers that support
generated content but not positioning it (Camino 2 is one example) */
margin-right:8px;
padding:4px;
border-top:2px solid #317EAC;
color:#fff;
background:#317EAC;
font-weight:bold;
font-family:"Helvetica Neue", Arial, sans-serif;
text-align:center;
}
.question ol ol {
counter-reset: subitem;
}
.question li ol,
.question li ul {margin-top:6px;}
.question ol ol li:last-child {margin-bottom:0;}
好的,我认为这可能是一个非常幼稚的问题,但我没有找到任何有用的解决方案。 我有一个用于教学统计的“R markdown”,我在其中使用 CSS 文件为我所有的问题自定义一些外观。我已经导入了这个 CSS file from here,它非常酷,因为我可以轻松创建一个问题框,例如这个:
但是,现在,在我的 R Markdown 文件中,每次输入“1.”“2.”等时,它都会变成一个问题框。
如何修改 CSS 以防止将我的所有列表转换为“问题框”?
谢谢。
请检查下面的 CSS 文件:
body {
counter-reset: li; /* initialize counter named li */
}
h1 {
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
}
h2 {
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
margin-top: 24px;
}
ol {
margin-left:0; /* Remove the default left margin */
padding-left:0; /* Remove the default left padding */
}
ol > li {
position:relative; /* Create a positioning context */
margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */
padding:10px 80px; /* Add some spacing around the content */
list-style:none; /* Disable the normal item numbering */
border-top:2px solid #317EAC;
background:rgba(49, 126, 172, 0.1);
}
ol > li:before {
content:"Exercise " counter(li); /* Use the counter as content */
counter-increment:li; /* Increment the counter by 1 */
/* Position and style the number */
position:absolute;
top:-2px;
left:-2em;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
width:7em;
/* Some space between the number and the content in browsers that support
generated content but not positioning it (Camino 2 is one example) */
margin-right:8px;
padding:4px;
border-top:2px solid #317EAC;
color:#fff;
background:#317EAC;
font-weight:bold;
font-family:"Helvetica Neue", Arial, sans-serif;
text-align:center;
}
li ol,
li ul {margin-top:6px;}
ol ol li:last-child {margin-bottom:0;}
.oyo ul {
list-style-type:decimal;
}
hr {
border: 1px solid #357FAA;
}
div#boxedtext {
background-color: rgba(86, 155, 189, 0.2);
padding: 20px;
margin-bottom: 20px;
font-size: 10pt;
}
div#template {
margin-top: 30px;
margin-bottom: 30px;
color: #808080;
border:1px solid #808080;
padding: 10px 10px;
background-color: rgba(128, 128, 128, 0.2);
border-radius: 5px;
}
div#license {
margin-top: 30px;
margin-bottom: 30px;
color: #4C721D;
border:1px solid #4C721D;
padding: 10px 10px;
background-color: rgba(76, 114, 29, 0.2);
border-radius: 5px;
}
如果有人遇到同样的问题,这就是解决方案。
在 CSS 文件中,以特定字符串(如下)开始命令,然后在 Markdown 上使用 div 符号。如:
<div class="question">
1. My first question
1. My second question
</div>
/* -----------Question counter ---------*/
body {
counter-reset: li;
}
h1 {
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
}
h2 {
font-family:Arial, Helvetica, sans-serif;
font-weight:bold;
margin-top: 24px;
}
.question ol {
margin-left:0; /* Remove the default left margin */
padding-left:0; /* Remove the default left padding */
}
.question ol>li {
position:relative; /* Create a positioning context */
margin:0 0 10px 2em; /* Give each list item a left margin to make room for the numbers */
padding:10px 80px; /* Add some spacing around the content */
list-style:none; /* Disable the normal item numbering */
border-top:2px solid #317EAC;
background:rgba(49, 126, 172, 0.1);
}
.question ol>li:before,
.question ol>p>li:before {
content:"Questão " counter(li); /* Use the counter as content */
counter-increment:li; /* Increment the counter by 1 */
/* Position and style the number */
position:absolute;
top:-2px;
left:-2em;
-moz-box-sizing:border-box;
-webkit-box-sizing:border-box;
box-sizing:border-box;
width:7em;
/* Some space between the number and the content in browsers that support
generated content but not positioning it (Camino 2 is one example) */
margin-right:8px;
padding:4px;
border-top:2px solid #317EAC;
color:#fff;
background:#317EAC;
font-weight:bold;
font-family:"Helvetica Neue", Arial, sans-serif;
text-align:center;
}
.question ol ol {
counter-reset: subitem;
}
.question li ol,
.question li ul {margin-top:6px;}
.question ol ol li:last-child {margin-bottom:0;}