Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

wrapping issue within a <div>

Posted on 2004-08-08
16
Medium Priority
?
1,534 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Without even knowing it, most of us are using web applications on a daily basis.  In fact, Gmail and Yahoo email, Twitter, Facebook, and eBay are used by most of us daily—and they are web applications. We generally confuse these web applications to…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
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)

927 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