1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Pushing an UL or LI to the right

Discussion in 'CSS' started by Lindsey2002, Nov 8, 2007.

  1. #1
    Hi,

    Is there a way to position an UL or LI a few pixels to the right (or left) without actually putting it in a box (div).

    I know that the "left" functions only works on a box so I was wondering if there is any other way of doing so.

    Thanks alot
     
    Lindsey2002, Nov 8, 2007 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Uhm, ok... you seem to misunderstand what a 'box' is - not that we call them 'boxes'... The correct term is 'block level element'

    WHERE people get this idea you can only apply values to div's is beyond me - I find out who's been spreading that one they are getting a serious beatdown. Too often you see **** like
    <div id="mainMenu">
    	<ul>
    		<li>Item</li>
    		<li>Item</li>
    		<li>Item</li>
    		<li>Item</li>
    		<li>Item</li>
    	</ul>
    </div>
    Code (markup):
    where unless you are applying a double border or multiple images, there's NO reason to do that since the same functionality can usually be done:

    <ul id="mainMenu">
    	<li>Item</li>
    	<li>Item</li>
    	<li>Item</li>
    	<li>Item</li>
    	<li>Item</li>
    </ul>
    Code (markup):
    ANYTHING you can apply to a DIV in CSS you can apply to a UL, a paragraph - in fact you can usually do it to most any tag, even changing the behavior of a tag like anchor by setting display:block;

    NOT that you should really be using left with position:relative in the first place since it leaves what I like to call the 'flow box' in place usually leading to headaches from hell. All you need to do is use margin-left.

    ul { margin-left:-5px; }

    should slide the ul 5px to the left.

    ul { margin-left:5px; }

    goes to the right.
     
    deathshadow, Nov 8, 2007 IP
  3. Lindsey2002

    Lindsey2002 Peon

    Messages:
    48
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks a lot for your help and explaining the elements.
     
    Lindsey2002, Nov 8, 2007 IP