wordpress - CSS Code styling - background color is missing on empty lines -


I hope it is simple I am not a CSS man

I try to make some code I am doing a bit better on blogs and I have the following & lt; Code & gt; is CSS style.

  code {display: block; White-space: normal; Background color: #eeeeee; Font: 1 AM, 'Courier New', Courier, Fixed; Padding: 7px; Margin: 7px 7px 7px 7px; }  

This is working well for me, except where my & lt; Code & gt; In the code contained in the tag, there are line breaks, background color is not white, light brown color.

Is there any CSS extractor, I have my entire & lt; Code & gt; Can I apply block color to a background color?

Thank you.

NOTE: If I place a space on the empty line, then what I find - a gray background of that line.

Note 2: I have only plain text to my & lt; Code & gt; & lt; / Code & gt; tag Ideally, I do not want to mark my code w / tags & lt; Code & gt; Cut and paste inside the tag and make it look good.

Last comment: After reading the following Mercator suggested, I finally went with it. I changed my code to & lt; Pre & gt; tags subclassed and want to offset my example code block to a well-shaded box.

  pre.code {color: black; Border: Solid 1px #eeeeee; Font size: 1.1m; Margins: 7px; Padding: 7px; Background: #eeeeee}  

This seems to work well for me, but then I

In any case, there are some abnormalities in your CSS:

  • I might use the display: block Will not, but & lt; P & gt; or & lt; Pre & gt; Wrap the tags in Changing it in the block as if you do not allow the nest block-level tag inside it, and still it will need to stay within the block-level tag CSS HTML syntax and cementix do not change Do you have a block-level tag inside your code tag?
  • Why did you set white-space: normal ? This is a bit unusual for a code block. How are you formatting your code? Do you see there & lt; P & gt; or & lt; Br> Adding Tags? font , or maybe white-location: pre-rap
  • why not use your font announcement There is a comma between the 1em and the font names that have been broken. The browser will now just parsize that such as 1em is the name of a font family, I think, and then Courier New , 1em is not present .
  • I think you mean to say monospace instead of fixed or fixed is the actual name of a font ? You can also add better Generic Monospace .
  • More than one tip: you can fall off those 4 margins even under one price.

I'm not sure that any of these are actually the cause of your problems. The first two most likely candidates are anything strange about the quick tests I have done, But some of your other CSS are building problems in combination with these points.

Aah, wait a minute ... Now I see that you are talking about making "some codes look a little better on a blog" Blog software is automatically adding paragraph tags around blocks of text different from blank lines. They are responsible for white color.

I think this is the reason why you added white spot: normal . Blog software is already adding line breaks and everything automatically (with & lt; p & gt; and & lt; br & gt; tag) , So a full bunch of extra spaces using the pre tag.

& lt; Pre & gt; & Lt; Code & gt; Try using stack overflow like tag synthesis & lt; Pre & gt; Using the tag, possibly (hopefully) the blog will stop the software from messing with your code.

For WordPress, check out your article "."


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -