pre

Horizontally and vertically center a pre tag without the use of tables?

二次信任 提交于 2019-11-29 12:48:26
Is it possible to horizontally and vertically align a pre tag without tables? I want to vertically and horizontally align some ASCII art on a webpage. While I have already produced a successful adaption using tables , I want to know if its possible to convert it to using other elements and CSS. Every piece of ASCII art is a different height and width, so therefore it is important to note that the solution to my issue must involve not having a fixed height or width requirement. Thank you. Throw er in a div and center that div one of these ways http://tutorialzine.com/2010/03/centering-div

Simple HTML Pretty Print

◇◆丶佛笑我妖孽 提交于 2019-11-29 00:25:48
http://jsfiddle.net/JamesKyle/L4b8b/ This may be a futile effort, but I personally think its possible. I'm not the best at Javascript or jQuery, however I think I have found a simple way of making a simple prettyprint for html. There are four types of code in this prettyprint: Plain Text Elements Attributes Values In order to stylize this I want to wrap elements , attibutes and values with spans with their own classes. The first way I have of doing this is to store every single kind of element and attribute (shown below) and then wrapping them with the corresponding spans $(document).ready

Inserting a newline into a pre tag (IE, Javascript)

半世苍凉 提交于 2019-11-28 10:55:39
In IE when I insert text into a <pre> tag the newlines are ignored: <pre id="putItHere"></pre> <script> function putText() { document.getElementById("putItHere").innerHTML = "first line\nsecond line"; } </script> Using \r\n instead of a plain \n does not work. <br/> does work but inserts an extra blank line in FF, which is not acceptable for my purposes. These quirksmode.org bug report and comments about innerHTML behaviour of Internet Explorer could help: " IE applies HTML normalization to the data that is assigned to the innerHTML property. This causes incorrect display of whitespace in

Horizontally and vertically center a pre tag without the use of tables?

风流意气都作罢 提交于 2019-11-28 05:46:57
问题 Is it possible to horizontally and vertically align a pre tag without tables? I want to vertically and horizontally align some ASCII art on a webpage. While I have already produced a successful adaption using tables, I want to know if its possible to convert it to using other elements and CSS. Every piece of ASCII art is a different height and width, so therefore it is important to note that the solution to my issue must involve not having a fixed height or width requirement. Thank you. 回答1:

How to preserve whitespace indentation of text enclosed in HTML <pre> tags excluding the current indentation level of the <pre> tag in the document?

强颜欢笑 提交于 2019-11-27 18:57:34
I'm trying to display my code on a website but I'm having problems preserving the whitespace indentation correctly. For instance given the following snippet: <html> <body> Here is my code: <pre> def some_funtion return 'Hello, World!' end </pre> <body> </html> This is displayed in the browser as: Here is my code: def some_funtion return 'Hello, World!' end When I would like it displayed as: Here is my code: def some_funtion return 'Hello, World!' end The difference is that that current indentation level of the HTML pre tag is being added to the indentation of the code. I'm using nanoc as a

Display element as preformatted text via CSS [duplicate]

て烟熏妆下的殇ゞ 提交于 2019-11-27 18:14:00
This question already has an answer here: How to change a span to look like a pre with CSS? 7 answers Is there any way to emulate the display of a pre element via CSS? For example, can I keep the whitespace intact in this div by using a CSS rule? <div class="preformatted"> Please procure the following items: - Soup - Jam - Hyphens - Cantaloupe </div> BoltClock Use white-space: pre to preserve whitespace preformatting as in the pre element. To go a step further, also add font-family: monospace , as pre elements are typically set in a monospace font by default (e.g. for use with code blocks).

How to insert spaces/tabs in text using HTML/CSS

点点圈 提交于 2019-11-27 10:12:13
Possible ways: <pre> ... </pre> or style="white-space:pre" Anything else? To insert tab space between two words/sentences I usually use   and   Japol In cases wherein the width/height of the space is beyond   I usually use: For horizontal spacer: <span style="display:inline-block; width: YOURWIDTH;"></span> For vertical spacer: <span style="display:block; height: YOURHEIGHT;"></span> Halim Qarroum You can use   for spaces, < for < (less than, entity number < ) and > for > (greater than, entity number > ). A complete list can be found at HTML Entities . Abhishek Goel Try   . As per the

Inserting a newline into a pre tag (IE, Javascript)

隐身守侯 提交于 2019-11-27 03:53:22
问题 In IE when I insert text into a <pre> tag the newlines are ignored: <pre id="putItHere"></pre> <script> function putText() { document.getElementById("putItHere").innerHTML = "first line\nsecond line"; } </script> Using \r\n instead of a plain \n does not work. <br/> does work but inserts an extra blank line in FF, which is not acceptable for my purposes. 回答1: These quirksmode.org bug report and comments about innerHTML behaviour of Internet Explorer could help: " IE applies HTML normalization

Output of multiple post and pre increments in one statement [duplicate]

不问归期 提交于 2019-11-26 20:59:31
This question already has an answer here: Why are these constructs using pre and post-increment undefined behavior? 14 answers int b=0,a=1;b= ++a + ++a; what is the value of b? what is the calculation for it? [duplicate] 2 answers I'm new to C language so plz sum1 help me out. A C code written int i=3; printf("%d",++i + ++i); Complier gvs O/P =9. How? Thanx in advance The results are undefined. You're modifying a variable more than once in an expression (or sequence point to be more accurate). Modifying a variable more than once between sequence points is undefined, so don't do it. It might be

Display element as preformatted text via CSS [duplicate]

人盡茶涼 提交于 2019-11-26 19:21:18
问题 This question already has answers here : How to change a span to look like a pre with CSS? (7 answers) Closed last year . Is there any way to emulate the display of a pre element via CSS? For example, can I keep the whitespace intact in this div by using a CSS rule? <div class="preformatted"> Please procure the following items: - Soup - Jam - Hyphens - Cantaloupe </div> 回答1: Use white-space: pre to preserve whitespace preformatting as in the pre element. To go a step further, also add font