What is the method for changing the color of a specific section of a header?

My header design consists of two lists of buttons, one on the left and one on the right. I am looking to customize the background color of the "Sign Up" button to make it stand out. Below is an example of what I want and the current design of my header along with the code:

Desired Design: https://i.sstatic.net/g2zLV.png

Current Design: https://i.sstatic.net/SXIuj.png

    <!-- html: -->

header {
  min-height: 20px;
}

header a {
  color: #3b4b5d;
  text-decoration: none;
}

section h1 {
  margin: 0;
}


/* TOP NAV CSS */

.top-nav {
  width: 100%;
  margin: auto;
  overflow: hidden;
}

.nav-logo img {
  float: left;
  width: 120px;
  padding: 20px 12px 20px 20px;
}

.left-nav ul li {
  margin: 10px 16px 0px 16px;
  padding: 0px 0px 0px 24px;
  font-size: 16px;
  text-decoration: none;
  display: inline-block;
  float: left;
  text-align: center;
}

header a:hover {
  color: #50E3C2;
}

.right-nav ul li {
  margin: 10px 16px 0px 16px;
  padding: 0px 24px 0px 0px;
  font-size: 16px;
  text-decoration: none;
  display: inline-block;
  float: right;
  text-align: center;
}
<header>
  <div class="top-nav">
    <div id="branding">
      <a href="index.html" class="nav-logo"><img src="assets/nav-bar-logo.png" alt="trooops-logo"></a>
    </div>

    <nav class="left-nav">
      <ul>
        <li><a href="discover.html">Discover</a></li>
        <li><a href="blog.html">Blog</a></li>
      </ul>
    </nav>

    <div class="right-nav">
      <ul>
        <li><a href="signup.html" style="background-color: #FF5733;">Sign Up</a></li>
        <li><a href="login.html">Log In</a></li>
      </ul>
    </div>
  </div>
</header>

Answer №1

It could look something like this:

.right-nav>ul>li:first-child{
    background-color: #whatever-color
}

Check out this fiddle for a demo

Edit: I have made some changes to the fiddle and added some example rules. It seems that there may be some adjustments needed with padding and margins. I also re-applied some rules to the anchors, as recommended by @Robert. The fiddle is just a suggestion, feel free to customize it further to suit your needs ;)

Updated fiddle: newFiddle

Answer №2

Building upon the information shared by @sissy, it is important to note that since your anchor (tag) serves as the clickable element and is styled like a button, it is ideal to apply your color scheme directly to that element. Additionally, utilizing padding can help create some spacing around the text for better visual appeal.

header {
  min-height: 20px;
}

header a {
  color: #3b4b5d;
  text-decoration: none;
}

section h1 {
  margin: 0;
}


/* CUSTOM NAVIGATION MENU STYLING */

.top-nav {
  width: 100%;
  margin: auto;
  overflow: hidden;
}

.nav-logo img {
  float: left;
  width: 120px;
  padding: 20px 12px 20px 20px;
}

.left-nav ul li {
  margin: 10px 16px 0px 16px;
  padding: 0px 0px 0px 24px;
  font-size: 16px;
  text-decoration: none;
  display: inline-block;
  float: left;
  text-align: center;
}

header a:hover {
  color: #50E3C2;
}

.right-nav ul li {
  margin: 10px 16px 0px 16px;
  padding: 0px 24px 0px 0px;
  font-size: 16px;
  text-decoration: none;
  display: inline-block;
  float: right;
  text-align: center;
}

.right-nav>ul>li:first-child a {
  background-color: purple;
  color: white;
  padding: 10px 12px;
}
<header>
  <div class="top-nav">
    <div id="branding">
      <a href="index.html" class="nav-logo"><img src="assets/nav-bar-logo.png" alt="trooops-logo"></a>
    </div>

    <nav class="left-nav">
      <ul>
        <li><a href="discover.html">Discover</a></li>
        <li><a href="blog.html">Blog</a></li>
      </ul>
    </nav>

    <div class="right-nav">
      <ul>
        <li><a href="signup.html">Sign Up</a></li>
        <li><a href="login.html">Log In</a></li>
      </ul>
    </div>
  </div>
</header>

Answer №3

Sample CSS styling for a button:

.custom-button {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 15px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    cursor: pointer;
}

HTML code to create the button:

<a href="#" class="custom-button">Click Here</a>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to create a fixed positioning for a div within a Material-UI table container?

When using the Material UI Table, I encountered an issue with applying the sticky property. The table itself works fine, but I also have a button inside the TableContainer that should be sticky alongside the table head. I attempted to achieve this by using ...

The Google calendar integration is working, but the appearance leaves much to

I embedded a Google calendar, but I'm having trouble centering it on the page without it overflowing onto the top menu. Can you help me fix this issue? If you'd like to see what I'm referring to, you can visit this link: ...

Avoiding additional empty lines between selectors when setting up Stylelint

Can anyone help me with configuring Stylelint options? Specifically, I want to enforce a rule that no empty lines are allowed between selectors in a list of selectors: &:focus, &:hover, &.active { color: #fb3a5e; text-align: left; text-de ...

Altering the Size of Text in HTML

Currently I am working on my website and the title appears as follows <h1><font face="tempus sans itc" color="White"><div style="text-align:center">Welcome To My Website. View My Projects Here</h1></div> Is there a way to in ...

Tips on including starting information into an angularjs application from the displayed HTML

I'm currently working on a complex AngularJs application that requires User Login. Once the user is authenticated, a page will be displayed to them and additional data will be loaded later. There are two methods for achieving this: XHR Fetch af ...

Using the symbols '&', '>', and '*' in the styling of React components

Below is the code snippet in question: const useStyles = makeStyles(theme => ({ row: { '& > *': { fontSize: 12, fontWeight: 'bold', color: 'rgba(33,34,34,0.5)', letterSpacing: 0.5, ...

Challenges with KendoUI integration

In one of my web pages, I have a combination box and a checkbox. To enhance the functionality, I decided to utilize the KendoUI library. The combo box allows users to choose between two options - 0% and 100%. If the checkbox is selected, the combo box shou ...

Adjust the padding when hovering using CSS

Hey everyone, newbie here taking a crack at my first Joomla module! I've made some progress but hit a snag with my CSS styling - I think it's an issue with my selectors and my limited understanding of what's going on. Basically, I'm at ...

Keeping datetimepicker current when a date is chosen - a guide

I am currently utilizing the datetimepicker plugin from xdsoft to enable users to select a booking date and time. Check out the documentation for more details. To manage bookings, I have set up a 'fechas' table in my database which stores inform ...

Changing the Color of Hamburger Menu Lines in Bootstrap

How can I change the color of the hamburger menu icon's lines for medium and smaller screen sizes? I have attempted changing it through style attributes and using !important in my CSS file, but so far nothing has been successful. ...

Dynamic item addition feature activated by button on contact form

I am looking to create a form that includes the standard name, phone, email fields as well as a dropdown for selecting products and a text box for inputting quantity. The unique aspect is allowing users to add multiple products (dropdown and quantity textb ...

Unusual display of feedback text in Bootstrap 4

When I directly copied this code snippet from Bootstrap 4: <div class="form-group has-danger"> <label class="form-control-label" for="inputDanger1">Input with danger</label> <input type="text" class="form-control form-contro ...

Issue with color display inconsistency in webgrid across various segments

https://i.sstatic.net/UW17M.png My goal is to display section status colors in a webgrid and divide them percentage-wise, but I am facing issues with some of the rows. Here is the cshtml script for the webgrid section status: webGrid.Column(header: "Sec ...

What is the best method for transforming an HTML file into an ICS (iCal) file?

Hello there! I am interested in converting an HTML file (website) to an iCalendar file (iCal). Is this even possible? If so, how can it be achieved? Does anyone have any ideas or recommendations on how to proceed? Thank you in advance! ...

Conceal elements of a rectangular shape using CSS

https://i.stack.imgur.com/ebaeI.jpg I need help hiding the second rectangular shape on my website. I want the width to be 100% and responsive, but whenever I use position: absolute; with right:-10%, it's not working as expected. Even trying body { ma ...

What is the best way to horizontally align and center the navigation menu?

I've been struggling to center and align the navigation links inside this div horizontally. I attempted a few methods, but none seem to work. I managed to fix the previous issue with #centermenu, but unfortunately it still isn't functioning as e ...

Having trouble applying CSS to SVG icons from defs file in Webkit Browser

I've been tinkering with a project that incorporates SVG icons, hoping to style them using CSS for various scenarios and hover effects. However, my attempts are falling short in Webkit, while Firefox is displaying the icons as intended: http://codepe ...

Filling a select element in an HTML file using AJAX

I've hit a roadblock, trying to display this PHP list. <?php include 'connection.php'; $query = mysqli_query($conn, "SELECT * FROM expense_object ORDER BY code" ); ?> <!DOCTYPE html> <html lang=" ...

Ways to dynamically incorporate media queries into an HTML element

Looking to make some elements on a website more flexible with media rules. I want a toolbar to open when clicking an element, allowing me to change CSS styles for specific media rules. Initially thought about using inline style, but it turns out media rul ...

Using the radius to determine the center point of the circle

<span class="qs">Q{{i + 1}} <a href="#question-view"></a></span> <div class="tooltipp text-center bubble[ngStyle]="bubbleStyle(prof?.proficiencyBrightness, prof?.proficiencyRadius)"> </div> In the illustration below, ...