473,834 Members | 1,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how can one prevent a horizontal list from breaking?

9 New Member
Hi all, i am looking for a way to prevent a horizontal, inline unordered list from breaking into seperate lines once contained inside a element with specific width (shorter than the list). the element has "overflow" set to "hidden".

the only way i found to create that effect is by giving a specific width to the "UL" element but now, i have to create that effect for a list with unknown width!! (user can add items to list). is there any other way? it would help me so much!!

thank you all
Jul 13 '10 #1
10 23753
TheServant
1,168 Recognized Expert Top Contributor
Can you give an example of some (shortened) code of you current HTML and CSS? Also a screenshot if you think it would help.
Jul 13 '10 #2
crippletoe
9 New Member
i will try to post a link to an example page but consider this code in the meanwhile:
HTML:
Expand|Select|Wrap|Line Numbers
  1. <div id="container">
  2. <ul id="list">
  3. <li>item1</li>
  4. <li>item2</li>
  5. <li>item3</li>
  6. <li>item4</li>
  7. <li>item5</li>
  8. <li>item6</li>
  9. <li>item7</li>
  10. </ul>
  11. </div>
  12.  
CSS:
Expand|Select|Wrap|Line Numbers
  1. #container{
  2. width: 200px;
  3. overflow: hidden;
  4. }
  5. #list{
  6. display: inline;
  7. }
  8.  
  9. #list li{
  10. float: left;
  11. }
  12.  
the list is horizontal and if it is wider than the width of the <div> it will break and continue on a new line.
i would like it to go on on the same line beyond the border of the #container DIV.
Jul 13 '10 #3
zorgi
431 Recognized Expert Contributor
If you give #container a height and overflow will be hidden.
Jul 13 '10 #4
crippletoe
9 New Member
i am afraid this does not prevent the UL from breaking it will simply hide the vertical overflow caused by the line breaking.
Jul 14 '10 #5
zorgi
431 Recognized Expert Contributor
Thats how I understood your problem. What exactly are you trying to achive if not to hide overflow?
Jul 14 '10 #6
crippletoe
9 New Member
i am trying to create a horizontal scroller on the container div. overflow will be set to auto than but i cannot even get to that stage because the list keeps breaking to a new line when it reaches the border of the div and so there is no need for the horizontal scroller..
Jul 14 '10 #7
JKing
1,206 Recognized Expert Top Contributor
Expand|Select|Wrap|Line Numbers
  1. #container{
  2. width: 200px;
  3. overflow-y:hidden;
  4. overflow-x:scroll;
  5. white-space:nowrap;
  6. }
  7. #list{
  8.  
  9.  
  10.  
  11. }
  12.  
  13. #list li{
  14. display: inline;
  15.  
  16. }
Is this what you are looking for?
Jul 14 '10 #8
zorgi
431 Recognized Expert Contributor
similar :


Expand|Select|Wrap|Line Numbers
  1.  
  2. #container{
  3.     width: 200px;
  4.     overflow: auto;        
  5. }
  6. #list{
  7.     white-space:nowrap;
  8.     padding: 0;
  9.     margin: 0;
  10. }
  11. #list li{
  12.     display: inline;
  13. }
  14.  
  15.  
Jul 14 '10 #9
crippletoe
9 New Member
@JKing
doesnt work. still breaks to a new line.
Jul 14 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5020
by: RugbyTravis | last post by:
I want to have a list that is horizontal and each <li> has different images. I also want them to change on hover. I want the words to be below the images as well. Anyone of you styles gurus have any words of wisdom? Please! :-) Here is what I have so far. <!--styles--> ul#mainNav{ font: bold 80% Verdana;
6
2391
by: ciwstudy | last post by:
I'm having problems getting the height to compress for a horizontal list in IE (styled with CSS). It works fine in other browsers. Does anyone know a way to fix this? http://www.uky.edu/Home/Web/newnavbar/
8
13880
by: Nathan | last post by:
I am trying to prevent a horizontal list from wrapping. Each list item is floated with "float: left". Currently I use an ugly hack. I set the width of the list to a large number which is guananteed greater than the total width of all items. Is there a way to accomplish this without my hack? It would be handy because I would like to read the total width of all items in javascript. I looked into white-space: nowrap, but it doesn't work...
1
1701
by: DarthDevilous | last post by:
I've been trying to lay out a list horizontally, like at http://www.w3schools.com/css/tryit.asp?filename=trycss_float5 , but I'm having some problems. The HTML Structure is <div id="page_footer"> <ul id="categories"> <li><div class="category"> Home <ul> <li><a>somelink</a></li> etc
9
3345
by: Verona Busch | last post by:
Hi everybody, I am very happy to find this group. I am searching for a solution to make a horizontal list menu with submenu on hover. I found a lot of examples for horizontal lists which open vertical lists on :hover i.e. http://phoenity.com/newtedge/horizontal_nav/ But what I am looking for is a horizontal list that opens another horizontal list and both need to be right-floated.
1
1639
by: irq3 | last post by:
I want to make a horizontal list elements, whose widths are determined by their "width" property. "width" doesn't work on inline elements, so I can't use <spanas I normally would if the width was determined by content. I played around with float: left, display: block, position: absolute, trying to get them to work properly and I've had some level of success, but I'm looking for some advice from the gurus on how to do this properly.
1
6182
by: nitinpatel1117 | last post by:
i am using an unordered list to display my horizontal navigation. i am using something link <ul> <li>link 1</li> <li>link 2</li> </ul>
1
5498
by: Jason | last post by:
I have an application that sends HTML emails. The HTML is basically a template that I provide, but part of the HTML is supplied by the user. Sometimes the user inadvertently supplies HTML which cause the the email recipient to have to scroll horizontally to see it. Is there any tag that I can use in my template to enclose the user HTML to make sure that doesn't happen? I've tried enclosing it in <table width="100%"but that doesn't...
1
1697
by: icancreate | last post by:
Anyone know how I can achieve the following. I want to place an animated banner into my homepage that extends beyond the width of the viewing area in the web browser without the browser displaying a horizontal scroll bar. Any ideas? My homepage is centered in the browser window with a fixed width of 960pixels wide.
0
9796
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10790
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10545
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10214
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6952
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5790
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4425
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3079
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.