How to get <pre> like behaviour, but ignore <br>
I have made my own custom little blog and well, I realized it was ignoring whitespace within code tags. Well, the generated code is like
<div class="codebody">
Mycode<br/>
other indented code<br/>
othercode<br/>
</div>
my codeb开发者_JS百科ody class looks like
.codebody {
background-color: #FFFFFF;
font-family: Courier new, courier, mono;
font-size: 12px;
color: #006600;
border: 1px solid #BFBFBF;
}
Well, how can I make it so that indentation will show up in code tags, but it won't add double-line breaks because of the <br/>\n
?
Well just figured out something.. I'm not sure that it works in all browsers, as it is a pretty nasty hack, but this is what I did
.codebody {
white-space: pre;
background-color: #FFFFFF;
font-family: Courier new, courier, mono;
font-size: 12px;
color: #006600;
border: 1px solid #BFBFBF;
}
.codebody br{
display: none;
}
精彩评论