Solved

wrapping issue within a <div>

Posted on 2004-08-08
16
1,526 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
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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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 …

920 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

15 Experts available now in Live!

Get 1:1 Help Now