Solved

wrapping issue within a <div>

Posted on 2004-08-08
16
1,527 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Objects on Same Line 2 30
Add box and text color changing for everything 1 26
Create animated movies for web page 18 45
Place text over image using CSS 6 44
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…
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
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…

810 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