jasonc Posted September 21, 2010 Share Posted September 21, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/213991-how-to-prevent-div-from-becoming-bigger-width-wise-when-url-or-long-line-is-in/ Share on other sites More sharing options...
SuperBlue Posted October 10, 2010 Share Posted October 10, 2010 The obvious method would be to break up long urls, and have a limit in place for how long a word can be. This can be done on the server side. Quote Link to comment https://forums.phpfreaks.com/topic/213991-how-to-prevent-div-from-becoming-bigger-width-wise-when-url-or-long-line-is-in/#findComment-1120716 Share on other sites More sharing options...
Colton.Wagner Posted October 14, 2010 Share Posted October 14, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/213991-how-to-prevent-div-from-becoming-bigger-width-wise-when-url-or-long-line-is-in/#findComment-1122221 Share on other sites More sharing options...
Colton.Wagner Posted October 14, 2010 Share Posted October 14, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/213991-how-to-prevent-div-from-becoming-bigger-width-wise-when-url-or-long-line-is-in/#findComment-1122229 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.