TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-03-2008, 02:24 PM   #1 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default Problem with aligning list

I'm trying to display a list that uses my own image for the button and where the list items are on two lines like

HTML Code:
 Line 1
 text

 Line 2
 text

It all looks fine in FireFox but in IE, the second line is flushed left and the space between the button image and the text is too great. The text appears as

HTML Code:
 Line 1
text

 Line 2
text
The css I am using is
HTML Code:
ul { 
 list-style-image: url('images/bullet.jpg');
 font-family: Verdana, Arial, sans-serif;
 font-size: 10px;
 font-weight: normal;
 padding-left: 20px;
 margin-left: 0;
 margin-top: .5em;
}
li {
  margin-left: 0;
  margin-right: 0px;
  margin-top: .5em;
  margin-bottom: .5em;
  font-weight: bold;
  border: solid 1 px;
}
and the list code is
PHP Code:
<ul>
 <
li><a href="somedomain.com">Line 1<br>text</a></li>
 <
li><a href="somedomain.com">Line 2<br>text</a></li>
</
ul
Would someone please point out what I am doing wrong?
benton is offline  
Reply With Quote
Old 04-03-2008, 03:36 PM   #2 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I wouldn't recommend using a custom image for an LI. Rather, set the background of the LI to your custom image, and set list-style-type to none. Like so:

css Code:
list-style-image: none;
background: transparent url('images/bullet.jpg') center left;

This way it'll be all the same in all the browsers. Well, this way at least you stand a little more chance!

Incidentally, welcome to the community. It's good to have you here .
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 04-03-2008, 04:07 PM   #3 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

Thank you for the quick response. I tried making the changes you suggested
HTML Code:
ul { 
 list-style-image: none;
 font-family: Verdana, Arial, sans-serif;
 font-size: 10px;
 font-weight: normal;
 padding-left: 20px;
 margin-left: 0;
 margin-top: .5em;
}
li {
 background: transparent url('images/bullet.jpg') center left;
 background-repeat: no-repeat;
 margin-left: 0;
 margin-right: 1px;
 margin-top: .5em;
 margin-bottom: .5em;
 font-weight: bold;
}
Unfortunately, that causes the default bullet to be displayed along with mine and the alignment problem is still there.

Thank you for the welcome. I ran across this site while searching for a solution to a php problem I was having. I was so pleased as I skimmed the various formums since there seemed a wealth of information. I look forward to going through past posts when I have the time.
benton is offline  
Reply With Quote
Old 04-03-2008, 04:52 PM   #4 (permalink)
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

set list-style: none; instead of list-style-image: none; That will get rid of the default bullets.
__________________
Eric
wGEric is offline  
Reply With Quote
Old 04-03-2008, 05:27 PM   #5 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

Thanks. That took care of the default image. Does anyone have any suggestions on how to align the text? I can force it aligned by adding padding for the line but then FireFox is out of alignment.
benton is offline  
Reply With Quote
Old 04-03-2008, 10:21 PM   #6 (permalink)
The Wanderer
 
dylanfm's Avatar
 
Join Date: Jan 2008
Location: Australia
Posts: 14
Thanks: 1
dylanfm is on a distinguished road
Default

To deliver IE specific code, use IE conditionals.

For example:
Code:
<!--[if IE]>
	<link rel="stylesheet" href="..." type="text/css" media="screen, projection" charset="utf-8" />
<![endif]-->

<!--[if lte IE 6]>
	<link rel="stylesheet" href="..." type="text/css" media="screen, projection" charset="utf-8" />
<![endif]-->

<!--[if !IE]>
	<link rel="stylesheet" href="..." type="text/css" media="screen, projection" charset="utf-8" />
<!-- <![endif]-->
Send a message via ICQ to dylanfm
dylanfm is offline  
Reply With Quote
Old 04-05-2008, 04:09 PM   #7 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

I'm not at a point where conditionals would make a difference since none of the code I have tried works in IE.
benton is offline  
Reply With Quote
Old 04-05-2008, 05:04 PM   #8 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

HTML Code:
ul    {margin:0.5em 0 0 20px; list-style:none; font-family: Verdana, Arial, sans-serif; font-size: 10px;}
ul li {margin:0 1px 1em 5px; background: transparent url('images/bullet.jpg') center left; background-repeat: no-repeat; font-weight: bold;}
Should work fine. Both IE and Firefox maintain the margin, no matter how many breaks you use in your <li> </li> elements.
-m
delayedinsanity is offline  
Reply With Quote
Old 04-06-2008, 01:01 AM   #9 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

My problem turned out to be a silly coding problem. The list is in a table but the <td> was missing. I found that while I was setting up a test site to show it here. I do apologize for wasting the members time with such a mistake but I may not have found it without everyone's help.

After fixing that, there is only one problem left. The bullet is not in the same position for lists that have two lines and for one that has one line. I have uploaded an example here New Page 1 The complete code for that example is as follows. I tried playing around with the settings but I don't really know which would control something like that, even if it is controllable. I would appreciate it if someone would take a look at this last problem.
HTML Code:
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><title>New Page 1</title>
<style type="text/css">
ul    {margin:0.5em 0 0 20px; list-style:none; font-family: Verdana, Arial, sans-serif; font-size: 10px; border: 0px; padding: 0px;}
ul li {
 margin:0 1px 1em 1px;
 background: transparent url('images/bullet.jpg') center left; background-repeat: no-repeat; 
 font-weight: bold;
 padding-left: 20px;
}
</style>
</head>
<body>
 <table border="0" cellpadding="0">
  <tr>
   <td>
    <ul>
     <li><a href="somepage.com">Line One<br>Line Two</a></li>
     <li><a href="somepage.com">Line One<br>Line Two</a></li>
     <li><a href="somepage.com">Line One<br>Line Two</a></li>
    </ul>
   </td>
  </tr>
  
  <tr>
   <td>
    <ul>
     <li><a href="somepage.com">Line One</a></li>
     <li><a href="somepage.com">Line One</a></li>
     <li><a href="somepage.com">Line One</a></li>
    </ul>
   </td>
  </tr>
 </table>
</body>
</html>
benton is offline  
Reply With Quote
Old 04-06-2008, 01:19 AM   #10 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

You want to change the following,

background: transparent url('images/bullet.jpg') center left;

to

background: transparent url('images/bullet.jpg') no-repeat top left;
delayedinsanity is offline  
Reply With Quote
Old 04-06-2008, 01:25 PM   #11 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

Thanks, that made them all consitent. But the bullets are positioned too high now (more so in IE). See example Are there commands that allow specific positioning like margin and padding that will fix this?
benton is offline  
Reply With Quote
Old 04-07-2008, 09:25 PM   #12 (permalink)
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

Use something like

css Code:
background: transparent url('images/bullet.jpg') no-repeat 5px 0;

Change the 5px until it is centered with the first line.
__________________
Eric
wGEric is offline  
Reply With Quote
The Following User Says Thank You to wGEric For This Useful Post:
delayedinsanity (04-07-2008)
Old 04-06-2008, 01:57 PM   #13 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

You can play with the margin/padding and/or line-height settings, but your best bet honestly is to edit the image and add some whitespace to the top of it. Do you have anything like Jasc PaintShopPro, perhaps lucky enough to run Adobe Photoshop, or perhaps you've got the Gimp? Anything would work.

If you don't, use this copy I edited for you.
-m
delayedinsanity is offline  
Reply With Quote
Old 04-07-2008, 10:09 PM   #14 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

I didn't realize you could give it a pixel setting... always something new to learn.
delayedinsanity is offline  
Reply With Quote
Old 04-08-2008, 11:51 AM   #15 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

Thanks for everyone's help. The display is still not correct but getting closer. I will keep playing around with all of the suggestions.
benton is offline  
Reply With Quote
Old 04-08-2008, 10:18 PM   #16 (permalink)
The Acquainted
 
wGEric's Avatar
 
Join Date: Nov 2007
Posts: 166
Thanks: 0
wGEric is on a distinguished road
Default

Using the example site you listed above I edit the CSS and this lined the bullets up with the center of the first line.

css Code:
ul    {margin:0.5em 0 0 20px; list-style:none; font-family: Verdana, Arial, sans-serif; font-size: 10px;
 border: 0px;
 padding: 0px;
 }
ul li {
 margin:0 1px 1em 1px;
 background: transparent url('images/bullet.jpg') no-repeat 0 2px;
 font-weight: bold;
 padding-left: 20px;
}
Originally I had my numbers backwards. It's x position and then y position.
__________________
Eric
wGEric is offline  
Reply With Quote
Old 04-09-2008, 03:09 AM   #17 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

What browser are you using to view it? I ask because I made the change you suggested but when I view this page in IE 7, the bullet is too high. I've tried all of the suggestions mentioned here and then a lot of trial and error type guesses. But I can never get it looking any better than how it is now. In FireFox, it looks pretty much perfect no matter what changes are made.
benton is offline  
Reply With Quote
Old 04-09-2008, 11:57 AM   #18 (permalink)
The Frequenter
 
Join Date: Dec 2007
Location: In my basement
Posts: 386
Thanks: 47
Aaron is on a distinguished road
Default

make the first number in the ul li background 50% (it might be a little high, move the number around a little if it is.)
__________________
Signatures are nothing but incriminating.
Send a message via MSN to Aaron
Aaron is offline  
Reply With Quote
Old 04-11-2008, 06:33 PM   #19 (permalink)
The Contributor
 
Join Date: Apr 2008
Posts: 78
Thanks: 0
benton is on a distinguished road
Default

This last was enough to make it close enough between the two browsers so I'm all set.

Once again,I appreciate everyone's input on this. I wouldn't have come close without the help found here.
benton is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 09:46 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design