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

x
?
Solved

wrapping issue within a <div>

Posted on 2004-08-08
16
Medium Priority
?
1,532 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
[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
  • 4
  • 3
  • 3
  • +4
16 Comments
 
LVL 36

Accepted Solution

by:
Zyloch earned 1500 total points
ID: 11749789
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_
ID: 11750845
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
ID: 11752559
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 31

Expert Comment

by:seanpowell
ID: 11752656
>>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
ID: 11752662
>>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
ID: 11752808
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
ID: 11752954
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
 
LVL 31

Expert Comment

by:seanpowell
ID: 11752997
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_
ID: 11753709
> 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_
ID: 11753751
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
ID: 11754078
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
ID: 11758262
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
ID: 11762819
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
ID: 11764712
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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

705 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