仅通过 css 为代码添加行号 | code line number with CSS only

效果图:
在这里插入图片描述

完整代码:


<style>
pre > code{
	display:block;
	color:#fff;
	background:#282c34;
	
	/*
	font-size: 18px;
    line-height: 22px;

	
	border-radius:20px;
	width:80%;
	margin:0 auto;
	
	height:100%;
	overflow-y: scroll;
	*/
	
	padding:10px 20px;
	word-wrap: break-word;
    white-space: pre-wrap;
}

/* code line number
https://webtips.dev/add-line-numbers-to-html-textarea
*/
pre{counter-reset: linenumber;}
pre > code > span::before{
	content: counter(linenumber, decimal-leading-zero) " ";
	counter-increment: linenumber;
	color:#506882;
}
/*
pre > code > span{display: block;}
*/
</style>

<pre>
  <code>$ cat ./code/w.step2.FigureS22.MAIT_Tex.R
<br>
<span># This is a very long line. This is a very long line. This is a very long line. This is a very long line. This is a very long line. </span>
<span>library("Seurat")</span>
<span></span>
<span>RhpcBLASctl::omp_set_num_threads(1)</span>
<span>doParallel::registerDoParallel(cores=8)</span>
<span>options(stringsAsFactors=F)</span>
<span></span>
<span>oDir = "./OUT_FigS22"</span>
<span>dir.create(oDir, F, T)</span>
  </code>
</pre>
  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值