Solved

CSS - specify different colour for first list menu?

Posted on 2013-06-03
7
226 Views
Last Modified: 2013-06-03
Hi,
Is there a way I can have the first link "CONTACT US" display in in red?

Thanks,

Andrew


<html>
<head>
<title>Untitled Document</title>

<style type="text/css">


#navbar_bottom {
   margin: 0;
   padding: 0;
   height: 30px; 
}
#navbar_bottom li{
   list-style: none;
   float: right; 
   text-align: center;
   font-size: 12px;
   
}
/* main top menu */
#navbar_bottom li a{
	display: block;
	padding-left: 20px;
	padding-right: 20px;
    color: #ccc;
	height:30px;
	line-height:30px;
	text-decoration: none;
}
/* main top menu hover*/
#navbar_bottom li a:hover {
   color: #000;
}

</style>
</head>

<body>


<div id="menu_bottom"><ul id="navbar_bottom">

<li><a class='main_menu_bot' href=''>CONTACT US</a></li>
<li><a class='main_menu_bot' href=''>JOBS + TRAINING</a></li>
<li><a class='main_menu_bot' href=''>RETAIL</a></li>

 
</ul></div>

</body>
</html>

Open in new window

0
Comment
Question by:sabecs
  • 4
  • 2
7 Comments
 
LVL 9

Expert Comment

by:dustock
ID: 39217403
li:first-child {
color:red;
}

Open in new window

0
 
LVL 14

Expert Comment

by:Juan Ocasio
ID: 39217420
<html>
<head>
<title>Untitled Document</title>

<style type="text/css">


#navbar_bottom {
   margin: 0;
   padding: 0;
   height: 30px;
}
#navbar_bottom li{
   list-style: none;
   float: right;
   text-align: center;
   font-size: 12px;
   
}
/* main top menu */
#navbar_bottom li a{
      display: block;
      padding-left: 20px;
      padding-right: 20px;
    color: #ccc;
      height:30px;
      line-height:30px;
      text-decoration: none;
}
/* main top menu hover*/
#navbar_bottom li a:hover {
   color: #000;
}

</style>
</head>

<body>


<div id="menu_bottom"><ul id="navbar_bottom">

<li><a class='main_menu_bot' href=''>CONTACT US</a></li>
<li><a class='main_menu_bot' href=''>JOBS + TRAINING</a></li>
<li><a class='main_menu_bot' href=''>RETAIL</a></li>

 
</ul></div>

</body>
</html>
0
 
LVL 14

Expert Comment

by:Juan Ocasio
ID: 39217440
Or you can use color:red in another class:

<html>
<head>
<title>Untitled Document</title>

<style type="text/css">


#navbar_bottom {
   margin: 0;
   padding: 0;
   height: 30px;
}
#navbar_bottom li{
   list-style: none;
   float: right;
   text-align: center;
   font-size: 12px;
   
}
/* main top menu */
#navbar_bottom li a{
      display: block;
      padding-left: 20px;
      padding-right: 20px;
    color: #ccc;
      height:30px;
      line-height:30px;
      text-decoration: none;
}
/* main top menu hover*/
#navbar_bottom li a:hover {
   color: #000;
}
 .red{
Color:red;}
</style>
</head>

<body>


<div id="menu_bottom"><ul id="navbar_bottom">

<li><a class='main_menu_bot red' href=''>CONTACT US</a></li>
<li><a class='main_menu_bot' href=''>JOBS + TRAINING</a></li>
<li><a class='main_menu_bot' href=''>RETAIL</a></li>

 
</ul></div>

</body>
</html>
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:sabecs
ID: 39217506
Thanks for your feedback, I tried all suggestions above but none of them worked when testing in IE & Firefox?
0
 
LVL 14

Expert Comment

by:Juan Ocasio
ID: 39217571
Where is the main_menu_bot class defined?
0
 
LVL 14

Accepted Solution

by:
Juan Ocasio earned 500 total points
ID: 39217604
Try this:

<html>
   <head>
      <title>Untitled Document</title>

   <style type="text/css">
      #navbar_bottom {
         margin: 0;
         padding: 0;
         height: 30px;
      }

      #navbar_bottom li{
         list-style: none;
         float: right;
         text-align: center;
         font-size: 12px;
      }
      /* main top menu */
      #navbar_bottom li a{
            display: block;
            padding-left: 20px;
            padding-right: 20px;
          color: #ccc;
            height:30px;
            line-height:30px;
            text-decoration: none;
      }

      /* main top menu hover*/
      #navbar_bottom li a:hover {
         color: #000;
      }

      #navbar_bottom li a.red {
         color: #f00;}
      #navbar_bottom li a.red:hover {
         color: #000;}
   </style>

   </head>

<body>


<div id="menu_bottom">
   <ul id="navbar_bottom">
      <li><a class='main_menu_bot red' href=''>CONTACT US</a></li>
      <li><a class='main_menu_bot' href=''>JOBS + TRAINING</a></li>
      <li><a class='main_menu_bot' href=''>RETAIL</a></li>
   </ul>
</div>

</body>
</html>

Open in new window

0
 

Author Closing Comment

by:sabecs
ID: 39217682
Thanks jocasio123, that's perfect...
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…

770 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