Solved

CSS question

Posted on 2012-03-16
8
191 Views
Last Modified: 2012-03-16
I am having some trouble styling a link. I need to create a "float:right" on the last-menu-item class

class="last-menu-item menu-item menu-item-type-taxonomy menu-item-object-category menu-item-33"

I cannot figure out where to insert this - all my efforts are failing. Any ideas?

<div class="menu-main-navigation">
    <ul id="menu-main-navigation" class="menu">
        <li id="menu-item-35" class="menu-item menu-item-type-post_type menu-item-object-page menu-item-35"><a href="#">About us</a><cite></cite></li>
        <li id="menu-item-29" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-29"><a href="#">Entertaining</a><cite></cite></li>
        <li id="menu-item-33" style="last-menu-item menu-item menu-item-type-taxonomy menu-item-object-category menu-item-33"> <a href="#">Last Link</a><cite></cite></li>
        </li>
    </ul>
</div>

Open in new window


Here is the CSS:

/*------------------------------------------------*/
/*---------------[MAIN NAVIGATION]------------*/
/*------------------------------------------------*/
	ul#menu-main-navigation { border-bottom:1px solid #d1d1bd; border-top:1px solid #d1d1bd;height:27px; margin: 0 auto; padding-top:3px; position: relative; width:945px; }
		ul#menu-main-navigation li { float:left; margin-right:5px; padding:2px 0 0 0; height:26px; width:auto; }
			ul#menu-main-navigation li a { font-family:Museo500, "Helvetica Neue", Helvetica, Arial, sans-serif; padding:8px 12px 7px; font-size: 13px; color: #49413c;}
			ul#menu-main-navigation li a:hover { color: #49413c !important; text-decoration:underline !important; }
			ul#menu-main-navigation li a:active { color:#d9461e !important;text-decoration:underline; }
				ul#menu-main-navigation li#menu-item-35 { padding-left:2 !important; }
				ul#menu-main-navigation li.current-menu-item a, ul#menu-main-navigation li.current-menu-item a:hover { background:url(images/nav-start.png) no-repeat 0 3px transparent; color:#ffffff !important; padding:5px 0 6px 12px; }
				ul#menu-main-navigation li.current-menu-item cite { background:url(images/nav-end.png) no-repeat right 0 transparent; display:block; float:right; height:21px; left:-1px; position:relative; width:12px; }
				ul#menu-main-navigation li.current-menu-item cite { top: 1px\9; }  /* IE8 */
				ul#menu-main-navigation li.current-menu-item cite { position:relative\9; }  /* IE8 */
				:root ul#menu-main-navigation li.current-menu-item cite { top: 1px \0/IE9; }  /* IE9 */
				:root ul#menu-main-navigation li.current-menu-item cite { position:relative; \0/IE9; }  /* IE9 */
				ul#menu-main-navigation li.current-menu-item a:hover { cursor:default; text-decoration:none !important; }
/*------------------------------------------------*/
/*---------------[CATEGORIES DROPDOWN]------------*/
/*------------------------------------------------*/
	ul#cats-menu, #menu-main-navigation { border-bottom:1px solid #d1d1bd; border-top:1px solid #d1d1bd;height:30px; margin: 0 auto; position: relative; width:940px; }
		ul#cats-menu li, #menu-main-navigation li { margin-right: 5px; padding-left: 12px; height: 37px;}
			ul#cats-menu li a, #menu-main-navigation li a { font-family:Museo500, "Helvetica Neue", Helvetica, Arial, sans-serif; padding:4px 8px 7px 0; font-size: 13px; color: #49413c;}
				ul#cats-menu li a:hover, #menu-main-navigation li a:hover { color: #22b7c9; text-decoration: none; }
	ul#cats-menu li li { background:#313131; background-image:none; margin:0; padding: 0px; width: 240px; }
		ul#cats-menu li li a { background: none; text-align: left; height:auto; padding:10px 12px; display: block; width: 216px;}
	#cats-menu ul { background-image: url(images/categories-bottom.png); padding-bottom: 18px; }
	#cats-menu li:hover ul, ul#cats-menu li.sfHover ul { top:37px; }
		#cats-menu li li { background-image: none; margin: 0px; }
	ul#cats-menu > li:hover { color:#22b7c9; padding-left: 12px; }
		ul#cats-menu > li:hover > a {  }
			#cats-menu li li a:hover { background-color: #242424; border: none; }
			#cats-menu li li:hover ul, ul#cats-menu li li.sfHover ul { top:0px; }


  

Open in new window

0
Comment
Question by:lvollmer
  • 3
  • 3
  • 2
8 Comments
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 37730746
I'm not surprised you can't find the right spot.  Did you ever hear the expression "keep it simple"?

The CSS is terrible.

You saved a little typing by not applying ids to elements, and then doing a bunch of nesting.  That litle bit you saved is now costing you big time in maintenance.

You you want to target an element, then give it an id and do it directly.

Then go back to your CSS and re-think the mis-guided notion that you save something by creating a rat's nest in the CSS.


Cd&
0
 

Author Comment

by:lvollmer
ID: 37730754
Yeah, no kidding - The code is generated by a CMS, I cannot alter the HTML that is output, I can only alter the CSS.
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 37730770
Then your best hope is to use firefox.  Right click on the element and inspect it. You will be able to get the style, and you may be able to determine where it is ultimately inheriting from.

Cd&
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 37730787
BTW any CMS that generates code like that is crap.  Four classes assigned to an element... WOW!


Cd&
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 30

Expert Comment

by:LZ1
ID: 37730849
Is this WordPress?  Do you have a live link you can share?

The CSS is definitely over-bloated.  I never let anyone or anything write my code for me and CMS's are no exception.
0
 

Author Comment

by:lvollmer
ID: 37730879
Yes it is Wordpress - here is the link > http://tinyurl.com/757mp88

I am stuck using this theme some company built, rebuilding is not an option at the moment although I have recommended it many times.
0
 
LVL 30

Accepted Solution

by:
LZ1 earned 500 total points
ID: 37730887
Do something like this:
 
ul#menu-main-navigation li.last-menu-item{float:right;}

Open in new window

0
 

Author Closing Comment

by:lvollmer
ID: 37730902
Jackpot! thanks. saved me a bunch more time.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
html input clean up 3 32
targeting between desktop and responsive menu 3 18
CSS grid style change 2 14
CSS measurement 10 14
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now