tags:

views:

89

answers:

2

I'm having a problem lining up some icons and am new enough to css that I'm not exactly sure how to explain this. So I've attached a picture of what the out put is rendering like. I've also included what the css and html code is. Hopefully someone can help point me in the right direction to help fix this.

I want the "edit", "archive", "delete" icons to all line up in the right side exactly the same as the first row in the picture.

Here is the html:

<ul id="nav">
<li>California
    <div class="portf_edit">
        <span>
            <img src="../images/edit.png">
        </span>
    </div>
    <div class="portf_archive">
        <span>
            <img src="../images/archive.png">
        </span>
    </div>
    <div class="portf_delete">
        <span>
            <img src="../images/delete.png">
        </span>
    </div>
</li>
<li>Hyrum
    <div class="portf_edit">
        <span>
            <img src="../images/edit.png">
        </span>
    </div>
    <div class="portf_archive">
        <span>
            <img src="../images/archive.png">
        </span>
    </div>
    <div class="portf_delete">
        <span>
            <img src="../images/delete.png">
        </span>
    </div>
</li>

Here is the css:

li {
list-style-type:none;
vertical-align: bottom;
list-style-image: none;
left:0px;
text-align:left;
}
ul {
list-style-type: none;
vertical-align: bottom;
list-style-image: none;
left:0px;
}
ul#nav{
margin-left:0;
padding-left:0px;
text-indent:15px;   
}

.portf_edit{
float:right;
position: relative;
right:50px;
display:block;
}
.portf_archive{
float:right;
position: relative;
right:-5px;
display:block;
}

.portf_delete{
float:right;
position: relative;
right: -60px;
display:block;
}

Here's what is being output:alt text

Any ideas where to start? Thanks.

+1  A: 

Add this to your CSS:

ul#nav div{
  overflow: hidden;
}

The gist of it is that your floating elements reduce the height of your divs to 0. If you add overflow: hidden to the div then the element will be forced to contain the floating elements and thus have a positive height.

Jeremy
Thanks for the reply. I added your code, but got the same result. I also tried adding "overflow:hidden;" to each class to see of that would make a difference, but I got the same result, the cascading display of the icons. Also, if it matters, I reduced the size of the images, just to see what would happen...nothing. Am I doing something wrong?
Ronedog
+1  A: 

The easiest way to fix this is to turn off the float by adding a clear to the LI style as shown below.

li {
 list-style-type:none;
 vertical-align: bottom;
 list-style-image: none;
 left:0px;
 text-align:left;
 clear: both; 
}
Jose Basilio
Thank you!. that worked! What is "clear: both" doing?
Ronedog
It basically turns off the effect of the float you have set in the divs so it doesn't carry over.
Jose Basilio
Thanks Jose. I did come accross another problem...different to this post, but somewhat related...thought you might have some tips there...here is the post if you want to answer it: http://stackoverflow.com/questions/2526441/css-problem-icons-being-pushed-to-bottom-of-li-tag-i-want-them-to-stay-at-t
Ronedog