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:

Current Design:

    <!-- 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

generate a different identifier for ajax requests avoiding the use of JSON

The AJAX request functions in the following way: success: function(data) { $('#totalvotes1').text(data); } However, I need it to work with unique IDs as follows: success: function(data) { $('#total_' + $(this).attr("id")). t ...

Expanding the height of Bootstrap 4 cards

I'm having an issue with Bootstrap 4's card columns where the height of the shorter card ends up stretching to match the one beside it. This only occurs when I add the 'row' class to the parent div. If I remove the 'row' class ...

What are the steps for implementing responsive design animation in my particular scenario?

Can someone please help me with a strange bug in Chrome? I am trying to create a responsive design for my app. The width of the 'item' element should change based on the browser's width. It works fine when the page first loads in Chrome, b ...

Bring in a video file in order to watch it on your web page (HTML)

Is there a way to upload and play a video file using the video element? I am looking to add a video file to my webpage that can be played using a video element. <input type="file"> <h3>Video to be imported:</h3> <video width="320" ...

Using jQuery Mobile to Recycle a Header and Navigation

I'm a beginner when it comes to jQuery Mobile and I'm struggling to grasp the concept of reusing headers and general navigation. Currently, I have a header with a menu button on the right. When the menu button is clicked, a popup shows up with l ...

What is the best way to retrieve the object of the selected option from a single select input in Angular

I'm currently working with an array of objects that looks like this: let myArray = [{'id':1,'Name':"ABC"},{'id':2,'Name':"XYZ"}] I'm trying to retrieve object values based on a dropdown selection, but so ...

Ensuring consistent column height in HTML Tables

Hey there, I'm just starting out with CSS and I have a question about table design. I have three separate tables below and I want to ensure that all the columns in each table are of equal height. Is there an easy way to achieve this? Any suggestions o ...

Try implementing a body template when using the mailto function

Is there a way to customize an HTML template for the mailto() function body? For example, suppose I have the following link: echo "<a href="mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97f2faf6fefbd7f0faf6fefbb ...

Text transitions in a gentle fade effect, appearing and disappearing with each change

I want to create a smooth fade in and out effect for the text within a div when it changes or hides. After researching on Google and Stack Overflow, I found that most solutions involve adding a 'hide' CSS class and toggling it with a custom func ...

Compiling SCSS to CSS in Vue.js is a breeze

I am working on a vue js project that includes scss files. My goal is to compile these scss files into css and store them in the public folder. How can I achieve this? Should I make changes to the vue.config.js file? const path = require('path'); ...

Is there a way to compel @keyframes to continue playing until it reaches its conclusion even after a mouseout event

Whenever I hover over an element, a keyframe animation starts playing. However, when I move the cursor away, the animation stops abruptly. Is there a way to ensure that it plays until the end? I've tried using the animationend event, but it doesn&apos ...

Tips for concealing password input in an HTML form

Is it possible to echo the password variable into an input field in a form without displaying any password characters in the HTML source code? The purpose is for the form to be able to post the password without revealing it. Any ideas on how to accomplis ...

Ways to subtly adjust the edges of text in a design

https://i.stack.imgur.com/sr4PF.pngIs there a way to adjust the border of text that already has a border applied? I have successfully created the text with the border using the following CSS: h1 { font-size: 35pt; text-align: center; font-family: ...

How to use jQuery Animate to create a step-by-step animation with image sprites?

I'm working on creating an image sprite using jQuery and I'm curious if it's feasible to animate it in steps rather than a linear motion. I initially tried using CSS3 animations, but since IE9 is a requirement, the animations didn't wor ...

Vue unable to load material icons

The icons npm package "material-icons" version "^0.3.1" has been successfully installed. "material-icons": "^0.3.1" The icons have been imported as shown below. <style lang="sass"> $material-icons-font-path: '~material-icons/iconfont/'; ...

What causes the width of unrelated cells to change when the contents of colspan'd cells expand in IE7?

Before we delve into the details, I invite you to take a look at this fiddle using IE7. It's quite intricate and not something I want to repeat here. The main issue is that clicking on the red block should display additional information. The top row ...

Determining the window height using jQuery when overflow is set to hidden

I've built a full screen web application that I don't want to scroll, so I used this code: $("body").css("overflow", "hidden"); However, after adding a resize listener: $(window).resize(function(){ console.log("Inner height: " + $(window). ...

Deactivating a form field depending on a selected radio button in Angular 2

If I have two radio buttons, with a click function called localClick for the first button to give value 1 and the second button to give value 2. <div class="ui-g-12"><p-radioButton name="group1" value="Local" (click)=localClick(1) label="Local"&g ...

Is it possible to bind browser keyboard scrolling to a div without explicit instructions?

Here is a question that closely relates to this one: Enable div to scroll by keyboard without clicking I am aware that explicitly focusing on the element will enable the desired behavior. My inquiry is whether there is a way to achieve this implicitly. ...

How can I access the ng-template in a component?

How can I reference <ng-template #modal_Template> in my component.ts file? Previously, I triggered a modal using a button on my HTML file and included this code: <button type="button" class="btn btn-primary" (click)="openModal(modal_Template)"> ...