...

View Full Version : Aligning list items



speck
11-24-2011, 07:51 AM
For some reason I cannot get the 2 items to line up side by side. I have the entire UL center aligned. http://shilohcreative.gethifi.com/work#/esque

Thanks so much for your help.

RNorskov
11-24-2011, 08:15 AM
I have no idea what two items you are speaking of, can you give a little more detail.

speck
11-24-2011, 08:35 AM
Sorry about that. I am dynamically loading portfolio projects. Identity and web presence are the list items I am speaking of. Thanks.

SB65
11-24-2011, 09:00 AM
At the moment you have those li elements within two different unordered list elements. Combine these into one:


<ul class="projects">

<li>

<a href="/work/esque/identity">
<div>
<img src="http://files.shilohcreative.gethifi.com/work/esque/identity/Identity-process-s306x-q100-t1322080711.jpg" alt="Identity">
</div>

<h3>Identity</h3>
</a>

</li>



<li>

<a href="/work/esque/web-presence">
<div>
<img src="http://files.shilohcreative.gethifi.com/work/esque/web-presence/Web_Presence-process-s306x-q100-t1322081130.jpg" alt="Web Presence">
</div>

<h3>Web Presence</h3>
</a>

</li>

</ul>

and make your css:


.projects li {
float: left;
height: 500px;
margin-right: 50px;
width: 300px;
}

speck
11-24-2011, 04:17 PM
Thank you for the help, but I need all list items centered horizontally. Usually i can just do this using display: inline instead of float: left for the list item. When I do display: inline, it stacks them again.

Also, how would I make it where each list item is vertically centered to each other?

Thanks so much!

speck
11-26-2011, 11:33 PM
Anyone know how to do this?

Thanks in advance!

speck
11-28-2011, 12:36 AM
Any help would be greatly appreciated. Just need to get the portfolio list items to horizontally center on page and vertically center with each other.

Thanks in advance!

Excavator
11-28-2011, 02:03 AM
Any help would be greatly appreciated. Just need to get the portfolio list items to horizontally center on page and vertically center with each other.

Thanks in advance!


In FF the two li's appear to be aligned vertically the same.
To center an element horizontally, you need three things:

a valid DocType
an element with a width
that elements right/left margins set to auto


That centers your ul inside containing #esque

speck
11-28-2011, 05:05 AM
I have tried so many suggestions, but it is still not working. There are 2 things I am needing to do. Please keep in mind these portfolio items are dynamically created and will vary.

1) Horizontally center align list items (identity, web presence, etc)
2) Vertically center align each list item with each other.

Thank you so much!

speck
11-28-2011, 08:17 AM
Sorry about that. I forget the view is changing as I work on the site. Here you go.... http://shilohcreative.gethifi.com/work#/esque. See the two list items... Identity and Web Presence.

Thanks

SB65
11-28-2011, 08:32 AM
To centre the items horizontally you need to change the lis back to display:inline, remove the float, but then you also need to make the divs and h3s contained within that li display:inline as well. Since these are block elements if you don't do that the lis will not align side by side. I'm not actually sure you need the div element at all.

Since it looks like your page uses javascript heavily I'd be inclined to vertically centre with javascript here.

speck
11-28-2011, 02:36 PM
I did the following:

- Removed the div
- Removed float: left
- Added display: inline to li and all elements within

We are close but not fully there: http://shilohcreative.gethifi.com/work#/esque

Thanks,
Josh

SB65
11-28-2011, 04:21 PM
I think you'll find that is centred - the effect is more obvious if you remove the margin-right on the li.

EDIT: Perhaps a better approach, guessing you want the h3 under the image:


.projects li {
display: inline-block;
margin-right: 50px;
}
.projects li h3 {
/*display: inline;*/
font-size: 14px;
margin-bottom: 30px;
text-align: center;
}

You might want to check that in IE, as IE7 and under don't always play well with inline-block.

speck
11-28-2011, 04:35 PM
The images are centered, but I am having trouble getting the h3 to center under each image. Also, how do I vertically align each list item. Thanks so much!

SB65
11-29-2011, 07:27 AM
Your page doesn't show the changes above - revert the h3 to display:block as well as making the li inline-block.

Vertically, as I said above, I'd suggest javascript.

speck
11-30-2011, 05:57 PM
I have tried getting assistance in the javascript forums, but they are pointing back to html/css. Do you mind helping me with this?

Thanks,
Josh

speck
12-01-2011, 07:50 PM
Can anyone help with this please? Thank you so much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum