Jump to content

Recommended Posts

Posted

I have a list I am trying to display inline.

Here is the code.

 

Frames

 

By OSWM

 

DOS

 

By Richard O Robinson

 

Gears Of War

 

By Richard O Robinson

 

The Greener Side

 

By Shane Jeffers

 

Moment of Zen

 

By One|Te Productions

 

Add To The Garden

 

 

 

It should have two lines of text for each link, and I want it to be horizontal.

 

Here is my css for it.

 

#navlist a {

color: green;

}

 

#navlist {

list-style-type: none;

}

 

#navlist li{

display: inline;

 

}

 

Thanks for any help.

Posted

Try this:

 

The HTML:

></pre>
<ul id="navlist">
Frames
By OSWM

DOS
By Richard O Robinson

Gears Of War
By Richard O Robinson

The Greener Side
By Shane Jeffers

Moment of Zen
By One|Te Productions

Add To The Garden

 

The only thing I did to the above code is remove the

tags. Don't need if you set the to display block because you are defining an for each line you want.

 

 

The CSS:

#navlist {
   list-style: none;
}
#navlist li {
   display: inline;
   float: left;
}
#navlist li a {
   color: green;
   display: block;
   padding: 3px 15px;
       margin: 0;
}
#navlist li a:hover {
   text-decoration: none;
}

 

Two important elements here is that I added float: left to the #navlist li and display: block to #navlist a. Of course I've added a bit of padding/margins to give it a nice look.

Posted
Try this:

 

The HTML:

></pre>
<ul>
Frames
By OSWM

DOS
By Richard O Robinson

Gears Of War
By Richard O Robinson

The Greener Side
By Shane Jeffers

Moment of Zen
By One|Te Productions

Add To The Garden

 

The only thing I did to the above code is remove the

tags. Don't need if you set the to display block because you are defining an for each line you want.

 

 

The CSS:

#navlist {
   list-style: none;
}
#navlist li {
   display: inline;
   float: left;
}
#navlist li a {
   color: green;
   display: block;
   padding: 3px 15px;
       margin: 0;
}
#navlist li a:hover {
   text-decoration: none;
}

 

Two important elements here is that I added float: left to the #navlist li and display: block to #navlist a. Of course I've added a bit of padding/margins to give it a nice look.

 

You are a life saver my friend. That also helps me understand CSS a little bit more. What exactly does display: block do?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...