Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

LI elements not on the same line

Posted on 2007-11-22
7
Medium Priority
?
936 Views
Last Modified: 2013-11-19
HI,

I wrote an ul li list. In the li tag, I out 2 img and 1 div. Div contains text with style="WHITE-SPACE: nowrap".
When I load it, on firefox evreything is ok, for each line, I see the 2 images and the texte.
On internet explorer, I see the 2 images and below the text.

Is there a solution, to see them on the same line ?

An example of my list :
<ul id="tree" style="display: block;">
  <li id="1" class="tree_node">
    <img id="icone_1" src="http:.../img1.gif">
    <img id="gadget_1" src="http:.../img2.gif">
    <div class="tree_text">Title 1</div>
    <ul id="sub_1" style="display:none">
      <li id="2" class="tree_node">
        <img id="icone_2" src="http:.../img1.gif">
        <img id="gadget_2" src="http:.../img2.gif">
        <div class="tree_text">Title 2</div>
        <ul id="sub_2" style="display:none">
          <li id="3" class="tree_node">
            <img id="icone_3" src="http:.../img1.gif">
            <img id="gadget_3" src="http:.../img2.gif">
            <div class="tree_text">Title 3</div>
            <ul id="sub_3" style="display:none">
              <li id="4" class="tree_node">
                <img id="icone_4" src="http:.../img1.gif">
                <img id="gadget_4" src="http:.../img2.gif">
                <div class="tree_text">Title 4</div>
                <ul id="sub_4" style="display:none">
                  <li id="5" class="tree_node">
                    <img id="icone_5" src="http:.../img1.gif">
                    <img id="gadget_5" src="http:.../img2.gif">
                    <div class="tree_text">Tilte 5</div>
                    <ul id="sub_5" style="display:none">
                      <li id="6" class="tree_node">
                        <img id="icone_6" src="http:.../img3.gif">
                        <div class="tree_text">Modalité d'adhésion</div>
                      </li>
                    </ul>
                  </li>
                </ul>
              </li>
            </ul>
          </li>
        </ul>
      </li>
    </ul>
  </li>
</ul>

Thanks

sroz
0
Comment
Question by:sroz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 5

Expert Comment

by:rucky544
ID: 20335131
try using <span class="tree_text">Title 1</span>
instead of <div class="tree_text">Title 1</div>

Span is an inline element and div is a block element.
0
 

Author Comment

by:sroz
ID: 20335190
I tried this. Now I have the same problem with ie and firefox. If the text is larger than panel, text is below images.
And now I get list where li of the same ul seem to be li of previous li.
0
 
LVL 1

Expert Comment

by:edenmachine
ID: 20335678
what does the class "tree_text" include?  Please post that code from your stylesheet code.

Alternatively - you can always use tables to insure the format is correct:

<li id="2" class="tree_node">
        <table>
               <tr>
                   <td><img id="icone_2" src="http:.../img1.gif"></td>
                   <td><img id="gadget_2" src="http:.../img2.gif"></td>
                   <td><div class="tree_text">Title 2</div></td>
               </tr>
        </table>

This will work 100% of the time but it's not the most optimal.  Div's will always wrap if unless you specifically tell them not to by using style="float:left;" or something to that effect depending on your layout.
0
Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

 
LVL 5

Expert Comment

by:rucky544
ID: 20336170
if you want the text to not go underneath then you are going to have to float the images to the left. This will allow the text to align with the top of the images.
0
 

Author Comment

by:sroz
ID: 20337829
I use these styles :

.tree_text
{
    CURSOR: pointer;
    PADDING-TOP: 3px;
    HEIGHT: 15px;
    WHITE-SPACE: nowrap;
}
.tree_img
{
    FLOAT: left;
    display:in-line;
}

tree_img is used on tag img
0
 
LVL 1

Accepted Solution

by:
edenmachine earned 750 total points
ID: 20338942
either get rid of the div tag altogether or try my table method.
0
 

Author Closing Comment

by:sroz
ID: 31410578
it works fine with table. Thanks
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question