Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-06-2012, 02:41 PM   PM User | #1
lmorales
Regular Coder

 
Join Date: Mar 2011
Posts: 192
Thanks: 8
Thanked 1 Time in 1 Post
lmorales is an unknown quantity at this point
Different colored square bullet on every navigation item

My site is up at mmp.power1.com. I want to change the menu so that each menu item has a different colored square bullet on it. How do I accomplish that?
lmorales is offline   Reply With Quote
Old 08-06-2012, 03:00 PM   PM User | #2
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
Code:
.mainnav li {
	float: left;
	position: relative;
	z-index: 999;
	height: 20px;
	line-height: 20px;
	margin-right: 20px;
	list-style-image:url(images/square.png);
}

.mainnav li:nth-child(2) {
      list-style-image:url(images/square2.png);
}   /* etc..  OR */

.mainnav li:nth-child(2n+2) {
      list-style-image:url(images/square2.png);
}   /* Every second element etc.. */
This is CSS3 so is flakey (flawed?) in IE. Otherwise you could apply class names to the individual li elements and apply image-bullets to the classes.
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 08-06-2012, 04:51 PM   PM User | #3
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,587
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
No need for “flakey” CSS 3. And no need for background images. Here’s a better way, based on Andrew’s code (we’re disregarding IE 7 and below anyway):

Code:
.mainnav li {
  position: relative;
  padding-left: 15px;
}
.mainnav li:before {
  content: "";
  border: 5px solid;
  position: absolute;
  left: 0;
  top: 5px; /* change that to your desire */
}
.mainnav li:first-child:before {border-color: red;}
.mainnav li:first-child + li:before {border-color: green;}
.mainnav li:first-child + li + li:before {border-color: yellow;}
.mainnav li:first-child + li + li + li:before {border-color: blue;}
…
…
You can achieve the same effect with assigning a height and width and background color to the generated content rather than using borders.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Users who have thanked VIPStephan for this post:
AndrewGSW (08-06-2012)
Old 08-06-2012, 04:59 PM   PM User | #4
lmorales
Regular Coder

 
Join Date: Mar 2011
Posts: 192
Thanks: 8
Thanked 1 Time in 1 Post
lmorales is an unknown quantity at this point
Ok, would I have to call the classed within my ul nav? My biggest issue is this whole things in php and Im not sure where the heck the list is.
lmorales is offline   Reply With Quote
Old 08-06-2012, 05:02 PM   PM User | #5
AndrewGSW
Senior Coder

 
Join Date: Apr 2011
Location: London, England
Posts: 2,120
Thanks: 15
Thanked 354 Times in 353 Posts
AndrewGSW will become famous soon enough
That's sensible, seeing as we only want squares anyway

I suppose background-image can be used in place of border-color, if an image is required..
__________________
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
Validate your HTML and CSS
AndrewGSW is offline   Reply With Quote
Old 08-06-2012, 07:53 PM   PM User | #6
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,587
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Quote:
Originally Posted by lmorales View Post
Ok, would I have to call the classed within my ul nav? My biggest issue is this whole things in php and Im not sure where the heck the list is.
You can find your list easily by looking at the output source code (view source in browser or using a debugging tool that’s usually built into the browser already). And your menu code looks like this:
Code:
<ul id="menu-left" class="mainnav superfish">
<li id="menu-item-11" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-11"><a title="Mega My Pixel" href="index.php">HOME</a></li>
<li id="menu-item-12" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-12"><a title="behind the lens" href="http://mmp.power1.com/?page_id=7">BEHIND THE LENS</a></li>
<li id="menu-item-13" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-13"><a title="buzz" href="http://mmp.power1.com/?page_id=17">BUZZ</a></li>
<li id="menu-item-14" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-14"><a title="clientele" href="http://mmp.power1.com/?page_id=19">CLIENTELE</a></li>
<li id="menu-item-31" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-31"><a href="http://http://http://mmp.power1.com/?page_id=28">BUY MY ART</a></li>
<li id="menu-item-25" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-25"><a href="http://mmp.power1.com/?page_id=23">CONNECT</a></li>
<li id="menu-item-32" class="menu-item menu-item-type-custom menu-item-object-custom menu-item-32"><a href="http://mmp.power1.com/?page_id=21">LOGIN</a></li>
</ul>
And there we see that there are already IDs and classes so you don’t need all these sibling selectors I posted, you can address the elements directly via the IDs.
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 08-06-2012, 08:41 PM   PM User | #7
lmorales
Regular Coder

 
Join Date: Mar 2011
Posts: 192
Thanks: 8
Thanked 1 Time in 1 Post
lmorales is an unknown quantity at this point
Thanks!!
lmorales is offline   Reply With Quote
Old 08-07-2012, 04:21 PM   PM User | #8
lmorales
Regular Coder

 
Join Date: Mar 2011
Posts: 192
Thanks: 8
Thanked 1 Time in 1 Post
lmorales is an unknown quantity at this point
So that worked for the bullets... but they are all showing up as white?
lmorales is offline   Reply With Quote
Old 08-07-2012, 04:28 PM   PM User | #9
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,587
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Yeah, of course you need to assign a border color, otherwise it takes the default text color which is white in this case. If you need a different color for each list item use:
Code:
#menu-item-11:before {border-color: red;}
#menu-item-12:before {border-color: green;}
#menu-item-13:before {border-color: blue;}
Or use the method with the sibling selectors I demonstrated earlier if you can’t be sure that the IDs will always be like that (e. g. if you add/remove or change the order of pages).
__________________
Don’t click this link!
VIPStephan is offline   Reply With Quote
Old 08-07-2012, 05:26 PM   PM User | #10
lmorales
Regular Coder

 
Join Date: Mar 2011
Posts: 192
Thanks: 8
Thanked 1 Time in 1 Post
lmorales is an unknown quantity at this point
o.o i think i just broke my website... I checked to see if it was the footer doing it, its not, checked the main menu css which i dont think it is, Ive only been tinkering with the main menu css, style css and footer.php.... Im wondering how i broke it.
lmorales is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:39 PM.


Advertisement
Log in to turn off these ads.