The pair of divs with distinct backgrounds

Looking to customize the navigation on my website by creating a separate background for the list links menu and making sure the left part of the navigation with the logo has its own distinct background that extends until the next div. I've experimented with various approaches but none of them have worked as intended. The issue is that the background for the left side with the logo only occupies the space under the text rather than the entire div.

Check out the example below:

$('.navigation ul li a').on('mouseover', function() {
  $(this).parent().addClass('navigation-hover');
}).on('mouseout', function() {
  $(this).parent().removeClass('navigation-hover');
})
.navigation {
  font-size: 3em;
  height: 70px;
  position: fixed;
  right: 0;
  left: 0;
}

.navigation-logo {
  float: left;
  background-color: rgba(0, 0, 0, 0.2);
}

.navigation ul {
  display: inline;
}

.navigation ul li {
  float: right;
  font-size: 0.5em;
  line-height: 60px;
  height: 70px;
  display: inline-block;
  text-align: center;
  padding-left: 10px;
  color: #ffffff;
  padding-left: 10px;
  background-color: rgba(0, 0, 0, 0.2);
}

.navigation-hover {
  background: transparent !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<div class="navigation">
  <div class="navigation-logo">
    <a class="navigation-logo">logo</a>
  </div>
  <div>
    <ul>
      <li><a href="">link1</a></li>
      <li><a href="">link2</a></li>
      <li><a href="">link3</a></li>
      <li><a href="">link4</a></li>
    </ul>
  </div>
</div>

Answer №1

/* Customized Styles */

.header {
  font-size: 3em;
  height: 70px;
  justify-content: space-between;
  margin: 0 8px;
  width: calc(100% - 16px);
  display:flex;
  left:0;
  position:fixed;
  flex-direction: row;
}

.logo {
  background-color: rgba(0, 0, 0, 0.2);
}

.menu-items {
  display:inline;
}

.menu-items li {
  float:right;
  font-size: 0.5em;
  line-height: 60px;
  height: 70px;
  display:inline-block;
  padding-left: 10px;
  text-align:center;
  color:#ffffff;
  background-color:rgba(0, 0, 0, 0.2);
}

.menu-hover {
  background:transparent !important;
}
    Link to the updated code on Plunker:

    http://plnkr.co/edit/0PY5IPExNYVwQPsOVyXS?p=preview

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

Scraping data from a support portal using JSOUP

I am currently learning how to utilize jSoup for web scraping purposes on this specific portal that focuses on LAN switching and routing discussions. Link to the portal My goal is to extract information from a list of topics, specifically identifying sol ...

Problem with the mobile site width due to viewport misalignment

Our website is currently experiencing an issue with the viewport, but it seems to only occur on mobile devices: If you visit the site on your mobile device, you may notice a large gap on the right side of the page. Strangely, this problem does not appear ...

Why isn't my custom HTML attribute displaying correctly?

In my current React app project, I have been incorporating custom attributes to HTML tags and React components for End-to-End (E2E) tests using Testcafe. However, I am facing an issue where the additional data-test="burger-menu-btn" attribute is ...

Changing the arrow in jQuery's slideToggle for different div elements is a breeze

Good day, I'm struggling with getting the arrow switch to work correctly for slideToggle. Even though I have three of them, the arrow changes only for the first one - no matter which div I click on. Any suggestions on what I might be missing? Thank yo ...

Retrieve the values by accessing an element upon clicking the "Submit" button

Here is an interesting example that I found on this website I am currently working on a simple webpage to display both the current forecast and extended forecast. This is my Index.html: <!DOCTYPE html> <!-- To change this license header, choose ...

Display a div using Jquery depending on the visibility and checked value of another div

Trying to toggle the visibility of a div based on another div's input has proven to be quite challenging in this scenario. Here is the HTML setup: <div id="main-question"> <div class="form-group"> <div class="form-radios"> ...

Ensure that the floating div is positioned along the right side and adjusts to accommodate the

I've been searching for a solution to this issue, but it seems like I might not be articulating it correctly because I haven't been able to find an answer yet. On my page, there is a 'quick links' button that is supposed to stay fixed ...

Issue encountered during the execution of the project on wamp server

I am working on a PHP 5 website and have downloaded all the files from the server to my WAMP for editing some text. However, when I try to run localhost, I encounter an error: **Internal Server Error The server has encountered an internal error or miscon ...

Using Javascript within HTML: A guide on when to utilize semi-colons and when to implement the return false statement

Exploring the use of JavaScript attributes within HTML elements: <input type="button" onclick="somceFunc()" /> <input type="button" onclick="somceFunc();" /> <input type="button" onclick="somceFunc(); return false;" /> Debating whether ...

A guide on personalizing HTML for Django forms

I have implemented an HTML template on my website and need to capture information for my Django backend. Specifically, I am trying to extract the email address from this section of code: <input type="text" placeholder="Email" value="" style="height: 30 ...

How to position ul at the bottom of a fixed div

I have a fixed sidebar with two ul elements. I attempted to position the blue ul at the bottom of the fixed div, but it is not aligning as intended. <div class="sidebar"> <ul style="background:green;"> <li>test</li> <li>test ...

Utilize the text box feature for manipulating the data field in Angular4

Within my grid view, there exists a column labeled remark. This specific field contains various values, one of which is absence. My objective is to modify the remark value exclusively when it is equal to absence, followed by clicking the corresponding icon ...

Attempting to create a multi-page slider using a combination of CSS and JavaScript

Looking for help with creating a slider effect that is triggered when navigating to page 2. Ideally, the div should expand with a width of 200% or similar. Any assistance would be greatly appreciated! http://jsfiddle.net/juxzg6fn/ <html> <head& ...

Transfer the value of a JavaScript variable to paste it into a fresh tab on Google Chrome

I have come across some examples where users can copy HTML text to the clipboard. However, I am working on something more dynamic. Here's what I'm trying to achieve: <button id="" ng-click="outputFolder()">Output Folder</button> $sc ...

Using AJAX to update content based on selected value in a dropdown menu

My challenge lies in ensuring that a select box retains the selected value from a database entry and triggers an onchange event during form editing or updating. While I have successfully populated the data in the select box based on other selections, I a ...

Tips on adjusting the size of a font icon using an inline element prior to the font being fully loaded

I'm facing an issue with embedding an icon font within text so that it wraps properly. Currently, the only way I can achieve this is by using &nbsp; between the text and the icon (i tag with font awesome). However, this causes a problem as the ico ...

Tips on creating a post that can be viewed exclusively by one or two specific countries

I'm stumped on how to create a post that is visible only to specific countries. How can I code it to determine the user's country without requiring them to make an account? Any advice or hints would be greatly appreciated. ...

Updating the background of a specific div element by retrieving data from an SQL database

I have a unique situation where I have a div element with the property set to runat="server" and an ID assigned to it. I am attempting to dynamically set the background image for this specific div from a MySQL database where the path URL is stored in a r ...

Fixing the filter button: A step-by-step guide

I'm new to html and spring boot, and I'm currently working on filtering and searching for books in a list based on the author, description, etc. However, it seems that my button isn't functioning properly. Can someone please assist me with t ...

I am unable to sketch my backdrop. - HTML Canvas Game

Recently I've encountered an issue in my code where the image doesn't appear and mouse interaction stops working when I uncomment bg.draw() within the draw function. function draw() { clearAllCtx(); player.draw(); ene ...