473,385 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how can one prevent a horizontal list from breaking?

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 23571
TheServant
1,168 Expert 1GB
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
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 Expert 256MB
If you give #container a height and overflow will be hidden.
Jul 13 '10 #4
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 Expert 256MB
Thats how I understood your problem. What exactly are you trying to achive if not to hide overflow?
Jul 14 '10 #6
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 Expert 1GB
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 Expert 256MB
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
@JKing
doesnt work. still breaks to a new line.
Jul 14 '10 #10
JKing
1,206 Expert 1GB
@crippletoe
I tested it and it works fine in Firefox and IE8.

Make sure you moved display:inline from #list to #list li.
Jul 14 '10 #11

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

Similar topics

1
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...
6
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? ...
8
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...
1
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">...
9
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...
1
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...
1
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
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...
1
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.