Solved

What am I doing wrong with this ordered list?

Posted on 2014-11-04
10
85 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

751 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