CSS - Li Width In Horizontal Lists
how can i make list items that are in a horizontal list all the same width. I try adding the width attribute to it but it has no effect
Similar TutorialsI have a horizontal list using <ul> but the last two items in the list i want aligned to the right of the page but how do i do this? PHP Code: <div id="menu"> <ul> <li>home</li> <li>browse</li> <li>artists</li> <li id="selected">collections</li> <li>news</li> <li>how to buy</li> <li>trade</li> <li>mailing list</li> <li>e-card</li> </ul> </div> above is my list Working on converting the layout in the attached image and I'm having a problem with the main menu. Here are my problems: *trying to push down the menu items. Setting padding-top only seems to extend the borders up above the horizontal line and doesn't push the text down. *getting the highlight color above the text. Some ideas I had were trying to set a background image for each list item (but how can I do this without the borders extending above the horizontal line) or setting a background image of the whole unordered list (but with this will "break" when users have different font sizes). Any thoughts? Layout is attached as well as what little code I have since I'm just starting on this project. Thanks in advance, -b Hello all, I am trying to make a horizontal nav bar using a list. Everything was going good until I tried to add an image (essential a line) to seperate each <li>. When I did this, the height of the nav bar expanded and it moved the entire list down about 15 pixels or so. I am attaching an image before I added the image and after I added the image to show. Here is my css code for before I add the image: PHP Code: #navbar { height:37px; line-height:33px; padding: 2px 0 0 10px; vertical-align:top; background: url(images/linkbarbg1.png) repeat-x; font-family: Tahoma, Georgia, "Times New Roman", Times, serif; font-size: 18px; color: #FFFFFF; } #navbar ul { vertical-align:top; margin:0; padding:0; border: 0px solid #000000; } #navbar ul li { display: inline; } #navbar ul li a { display: inline; text-decoration: none; padding-top: 5px; padding-bottom: 4px; padding-right: 10px; padding-left: 10px; color:#FFFFFF; } #navbar ul li a:hover { height: 31px; background:url(images/linkbarbg1hover.png) repeat-x top left; background-color: #FF3300; } And HTML: PHP Code: <div id="main"> <div class="leftshadow"> <div class="rightshadow"> <div id="header"><img src="images/logo1.png" /></div> <div id="navbar"> <ul> <li><a href="#">Milk</a></li> <li><a href="#">Eggs</a></li> <li><a href="#">Cheese</a></li> <li><a href="#">Vegetables</a></li> <li><a href="#">Fruit</a></li> </ul> </div> </div> </div> And here is what it looks like: My CSS Code is the same for after, here is my HTML code for after: PHP Code: <div id="main"> <div class="leftshadow"> <div class="rightshadow"> <div id="header"><img src="images/logo1.png" /></div> <div id="navbar"> <ul> <li><a href="#">Milk</a></li> <li><img src="images/linkbarseperator1.png" /></li> <li><a href="#">Eggs</a></li> <li><a href="#">Cheese</a></li> <li><a href="#">Vegetables</a></li> <li><a href="#">Fruit</a></li> </ul> </div> </div> </div> and here is what is looks like: Is there a way to fix this? UPDATE I have noticed the same thing happens even when it is not a list. Therefore, it must be due to some other factor...does anyone have any ideas? Hi Is there a way to create a 100% width (liquid layout without table) Horizontal menu using <UL><LI>. I searched Google, but i found only the menus aligned either towards left or middle. Not extending to full width. When i give "width: auto" for LI then all the links get aligned towards the left. Or if i specify some particular width say 12.5% for each Li then when i make it to 800x600 screen its wrapping to second line. Hi there, Is it possible to set a border's width? when I say width I mean it's horizontal width not height. Many thanks Hi, is there anyway to make the horizontal menu on the top of the webpage fit the entire width of the screen along with the titlebar? I mean, irrespective of the number of menu items, the menu should be exactly as wide as the screen. Thanks. Is there any way to have horizontal list items automatically fill any given width? for example, If I have 5 list items, I can set each width to 20% and the list will fill the width of the container, but if I don't set a width, then they collapse to the left. the behavior I'm after is like a table. The 'old' way to create a horizontal list would be to create a table with one row and 5 cols. Setting the width of the table to 100% would make each cell 20% automatically. Any way to accomplish this in css without explicitly setting the width? new to the world of css and now working on a shell for a website I'm doing. here is the css PHP Code: html, body{ margin:0; padding:0; } h1, h2, h3, h4, h5, h6 { color: #bf9060; } img { padding-bottom: 2px; } #pagewidth{ width:100%; min-width: 500px; } #header{ height:88px; width:100%; background:#ccae8f; background-image: url("/images/pillowback3.jpg"); background-repeat: repeat-x; } #navcontainer { margin: 0; padding: 0; height: 25px; width: 100%; } #navcontainer ul { border: 0; margin: 0; padding: 0; list-style-type: none; text-align: center; } #navcontainer ul li { display: block; float: left; text-align: center; padding: 0; margin: 0; } #navcontainer ul li a { background: #ffffff; width: 125px; height: 18px; border: 1px solid #ccae8f; padding: 0; margin: 0; color: #000000; text-decoration: none; display: block; text-align: center; font: normal 14px/22px "Lucida Grande", "Lucida Sans Unicode", verdana, lucida, sans-serif; } #navcontainer ul li a:hover { color: #ffffff; background: #806c59; } #navcontainer a:active { background: #806c59; color: #ffffff; } #navcontainer li#active a { background: #c60; border: 1px solid #c60; color: #fff; } and the list PHP Code: <div id="navcontainer"> <ul id="navlist"> <li><a href="/pillows.php" title="Everything you need for your pillow needs">Home</a></li> <li><a href="/build/index.php" title="Start here for the Best Pillows the net has to offer">Build</a></li> <li><a href="/samples/index.php" title="Pick up to 8 samples ">Samples</a></li> <li><a href="/products/index.php" title="See our full line of Products">Products</a></li> <li><a href="/about/index.php" title="Meet our staff. How PillowWorks works.">About</a></li> <li><a href="/contact/index.php" title="Contact us for any reason">Contact</a></li> </ul> </div> as you can see i'm using px to style the size of the elements, but that isn't very liquid I am trying to get a page that has 3 boxes in a row (horizontally) with the first two having a fixed width, and my problem is getting the third one to take up the rest of width - so I don't have to specifiy a width for the third one. I have tried the auto width which works great and shows up perfectly in Firefox but just leaves a not very wide box in IE. There is probably an easier or cleaner way to do this but this is what I have so far: CSS: #box1 { width:70px; height:120px; text-align:right; padding:10px; border: 1px solid gray; font-size:10px; position:absolute; top:250px; left:0px; } #box2 { width:70px; height:120px; text-align:right; padding:10px; border: 1px solid gray; font-size:10px; position:absolute; top:250px; left:97px; } #box3 { width:auto; /*WIDTH IN QUESTION*/ height:120px; text-align:right; padding:10px; border: 1px solid gray; font-size:10px; position:absolute; top:250px; left:194px; right:0px; } HTML: <body> <div id="box1">TEST</div> <div id="box2">TEST</div> <div id="box3">TEST</div> </body> Gday CSS PPL, Im still yet to test on other browers, but im using IE 6.0 while the explorer is full screen the width of my div is 100% But when i resize the browser on the horizontal untill a horizontal scroll bar appear, and scroll to the right, the div cuts off where the scrolling begins, div.banner { background-image: url(../images/banner_repeat.gif); width:100%; height:163px; text-align:center; } and yeah, the background image 'banner_repeat' stops repeating at that point. any help would be great, Thx in advance, James I found this code online and I'm trying to alter it slightly for what I need. Code: <html> <head> <style type="text/css"> body,html { padding: 0; margin: 10; } #navcontainer ul { list-style-type: none; padding: 0; margin: 0; text-align: center; } #navcontainer ul li { display: inline; } #navcontainer ul li a { text-decoration: none; padding: .2em 1em; color: #fff; background-color: #036; } #navcontainer ul li a:hover { color: #fff; background-color: #acf; } </style> </head> <body> <div id="navcontainer"> <ul> <li><a href="#">Content</a></li> <li><a href="#">Photographs</a></li> <li><a href="#">Events</a></li> <li><a href="#">Estate</a></li> </ul> </div> </body> It gives a nice center-aligned horizontal CSS menu. What I'm wondering is: How do I make it so that the width of each of the blue boxes the links are in are the same width? Say I want them all width: 180px; Where do I put that style so that it applies to all the links? [On a related issue, the style sheet has 4 things related to #navcontainer. How does one know which one of these to put additional styles in?] Thanks Much. j 9 Hi, Here is my problem: I have a horizontal css menu using a list. It is embedded within a table <td> element. The menu is floating to the left as I suppose is inteneded by the css code, but I want the whole list to be centered with respect to the <td> element. I put <td align=center> but that does not center the whole list. It is still flushed against the left side of the <td> element. Also, I want the entire list to cover the entire width of the <table>. How do I accomplish these tasks? I have searched on google without any success. thank you for your help in advance. Here is the CSS code and Html code for your reference: CSS: Code: <style type="text/css"> .horizontalcssmenu ul{ margin: 0; padding: 0; list-style-type: none; } /*Top level list items*/ .horizontalcssmenu ul li{ position: relative; display: inline; float: left; } /*Top level menu link items style*/ .horizontalcssmenu ul li a{ display: block; width: 80px; /*Width of top level menu link items*/ #width: 95px; _width: 95px; padding: 2px 8px; border: 0px solid #202020; border-left-width: 0; border-right-width: 0; text-decoration: none; /*background: url(http://asc2009.dreamhosters.com/menubg.gif) center center repeat-x;*/ color: white; font: bold 13px Tahoma; } .horizontalcssmenu ul li a:visited{ color:white; #color:white; /*background: url(menubgover.gif) center center repeat-x;*/ } .horizontalcssmenu ul li a:hover{ background: yellow; color: blue; #color: blue; /*background: url(menubgover.gif) center center repeat-x;*/ } HTML Code: Code: <table width="900" height="20" border="0" cellpadding="0" cellspacing="0" style="border-bottom:1px solid black;"> <tr> <td background="menubg.jpg" align="center"> <div class="horizontalcssmenu" align="center"> <ul> <li><a href="default.htm">Home</a></li> <li style="border-left:1px solid black"><a href="default.htm">About Us</a></li> <li style="border-left:1px solid black"><a href="default.htm" onClick="return clickreturnvalue()" onMouseover="dropdownmenu(this, event, menu1, '150px')" onMouseout="delayhidemenu()">Products</a></li> <li style="border-left:1px solid black"><a href="default.htm">Downloads</a></li> <li style="border-left:1px solid black"><a href="default.htm">Service</a></li> <li style="border-left:1px solid black"><a href="default.htm">Requests</a></li> <li style="border-left:1px solid black"><a href="default.htm">References</a></li> <li style="border-left:1px solid black"><a href="default.htm">What's New</a></li> <li style="border-left:1px solid black"><a href="default.htm">Contact Us</a></li> </ul> </div> </td> </tr> </table> Please visit my site where the menu is currently hosted. the url is http://asc2009.dreamhosters.com You will see my problem. You will notice when you hover your mouse over the last item in the menu, you will notice that the hover color does not go the whole way to the end of the td element. the list is flush to the left of the td element I need it to cover the whole width of the table. any help would be very much appreciated. Hi, I have hit the "wall" in my knowledge of CSS while trying to implement a "flex-width-equal-height-sidebar-layout" style of layout as a skin/theme for a message board system and need some help. My trouble occurs when a direct link to the post is used (instead of following the menu navigation system) where the top menu information/links area (the area between the banner and the post) is chopped off... The relevant portion of the CSS seems to be the .col_wrap {margin-top: 10px; border: 0; overflow: hidden; float: left; width: 100%; position: relative; z-index: 10; clear: both;} portion of my CSS because if I take out the overflow:hidden declaration then the menu portion of the skin/theme/layout shows correctly but the sidebar the shows the part which should be hidden at the bottom and the footer completely vanishes from view! My apologies but this is the best I can do without having the ability to post pics or urls which could better explain what is wrong and frankly speaking I don't know how anyone here can help given my inability to show the problem but hopefully someone knows or has run into this problem before or can offer some resources that may be of assistance.... i ve been playing with my page and been trying to modify the width of the page (divs) according to the browswer's width. The problem is i want the navigation menu on left to be fixed width (say 200px) and the center div and the right column to be variable width. Also, i want to set a minimum width , so that the floating divs dont roll below the navigation menu. here s the link to the page. try reducing ur browser windows size . the content div rolls down under theleft nav menu. http://ccc.1asphost.com/pacemakerpr...r/cicuitlab.htm Also , i get wierd result in netscape navigator. please help I have an absolutely positioned <div> containing a block of text. I have not specified a width for this <div>. This <div> is nested within another <div> for which I have specified a width of 200px. So something like: html4strict Code: Original - html4strict Code <div style="position: relative; width: 200px;"> <div style="position: absolute; top: 10px; left: 20px; z-index: 100;"> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur eu purus a tellus mollis consequat. Phasellus aliquam sapien quis mauris. </div> </div> <div style="position: relative; width: 200px;"> Since the absolutely positioned <div> is not part of the page's normal flow, I would expect that its width would expand according to its contents (and the browser window's boundries). Instead, in Firefox only, the width of the absolutely positioned <div> expands only to the width of its parent - in this case 200px. Am I doing something wrong? or is there a workaround for this? I have seen a design which I find pretty interesting where in the main site is aligned left and fixed width at say 700px wide. Yet the footer seems to span the entire screen. The header also seems to use the entire screen width but that is beign accomplished with the background image, but this footer goes all the way to end of the screen and naturally adjusts itself under all the content. Is there a way to get this effect? Hello, (please also see attached/uploaded style sheet) I'm puzzled why (in the following code) the TEST #2 table renders as required (i.e. 2 rows in 1 column, all with the same cell WIDTH) but the table in TEST #1 seems to render the table cells (i.e. 2 columns in 1 row) without a common cell WIDTH. How can I get all the cells (there are plenty more!) in table TEST #1 to all be exactly the same width (preferably 85px)? Code: <link rel="stylesheet" type="text/css" href="http://thinet/cgi-bin/thinetStyleSheet.css"> TEST #1 <table class="menu" border=1 CELLPADDING=2> <tr> <td class="pinkButtons"><a title="Treats menu" href='http://thinet/theread/forumdisplay.php?s=&forumid=82'>Treats</a></td> <td class="pinkButtons"><a title="New Starters, Leavers and Transfers" href='http://thinet/theread/forumdisplay.php?s=&forumid=41'>Joiners etc.</a></td> </tr> </table> <P> TEST #2 <table class="menu" border=1 CELLPADDING=2> <tr><td class="pinkButtons"><a title="Treats menu" href='http://thinet/theread/forumdisplay.php?s=&forumid=82'>Treats</a></td></tr> <tr><td class="pinkButtons"><a title="New Starters, Leavers and Transfers" href='http://thinet/theread/forumdisplay.php?s=&forumid=41'>Joiners etc.</a></td></tr> </table> I don't think I've quite grasped the idea of CSS yet?!?! Any help/pointers would be appreciated. Thanks, Andy Ok. Here's the problem: I have a asp.net 1.x datagrid inside a floated div and I want the datagrid to stretch the width of the div. This div is in the center of two other floated divs. Is there a way to make a table go 100% the width of its container div? Css code: Code: /* left bar: */ #navBar{ width: 185px; float: left; } /* right bar: */ #rightModulesContainer { width: 130px; margin: 0; padding: 0px 0px 0px 10px; float: right; } /* center content: */ #content{ padding: 0px 5px 0px 0px; margin-top:0; margin-bottom:0; margin-left:4px; margin-right:0px; float: left; text-align:left; /*display: inline;*/ } /* contained in #container: */ #dataGridContainer{ margin: 0; padding-bottom: 10px; min-width:360px; } .categoryGridStyle { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; font-style: normal; color: #000000; width:100%; } and here is the layout of the divs: Code: <div id="navBar">left navigation bar here (tree view)</div> <div id="rightModulesContainer">right side bar here</div> <div id="content"><div id="dataGridContainer">datagrid here</div></div> Thanks for your help in advance. I've been messing with this for a while - trying to get it to work cross browser is driving me nuts. I've tried placing the divs in containers and floating the containers, I've tried everything I can think of... I'm at the very very very begaining of a table-less design (my first, actually). The problem is, since I have decided to have a non-fixed width, when the browser is minimized, at a certain point the design breaks. See it here (please don't make fun! it's just the start): SiliconSatan.com/test.php I'd like to set a minimum width, probably on the container <div>, so at a certain point it sort of becomes like a fixed width? No smaller than a set width? [EDIT] Also, I have a question about background color mismatch, but it was not quite OT for the CSS forum: http://forums.devshed.com/web-desig...e7t-403266.html |