Solved

wrapping issue within a <div>

Posted on 2004-08-08
16
1,525 Views
Last Modified: 2011-09-20
Hi all,

I'm trying to make a div not wrap. I have 2 links one next to the other within a div as described below:

<html>
  <body>
    <div style="margin-left: 0;">
      <a href="#" style="background: url(../images/file.gif) no-repeat; float: left; height: 14px; width: 12px; padding-right: 3px; margin-left: 12px;">1111111111</a><a style="width:100%;" href="" >texttexttexttexttexttexttexttext</a>
    </div>
  </body>
</html>

The two links wrap no matter what I try to do.

Now, I can't replace the div. I have to use it because it is part of another very complex java-script.

Thanks,
Guy.

0
Comment
Question by:optimal
  • 4
  • 3
  • 3
  • +4
16 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 500 total points
Comment Utility
Hi

You have to set an explicit width for the <div>, for instance,

<div style="margin-left:0px;width:200px;">

The other thing you can try is this:

<nobr><a href="#" style="background: url(../images/file.gif) no-repeat; float: left; height: 14px; width: 12px; padding-right: 3px; margin-left: 12px;">1111111111</a><a style="width:100%;" href="" >texttexttexttexttexttexttexttext</a></nobr>


Regards,
Zyloch
0
 
LVL 2

Expert Comment

by:Joakim_
Comment Utility
Change the DIV-code to this: <div style="margin-left:0px;width:200px;" nowrap> (Just add a "nowrap" in the end of it.)
0
 

Author Comment

by:optimal
Comment Utility
Thanks guys,

but the problem I have is that the text within these two links is changing dynamically.
So I can't tell the size in advance.

Guy.
0
 
LVL 31

Expert Comment

by:seanpowell
Comment Utility
>>You have to set an explicit width for the <div>

That's possible - there's not enough information in the question to know if that's the best solution.

Also, <nobr> should be replace with the CSS white space property: white-space: nowrap

>>Just add a "nowrap" in the end of it
nowrap has been deprecated from the spec, and is not a valid attribute of a div tag anyways...
0
 
LVL 31

Expert Comment

by:seanpowell
Comment Utility
>>the text within these two links is changing dynamically
That's what I thought - can you post what's going on outside of the single div so we don't need to guess, or at least explain the interface that deals with this. The way you currently have it set up is rather odd...

Thanks,
Sean
0
 

Author Comment

by:optimal
Comment Utility
Sorry for not describing all of the outside information.

I have a JSP that is being populated from a database. Each record from the database is added to a "tree table" javascript.
Now the first column in each record is a combination of an icon link and a text link. The size of the link is based on whatever is coming from the database.

I have to use a <div> within the first <td> as described above in the code snippet for the javascript to work.

This jsp is than loaded into a frames screen and the user can change the size of the frame.
Unfortunately, when the frame is smaller than the width of the longest record, the record collapses after the icon and before the text link.

That's why a fixed length is not good. I don't know what the length is going to be.

I guess that if I could calculate the length is pixels of the links I could reset the width of the div, but I don't.

Thanks,
Guy.
0
 
LVL 6

Expert Comment

by:sathishv
Comment Utility
You can try setting the nowrap property to the cell.

<td nowrap>
<div style="margin-left: 0;">
      <a href="#" style="background: url(../images/file.gif) no-repeat; float: left; height: 14px; width: 12px; padding-right: 3px; margin-left: 12px;">1111111111</a><a style="width:100%;" href="" >texttexttexttexttexttexttexttext</a>
    </div>
</td>

Hope this helps.

Cheers,
Sathish
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 31

Expert Comment

by:seanpowell
Comment Utility
Still hard to tell how this suggestion will impact your layout. Here's one option, by modifying your table tag:

<table style="table-layout:fixed;">
0
 
LVL 2

Expert Comment

by:Joakim_
Comment Utility
> So I can't tell the size in advance.

So just remove the "width:200px;". I added it only because you had it in your code.
0
 
LVL 2

Expert Comment

by:Joakim_
Comment Utility
Oops, you didn't. I thought you did, because Zyloch did it. But just change it to <div nowrap>
0
 
LVL 12

Expert Comment

by:pigmentarts
Comment Utility
Really need to use CSS, it will still work. You could then set the position to absolute. There is also code which you could use in the CSS to stop the page from going below a limit, like:

body {
expression((this.parentNode.clientWidth<760)?760+"px":"auto");
font-size: 12px;
}

html > body { width: auto; min-width: 760px;}
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
The second link has a width of 100%.  That is 100% of the parent div.  Therefore if there is anything else in the div, the browser has no option except to warp unless there is an overflow property applied in the style.

Cd&
0
 

Author Comment

by:optimal
Comment Utility
I found the problem. For some reason the "float: left;" caused the div to wrap.
 I will give the answer to Zyloch.

Thanks everyone for your assistance.

Guy.
0
 

Author Comment

by:optimal
Comment Utility
Sorry for the grade, I didn't understand that "Avarage" meant those things.

I wanted to give the points to the person who was most close to solving the problem, but that the answer didn't 100% solve my specific issue.

If I can correct the grade I would be happy to do so because I didn't mean failure, or that I'm not satisfied. I think the response was very quick and helpful.

Thanks,
Guy.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now