我想将编号的源代码应用于特定标签,例如 <br>...我提供了两个示例,一个格式正确但不起作用,第二个格式正确并且它有效.. 我能做些什么开始工作第一个例子?
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>[Number Lines]</title>
<style type="text/css">
<!--
body {
background-color: #1F242C;
}
.title {
color: #E6E6FA;
font-family: 'Courier New', Courier, FreeMono, 'Nimbus Mono L', monospace;
font-size: 25px;
font-style: normal;
line-height: 50px;
font-weight: bold;
font-variant: normal;
margin: 45%;
}
.code {
background-color: #32363c;
border: #858687 1px solid;
border-radius: 7px;
color: #E6E6FA;
font-family: 'Courier New', Courier, FreeMono, 'Nimbus Mono L', monospace;
font-size: 13px;
font-style: normal;
line-height: 20px;
font-weight: normal;
font-variant: normal;
}
.code {
counter-reset: listing;
}
br {
counter-increment: listing;
}
.code br:before {
color: gray;
content: counter(listing, decimal-leading-zero);
margin-left: 3ex;
left: -3ex;
position: relative;
width: 2.5ex;
}
-->
</style>
</head>
<body>
<br><br><br>
<table class="code" align="center" border="0" cellpadding="15" cellspacing="0" width="70%">
<tr>
<td>
<span class="title">Example</span><br>
line of source code<br>
line of source code<br>
line of source code<br>
line of source code<br>
line of source code<br>
line of source code<br>
line of source code<br>
line of source code<br>
line of source code<br>
line of source code<br>
</td>
</tr>
</table>
</body>
</html>
这个例子不起作用,而下面的例子很好用!
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>[Number Lines]</title>
<style type="text/css">
<!--
body {
background-color: #1F242C;
}
.title {
color: #E6E6FA;
font-family: 'Courier New', Courier, FreeMono, 'Nimbus Mono L', monospace;
font-size: 25px;
font-style: normal;
line-height: 50px;
font-weight: bold;
font-variant: normal;
margin: 45%;
}
.code {
background-color: #32363c;
border: #858687 1px solid;
border-radius: 7px;
color: #E6E6FA;
font-family: 'Courier New', Courier, FreeMono, 'Nimbus Mono L', monospace;
font-size: 13px;
font-style: normal;
line-height: 20px;
font-weight: normal;
font-variant: normal;
}
.code {
counter-reset: listing;
}
code {
counter-increment: listing;
}
.code code:before {
color: gray;
content: counter(listing, decimal-leading-zero);
margin-left: 3ex;
left: -3ex;
position: relative;
width: 2.5ex;
}
-->
</style>
</head>
<body>
<br><br><br>
<table class="code" align="center" border="0" cellpadding="15" cellspacing="0" width="70%">
<tr>
<td>
<span class="title">Example</span><br>
<code>line of source code</code><br>
<code>line of source code</code><br>
<code>line of source code</code><br>
<code>line of source code</code><br>
<code>line of source code</code><br>
<code>line of source code</code><br>
<code>line of source code</code><br>
<code>line of source code</code><br>
<code>line of source code</code><br>
<code>line of source code</code><br>
</td>
</tr>
</table>
</body>
</html>
为什么我不能使用 <br> 来获得相同的结果?我哪里错了?感谢您对我的问题的任何答复...