Include code in wordpress posts, the easy way
Saturday, April 11th, 2009Although there are different plugins out there to help you display your code, there is a very simple solution as well. It does not provide code colouring, linenumbers and all that, but it does create a nice readable non-overflowing area to display your code.
Simply put this in your style.css:
div.codewrapper {
border: 1px solid #DDD;
max-height:200px;
overflow:auto;
width:450px;
height: expression(this.scrollHeight > 200 ? “200px” : “auto”);
white-space:pre;
line-height: 100%;
font-family: Verdana, Arial, Sans-Serif;
font-size:10px;
}
Now if you create a div with class codewrapper, it will look like this:
Simply put this in your style.css:
div.codewrapper {
border: 1px solid #DDD;
max-height:200px;
overflow:auto;
width:450px;
height: expression(this.scrollHeight > 200 ? “200px” : “auto”);
white-space:pre;
line-height: 100%;
font-family: Verdana, Arial, Sans-Serif;
font-size:10px;
}