Jump to content

Archived

This topic is now archived and is closed to further replies.

kit

changing the 2end level

Recommended Posts

I’m sorry if the is comes over a little confused, I am a total newbie!

At the moment I have a Navigation bar list put into boxes with css, and it works fine.

But what I want to do is make the second level, bulleted and not in boxes, so it is easier to see that they are sub levels.

Any help would be great. Sorry if I gave too much code, not sure what you needed too see.

Thanks!
[code]<?php
if (!defined('WEB_ROOT')) {
exit;
}

// get all categories
$categories = fetchCategories();

// format the categories for display
$categories = formatCategories($categories, $catId);
?>
<ul>
  <li><a href="<?php echo $_SERVER['PHP_SELF']; ?>">All
    Products </a></li>
<?php
foreach ($categories as $category) {
extract($category);
// now we have $cat_id, $cat_parent_id, $cat_name

$level = ($cat_parent_id == 0) ? 1 : 2;
    $url  = $_SERVER['PHP_SELF'] . "?c=$cat_id";

// for second level categories we print extra spaces to give
// indentation look
if ($level == 2) {
$cat_name = '&nbsp; &nbsp; &raquo;&nbsp;' . $cat_name;
}

// assign id="current" for the currently selected category
// this will highlight the category name
$listId = '';
if ($cat_id == $catId) {
$listId = ' id="current"';
}
?>
<li<?php echo $listId; ?>><a href="<?php echo $url; ?>"><?php echo $cat_name; ?></a></li>
<?php
}
?>
</ul>[/code]

css...

//#leftnav {
//width: 150px;
//font-size: 12px;
//vertical-align: top;
//font-size: 85%;
//font-family: Arial, Helvetica, sans-serif;
//color: #000000;
}

ul, ol {
font-family: Georgia, "Times New Roman", Times, serif;
}

#leftnav a {
padding: 3px;
display: block;
border: 1px solid #000099;
text-decoration: none;
line-height: 1em;
width: 150px;
background-color: #7AD8CE;
}

#leftnav a:link, #leftnav a:visited {
color: #003399;
}

#leftnav a:hover, #leftnav a:active {
color: #FFFFFF;
background-color: #6699CC;
border: 1px solid #000;
}

#leftnav ul {
/*/*/padding: 0em;
margin-left: 0em;
margin-right: 0em;
list-style-type: none; /* */
}

#leftnav li {
/*/*/margin: 0px 0px 6px 0px; /* */
}

#current a {
color: #FFFFFF !important;
/*/*/background-color: #99CCFF!important;
border: 2px solid #003399!important; /* */

Share this post


Link to post
Share on other sites
without reading all that you can use this

ul {
some decalrations that apply to top level
}

ul ul {
some declarations that apply to an unordered list inside an unordered list.
}

Share this post


Link to post
Share on other sites
ToonMariner, thanks for the help.

I'm sorry for being so stupid, but this is the first website i have ever made.

Where do I put them? *ducks all vertual slaps, rotten Tomatoes etc*

Share this post


Link to post
Share on other sites
Your html will look like something like this (not checked your code - if your code does not create this change it so it does - that is good practice for html)...
[code]
<ul>
<li>Item</li>
<li>Item</li>
<li>item
<ul>
  <li>Sub Item</li>
  <li>Sub Item</li>
</ul>
</li>
<li>Item</li>
</ul>
[/code]

and in your style sheet is the ul ul bit.

If this is a navigation type list then stick ALL the html for the unordered lists inside a div with id="nav"

then you can further refine you css to

#nav ul {
// attributes for top level list
}

#nav ul ul {
// attributes for sub lists
}
 

Share this post


Link to post
Share on other sites
Something like this should do it (I know it is ugly): [code]<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>Test</title>
<style type="text/css">
ul
{

background-color: blue;
}

ul ul
{
background-color: green;
}

ul ul ul
{
background-color: red;
}

ul ul ul ul
{
background-color: yellow;
}
</style>
</head>
<body>

<ul>
<li>
test
</li>
<li>
test
</li>
<li>
<ul>
<li>test</li>
<li>test</li>
<li>
<ul>
<li>test</li>
<li>test</li>
<li>
<ul>
<li>test</li>
<li>test</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>

</body>
</html>[/code]

You just need to style it better though.

Share this post


Link to post
Share on other sites
Ok, when I look at the source code on my website, it is laid out like the above.
But it is still not working.

Maybe I made a mistake and it is the php code?

Changes made


#leftnav ul ul {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
color: #000000;
list-style-position: outside;
list-style-type: disc;

[code]<ul>
<li<?php echo $listId; ?>><a href="<?php echo $url; ?>"><?php echo $cat_name; ?></a></li>
</ul>
[/code]

Thanks for your patience.

Share this post


Link to post
Share on other sites
You will need to set the margin of your sub list li elements! the top level has margin & paddin 0 this is inherited by child elements so make sure you give ul ul li{ margin: 0 0 0 5px;}

Share this post


Link to post
Share on other sites
Thank you
The sub level is still in a blue boxes (same as the top level).
It all works fine I would just like the sub levels to be different from the main levels, but nothing I have tried seems to work.???

Share this post


Link to post
Share on other sites
I suspect you are setting the background colour of the a tag still - which will override any li or ul background colors.

Share this post


Link to post
Share on other sites
[img]http://www.justcaroline.co.uk/images/navbar.gif[/img]

This is what it looks like.
yes I think the bg a tag is the problem, it is the colour that makes it look like its in a light blue box. I have tried, changing this but when I put the bg colur on the ul or ul ul it doesnt put each title in a seperate box just one big one.

Maybe I should just give up. Can anyone recommend a template or tutorial I can use for the same effect.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.