Solved

What am I doing wrong with this ordered list?

Posted on 2014-11-04
10
87 Views
Last Modified: 2014-11-06
Here's my site: http://www.brucegust.com/campaign/OOP/order_list.htm

Here's the tutorial I'm using: http://www.cssmojo.com/how_to_style_a_code_listing/#preview

Here's my code:

<!DOCTYPE html>
<html lang="en">
<head>
<title>Ordered List Test</title>
<style>
ol {
	background:#036 url(/img/gutter.gif) 2.3em 0 repeat-y;
	overflow:auto;
	font-family:"Courier New",Courier,mono;
	margin:0;
	padding:1em 0 1em 2.8em;
	color:#fff;
	width:90%;
}
#content ol li {
	background:#ffc;
	font-size:small;
}
#content ol code {color:#036;}
</style>
</head>

<body>

<ol>
<li><code>ol {background:#036 url(/img/gutter.gif) 2.3em 0 repeat-y;overflow:auto;font-family:"Courier New",Courier,mono;margin:0;padding:1em 0 1em 2.8em;color:#fff;width:90%}</code></li>
<li><code>ol li {background:#ffc;font-size:small;}</code></li>
<li><code>ol code {color:#036;}</code></li>
</ol>

</body>
</html>

Open in new window


I want my stuff to look like the tutorial, but all I get is that solid blue box as opposed to the blue margin and I can't figure it out.

What am I missing?
0
Comment
Question by:brucegust
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40422649
Check the url of that image it does not look like it loads so you might have the path wrong and it cannot be found.

Cd&
0
 

Author Comment

by:brucegust
ID: 40424426
Yo, COBOL! I corrected the URL and I'm still south of where I need to be.

In the example, the blue portion is 36 pixels across. Mine, I'm taking up the whole page with the blue color. Yet, it should be just the "<ol>" portion, right?

Where am I blowing it?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40424492
You have width of the ol set to 90% and the background color is going to fill the complete area of the ol block. Plus you have the background properties in reverse order and that be affecting the stacking order.  In the example the color #036 is specified last.  The CSS in the example is so badly written, that it is hard to folow and you will probably have a problem anytime you try and do maintenance on the page.  I generally avoid junk like that when I see the code is badly written.

Cd&
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

Author Comment

by:brucegust
ID: 40424601
I do like the effect, though. Is there anything salvageable about the code, or can you point me in the direction of a well written example of what they're doing.

Bottom line: I want to publish my code in the context of a numbered format like what they've got at http://www.cssmojo.com/how_to_style_a_code_listing/#preview. Is it tweak-able, or can you show me a different approach?

What do you think?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40424730
The effect is basically the result of applying padding to the ol and then overlaying the color with a background color on the text in the li elements.

If I wanted to do something like that I would just create a blue background image and the use background properties to limit its width so the ol ends up with a narrow vertical band on the left side, and the use the styling in the li elements to do the alternating rows.

ol {background-color:blue; background-repeat:repeat-y;background-position:left top;}
with a 40px square image should work fine. Then you just adjust the margin-left of the ol to move it in off of the background.

Cd&
0
 

Author Comment

by:brucegust
ID: 40424857
Got it!

Cd - two things: Head out to http://brucegust.com/campaign/OOP/order_list.htm and you'll see the improvements. What have I got to do to change the font color of the <li>'s? Looks great as far as the blue background and the white font, in terms of my numbers, but how can I get my text to stand out?

Also, in the example on http://www.cssmojo.com/how_to_style_a_code_listing/#preview, they use a <code> tag. That's just a CSS tool that you can use to ensure that the syntax you're documenting isn't processed as actual code, correct?
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 40424891
in the rule ol li you have a typo that inserted a single quote background:#ffc;' and it stops psrsing befor it gets to the color property.

The <code> tag is a formatting tag like <em> or <strong> it is generally used to make code stand out or use an alternate format.  If you want code to hold its format you can use <pre> normally white space is collapsed but inside <pre> all the white space is preserved as are the line feeds without having to use <br />

If you are going to display html code you either need to put it in a textarea, or hide the opening angle bracket with &lt; if you put <h2> in the text, the browser will treat it as a tag an turn everything following a a heading but if you use &lt;h2> then it will display <h2>

Cd&
0
 

Author Comment

by:brucegust
ID: 40424981
Cd - do you smell that? It's the smell of success! We're almost there, but I'm still missing something.

Head out to http://brucegust.com/campaign/OOP/order_list.htm and you'll see where I'm at. All I want to do is change the color of the <ol>. I did correct the typo, but we're still having to endure a pesky amount of consistency between the format of the <ol> number and the color of the text in my <li> tags.

What do you think? How can I make my <li> tags black>?
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 40427101
If you want the text a different color than the numbering then put the text in a span
(<li><span>Your text here</span></li>) so you can style it independently with:

ol li span{ color:purple; }

Then you can set the color on the ol and it will only affect the numbers.

Cd&
0
 

Author Closing Comment

by:brucegust
ID: 40427195
Perfect!
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Suggested Courses

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question