Jump to content

how to prevent DIV from becoming bigger width-wise when URL or long line is in


Recommended Posts

I have a few div on my page and the ones that have long lines or URL's are expanding width-wise.

 

 

<div style="width: 300px;">MyVeryLongLineThatCanAndMostLikelyContainsURLs</div>

 

 

I would like that the div keeps the same width, as the height is not a problem as the div contains other text, causing it to grow downwards anyway, and allow the line to break up with out causing any possible hyperlinks that are in the text to fail if clicked.

 

what happens is that the div grow wider to allow the long line to show inside.

  • 3 weeks later...

If you do not want the links to "break up" i would say try something like.

 

<style type="text/css">
#links {
   width: 300px;
   overflow: hidden;
}
</style>

 

basically what that will do is when something is in <div id="links"> it will make it so no matter how long the height is it keeps writing the link but will not show the text out some of 300px. I don't know if that is necessarily the direction you wish to go but you did not give much information on how you wanted it solved. Hope I could be of some help.

Thanks,

Colton Wagner

The code above should be:

#links {
white-space:nowrap;
width: 300px;
overflow: hidden;
}

 

I forgot to add the nowrap function sorry about that.

Thanks,

Colton Wagner

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.