CSS - Css Nested Lists: How Do I Do This...
Similar TutorialsOK i have a nested list: PHP Code: <div id="sideMenu"> <ul> <li><a href="">Menswear</a> <ul> <li><a href="">Shalwar</a></li> <li><a href="">Shalwar2</a></li> </ul> </li> <li><a href="">Womenswear</a></li> <li><a href="">Jewelry</a></li> </ul> </div> i am applying css to it! i want to set the background of the LI to be one colour but i want the background of the nested lists to be another. but what is happening (and its not really a bug) is that whne i apply the background colour to LI this colour also goes behind the nested lis? http://www.zahra-zahra.com/fullpage.html i am talking about the side menu (purple and light purple) is there a "fix"? I'm looking to use lists to create 2 columns of info: Info 1 Info A Info 2 Info B Presumably I would do this like (excuse the inline style): Code: <ul style="display:inline"> <li style="display:inline"> <ul style="display:inline"> <li>Info 1</li> <li>Info 2</li> </ul> </li> <li style="display:inline"> <ul style="display:inline"> <li>Info A</li> <li>Info B</li> </ul> </li> </ul> This outputs: Info 1 Info 2 Info A Info B I'm also looking to do a mix of images and text in a list, but have alignment issues. Code: <ul style="display:inline;list-style:none"> <li style="display:inline">Some</li> <li style="display:inline">random</li> <li style="display:inline">words</li> <li style="display:inline">with</li> <li style="display:inline">an</li> <li style="display:inline"><img src="mypic.jpg"></li> <li style="display:inline">mixed</li> <li style="display:inline">in</li> </ul> Is this bad practice? Should I just make a table, or a seperate div to contain the images and text apart from each other? Tia! PS. Hi Kravvitz :P ok i would like to have on my nested list 1.1 and 1.2 instead of 1? ie Code: 1. hhh 1.1 jjj 1.2 kkk 2. kkk 2.1 kkkk etc but currently if i have the list-style-type as decimal the inner list comes out as just 1,2,3 etc... is it even possible to do this? hello, this will perhaps sound like a crazy thing to do, but i am trying to style my nested list(s) in order for the 'category' to appear below its children. so rather than having, for example sport football cricket formula one i have football cricket formula one sport the reason for trying this is that i am hoping to display my lists at various positions along a base line (over a bg image) and certain positions within the image require the category name to be under the 'children'. is it possible though? i tried making the inner list's position to be relative and adjusting the top position to -20 etc but of course this brings the children up rather than push the category down. here is an example of my nested list Code: <ul> <li>sport <ul class="up"> <li>football</li> <li>f1</li> </ul> </li> <li>music <ul class="up"> <li>stuff</li> <li>stuff2</li> </ul> </li> </ul> it probably isn't possible but i thought i would ask before giving up on the idea completely. thank you for your time Hi I found it: ********************** Code: #tableLeftCol ul.menu li#current a { background-image: url('../images/menu-active-rect.gif'); background-position: right top; background-repeat: repeat-y; } #tableLeftCol ul.menu li#current ul li a { background-image: none; } *************************** I have a nested list representing a menu. I want the active menuitems (listitem) link to have a background image. When active menuitem is a parent then all the childs also get the background image...... How to I change the CSS so only active menuitems link get the background image set, and not the child links of the parent? If possible, I want to make it work without changing any in the HTML! Here is current CSS and list structu Code: #tableLeftCol ul.menu li#current a { background-image: url('../images/menu-active-rect.gif'); background-position: right top; background-repeat: repeat-y; } #tableLeftCol ul.menu li ul li#current a { background-image: url('../images/menu-active-rect.gif'); background-position: right top; background-repeat: repeat-y; } Code: <div id="tableLeftColPadding"> <ul class="menu"> <li id="current" class="parent active item54"> <a href="/index.php?option=com_content&view=article&id=48&Itemid=54"> <span>Parent</span> </a> <ul> <li class="item57"> <a href="/index.php?option=com_content&view=article&id=50&Itemid=57"> <span>Child-A</span> </a> </li> <li class="item81"> <a href="/index.php?option=com_content&view=article&id=71&Itemid=81"> <span>Child-B</span> </a> </li> <li class="item59"> <a href="/index.php?option=com_content&view=article&id=52&Itemid=59"> <span>Child-C</span> </a> </li> </ul> </li> </ul> </div> http://jordanmeeter.com/?page=resources Okay... WTF is that about? I added another article to the "Articles" list... And it moved the section below it down. My CSS for #noindent : Code: .noindent { float: left; width: 200px; margin-left: 0px; margin-top: 5px; padding-left: 0px; list-style-type: none; } Does anyone know how I can fix the gaps on this block level lists? It looks fine on firefox and other browsers but ie6 and ie7 add gaps in between the lists. http://section31.us/study/html/temp...lists_on_ie.php Hi... How do I break a single list into multiple columns? The page I'm talking about is http://jordanmeeter.com/?page=links. I'd like to bring the "Other" category up over to the right, next to the rest of the categories. I tried Code: float: left; width: 200px; And that kind of did what I want... Not really, though. I want to have a list that each listed item has a different image, how can i do this. Thanks Hi, I'm trying to build a simple menu for a layout in XHTML/CSS. I was thinking about having a list and then giving it a style, such as: Code: <ul class="menu"> <li id="menu_home">Home</li> <li id="menu_about">About Us</li> <li id="menu_contact">Contact Us</li> </ul> But then I would like the CSS to display the "li" items horizontally rather than vertically, and without bullets. Also, having the "Home", "About Us", etc, text replaced with images (CSS). Can this be done? I would really appreciate any guidance with this or any other ideas. Thanks, Ralph On my website, the left nav. bar is made using a list. The list has a border round top, bottom, right & left, and has a blue hover colour. The list however, does not display tight up against each other, and takes a line between each list item. I'd like it to be right above and below one another rather than a gap in between. You can view the list on the site, HERE. The CSS for the nav. bar is: Code: /*-----LEFT MENU-----*/ #leftcontent { width: 120px; } #leftcontent ul { margin-left: 8px; padding-left: 0; list-style-type: none; font-family: Arial, Helvetica, sans-serif; } #leftcontent a { padding: 0px; padding-left: 2px; padding-top: 1px; padding-bottom: 1px; background-color: #fff; border: 1px solid #ccc; text-decoration: none; display:block; } #leftcontent img { display:inline; padding:0; border:0; margin:0; } #leftcontent a:link, #navlist { color: #000; text-decoration: none; } #leftcontent a:visited { color: #000; } #leftcontent a { color: #000000; } #leftcontent a:hover { background-color: #369; display:block; color: #fff; } #leftcontent img a:hover{ display:inline; padding:0; border:0; margin:0; } /*----END LEFT MENU----*/ Note: The img hover, bg colour etc. is so it does not use the same properties as when I open the page up in my content management system it uses small icons, which would use the list properties if I did not define it as an image. Please just ignore it. Cheers. Hi, I have a list item that extends onto a second line. How do I keep the second line the indented more than the first line? thanks -S Hi, can anyone give me a hand with customizing my lists? I am trying to do something like here, http://www.microsoft.com/, but with a semi-transparent background in the nav bar. It works if I have borders around the links, which is fine if I had a solid bg as I can hide them, but being semi-transparent I have a problem, and when I remove them it causes a shift when moving over a link. Any ideas?? Hi: The return key works fine in HTML lists (for example those in Outlook editor). However, in normal HTML, the return key double spaces inappropriately outside of lists (and between lists, too). Outside of lists, Outlook replaces <p> with <br> to get wordprocessor-like action from the return key, but this doesn't isolate the "new" line/paragragh from the preceeding text, like <p> does. So, attempts to format the "new" paragraph affects the "previous" paragraph. Is there any way to have <p> behave differently inside and outside of lists (maybe making the double-spaced lines half the usual height, or some other approach? Thanks, Terry Hey i am trying to create a navigation bar that uses hover lists so that there are a number of links and when these are hovered over, the provide links which are under this section. I have sourced code and used this and it all works apart from that the hovered options are about 0.8cm apart and the first is over the top of the original list, which still needs to be seen. The code for the CSS is below; #navmenu{ width: 100%; float: left; background: #900; height: 100%; } #navmenu ul{ list-style: none; margin: 0; padding: 0; width: 120px; float: left; } #navmenu li{ margin: 3px 0px 3px 0px; padding: 3px 0px 3px 0px; display: inline } #navmenu a{ font: bold 15px Calibri; display: block; border-width:1px; border-style:solid; border-color:#F90; margin: 0; padding: 2px 3px; color: #FC0; background: #900; text-decoration:none; } #navmenu a:hover{ color:#FFF; background:#C30; } #navmenu li { position:relative; } #navmenu ul ul { position:absolute; top: 0; left: 100%; } div#navmenu ul ul{ display: none; } div#navmenu ul li:hover ul {display: block;} div#menu ul ul, div#menu ul li:hover ul ul, div#menu ul ul li:hover ul ul {display: none;} div#menu ul li:hover ul, div#menu ul ul li:hover ul, div#menu ul ul ul li:hover ul {display: block;} body { behavior: url(csshover.htc); } [if IE]> <style type="text/css" media="screen"> body { behavior: url(csshover.htc); font-size: 100%; } #menu ul li {float: left; width: 100%;} #menu ul li a {height: 1%;} #menu a { font: bold 0.7em/1.4em arial, helvetica, sans-serif; } </style> <![endif] and the code for the section of the webpage (btw it is linked in the header) <div id="navmenu"> <ul> <li><a href="index.html" title="Home">Home</a></li> </ul> <ul> <li><a href="products.html" title="Products">Products</a> <ul> <li><a href="rubber.html" title="Rubber">Rubber</a></li> <li><a href="struts.html" title="Struts">Struts</a></li> <li><a href="hardware.html" title="Hardware">Hardware</a></li> </ul> </li> </ul> </div> Thanks help would be appreciated. Okay, my problem deals with FireFox and Internet Explorer. If you view my links page (http://jordanmeeter.com/?page=links) in Internet Explorer, everything displays correctly. However, if you look at it in FireFox, none of the CSS works. In my CSS, I put: Code: .noindent { margin-left: 0px; list-style-type: none; } Why doesn't that work in FireFox? Thanks in advance. =) Question? Okay I know IE for some reason defaults with a left-padding or something for an unordered list. so when I set padding:0 for my unordered list everything is great in firefox. But when I look at it in IE the list-style elements are pulled off of the list object. How can I place no padding on the list and still use the list-symbols in IE? The thought of placing my own list object in the background, but it would be silly if I could just use the disc built into windows ie. thanks! Hey guys I just coded this list which has sub entries in it as well. It looks fine and works great in FireFox. However, when viewed in IE7 something is different. I am not sure if it isn't the normality, I just know it isn't what I want. I've attached and image of what the problem is, left side is IE and right side is FF. The code I'm using is simply Code: <ul> <li>Main</li> <ul> <li>Sub</li> </ul> </ul> Thanks Hi everyone. I'm looking for some help rendering a list using css. Basically I have a list in this format: Code: <ul> <li>shirts</li> <li>jackets <ul> <li>casual jackets</li> <li>formal jackets</li> </ul> </li> <li>suits</li> </ul> And I would like to render it something like: Code: shirts jackets > casual jackets formal jackets suits All the text needs to be floated left so it will wrap to the next line. I'm able to float the top level list items correctly i.e. "shirts jackets suits" using: Code: <ul id="menu"> <li>shirts</li> <li>jackets</li> <li>suits</li> </ul> #menu, #menu ul { list-style:none; } #menu li { float: left; width:5em; } the problem I have is getting the nested lists to appear alongside the parent items instead of below. When I add the nested lists I see something like: Code: shirts jackets suits casual jackets formal jackets Maybe this just isn't possible but if anyone could help me I'd sure appreciate it! Thanks! Toby i am trying to get the list to show over two lines like so (using _ as multiple spaces get turned on to one) how do i get both centered. _____item1____item2____item3 item4____item5____item6____item7 Code: <div class="homebodytext"> <ul> <li class="homebodylifloat">item1</li> <li class="homebodylifloat">item2</li> <li class="homebodylifloat">item3</li><br style="clear: both;"><br> <li class="homebodylifloat">item4</li> <li class="homebodylifloat">item5</li> <li class="homebodylifloat">item6</li> <li class="homebodylifloat">item7</li><br style="clear: both;"> </ul> </div> Code: .homebodytext { border: 0px solid #0000; text-align: center; width: 900px; padding-left: 20px; font-weight:bold; } .homebodylifloat { float: left; width: 220px; } |