Ultrashock Forums > Development > Client Side
CSS - Problems with lists in IE, Opera and Firefox
Member Blogs
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
CSS - Problems with lists in IE, Opera and Firefox
Old 2008-03-16

I am setting up a navigation using an unordered list, but I am tearing my hair out trying to find an easy way that will work in all browsers to have one bit of text on the right hand side of the anchor tag and another bit on the left hand side of the anchor tag. So far all my attempts have failed. I've tried putting the text that I want on the right in a div and span tags (on separate attempts) and floating it to the right then adding a nevative bottom margin to push it up, but either Opera, Fire Fox or IE will show incorrectly when any of the other two display it correctly. It'd be nice to have a way to target Firefox in CSS like you can with IE becuse it's being such a pain.

I am looking for something like this

<ul>
<li><a>Text on the left Text on the right</a></li>
<ul>

I've tried putting the text on the right into a div tag and then floating it to the right, and then adding a negative bottom margin but Firefox doesn't like that and nor does Opera. When I take the negative bottom margin away, Opera displays it fine, and both bits of text are lined up horizontally, but not in IE or Firefox

<ul>
<li><a>Text on the left <div>Text on the right<div></a></li>
<ul>

I also tried something like this where the text to go on the right side goes in a div outside of the anchor tag (in the HTML) but when I float it to the right and use padding to line it up visually with the text on the left it works fine in Firefox and Opera, but not IE6

<ul>
<div>Text on the right<div>
<li><a>Text on the left</a></li>
<ul>

So any suggestions on how I can get one bit of text on the right hand side in an anchor tag and another bit on the left (obviously the width is such that there would be a gap in between) then I'd be grateful. Thanks so much in advance!
FredVaux.com | LightFused.net
postbit arrow 2 comments | 361 views postbit arrow Reply: with Quote   
flashkicks
Registered User
flashkicks is offline
seperator
Posts: 630
2005-06-17
Age: 19
flashkicks lives in United Kingdom
seperator

Ultrashock Member Comments:
Nutrox's Avatar Nutrox Nutrox is offline Nutrox lives in United Kingdom 1 Blog Entries 13 Creative Assets 2008-03-16 #2 Old  
Something like the following should work, but it depends how you have you li elements styled really:

XHTML Code:
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
  4.  
  5. <head>
  6.  
  7.     <title></title>
  8.  
  9.     <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
  10.     <meta http-equiv="content-language" content="en-gb"/>
  11.     <meta http-equiv="imagetoolbar" content="false"/>
  12.    
  13.     <meta name="mssmarttagspreventparsing" content="true"/>
  14.  
  15.     <style type="text/css">
  16.         ul, li
  17.         {
  18.             margin:0px;
  19.             padding:0px;
  20.             list-style:none;
  21.         }
  22.         li
  23.         {
  24.             width:200px;
  25.             text-align:right;
  26.         }
  27.         li span
  28.         {
  29.             float:left;
  30.         }
  31.     </style>
  32.  
  33. </head>
  34.    
  35. <body>
  36.  
  37.     <ul>
  38.         <li><span>Left</span> Right</li>
  39.         <li><span>Left</span> Right</li>
  40.         <li><span>Left</span> Right</li>
  41.     </ul>
  42.  
  43. </body>
  44.  
  45. </html>
Reply With Quote  
flashkicks flashkicks is offline flashkicks lives in United Kingdom 2008-03-16 #3 Old  
Wow, thanks nutrox. I can't beleive that simply swapping the text align to right and putting the first bit of text in a span, and then floating that solved it. I don't know what it is with right floats. Everything always seems to get messed up with right floats.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: