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

What kind of GWT component features both a Button and text?

I am looking to develop a customized GWT widget that consists of a rectangular div element resembling a button, accompanied by text positioned adjacent to it. My goal is to enable the selection of this widget so that clicking on either the div/button or th ...

Setting up the CSS loader in a Vue.js project using webpack

I am currently working on a new vue-cli project and have successfully installed the Pure.CSS framework using npm install purecss --save. However, I am struggling to seamlessly integrate, import, or load the css framework into my project. I am unsure of whe ...

Choosing the div elements that have a PNG background image assigned to them

Is there a way to use jQuery to target all the div elements with a background-image property set to url(somepath/somename.png) in their style? ...

Keep rolling the dice until you hit the target number

Currently, I am in the process of learning JavaScript and one of my projects involves creating a webpage that features two dice images, an input box, and a button. The objective is for users to input a value, click the button, and then see how many rolls i ...

Expand or collapse Angular Material Accordion depending on selected Radio button choice

Is it possible to use a mat-accordion with radio buttons where each panel expands only when its corresponding radio button is selected? I have the radio buttons functioning correctly, but the panels are expanding and collapsing with every click rather than ...

Tips on preventing a lone track in Laravel for Server Sent Events

In my Laravel app, I am exploring the use of Server Sent Events. The issue I have encountered is that SSE requires specifying a single URL, like this: var evtSource = new EventSource("sse.php"); However, I want to send events from various parts/controlle ...

Dealing with problematic hover behaviors in Cypress: A guide

I encountered an issue with Cypress hover functionality while trying to access a sub menu that appears after hovering over a main menu item. The error message I received was This element is not visible because it has CSS property: position: fixed and it&ap ...

"Create a Single-Page Bootstrap Website with a Responsive Design showcasing PHP Code within the Contact Form

Working on the final touches of a single-page responsive website project for a client. Utilizing a Bootstrap contact form located at the bottom of the HTML document. The PHP code is unexpectedly displaying in the text fields of the contact form. I've ...

Choose an item from the list and use the scrollbar when the menu opens

My select element has over 50 options, but the options popup and go off the page without a scroll bar. As a result, I can only see and select up to 20 options. Is there a way to make the select element display a vertical scroll bar when there are more tha ...

The issue of JQuery and document ready being triggered multiple times while loading data into a control

Ever since implementing the load function to load content into a DIV upon document ready, I've noticed that all associated functions are firing multiple times (often twice, and sometimes endlessly). The scripts included in the head tag of all pages a ...

Ways to conceal a div element when the JSON data does not contain a value

If the value in "desc" is empty, then hide <div24> and <popup-desc>. html <div class="popup"> <div class="popup-top" style="background-color: '+e.features[0].properties.fill+';"> ...

What is the best method for arranging multiple images in a grid while keeping them within a specific maximum width and height?

I've been staring at this problem for a while now, attempting every possible solution to resize images and maintain aspect ratio, but none seem to work in my case. Here are two images that I manually resized so you can view them side by side: highly ...

Tips for accessing basic information from these websites without encountering CORS issues

Having issues retrieving data from the following two sites: and Eurolottery. The CORS issue is causing the problem, and I was able to retrieve data using a Chrome CORS extension and the provided code below: var HttpClient = function() { this.get = fu ...

Custom Component in React Bootstrap with Overflowing Column

I am working on a custom toggle dropdown feature in my React application: import React from 'react'; import 'react-datepicker/dist/react-datepicker.css'; const DateRange = props => ( <div className="dropdown artesianDropdo ...

Issue with jquery .click function not triggering after CSS adjustment

In the process of creating a fun game where two players take turns drawing on a grid by clicking <td> elements. Currently, I have implemented the functionality to toggle the background color of a <td> element from black to white and vice versa ...

What is the best way to apply styling exclusively to a child component?

I am currently working on a coding project that involves a parent component and multiple child components. My main goal is to adjust the position of a filter icon by moving it down 5 pixels on one specific child component. The issue I am facing is that no ...

Is a Selenium loop a viable option?

</head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> <tr><td rowspan="1" colspan="3">test</td></tr> </thead><tbody> <tr> <td>click& ...

The content within a select tag is experiencing vertical misalignment

The select tag on my page is behaving oddly - when there is a value in it, it is aligned to the bottom vertically. Upon inspecting the CSS, I noticed that the only styles applied are font size and type. Strangely, removing the doctype from the page resol ...

Adding multiple images to email HTML with Python made easy

Looking for a solution to embed 15 .jpg images from a single folder into the body of an email without them shrinking when stacked vertically. My initial approach was to create one long image with all photos but it reduced in size as more pictures were adde ...

What is the best approach to managing categorical variables with Flask?

After developing a machine learning model to classify a target variable Y based on predictors x1, x2, x3, and others, I needed to create an HTML form "calculator" for users. The form requires the user to input data for x1, x2, x3, etc., and then displays t ...