The border below the menu is not extending to the entire width of the page

Seeking assistance to create a menu with bordered items that have a border on the right and a full-width bottom border. Facing an issue where the bottom border only spans the container width, rather than the entire screen. The use of a container class is necessary in order for the category text to fit within the container width.

Additionally, encountering a problem where hovering over each item causes the text to shift slightly. Any insights on why this is happening?

If you have any solutions to these problems, I'd greatly appreciate it!

For reference, here is the code demonstrating the issues: http://jsfiddle.net/pjgt1q35/

HTML

<div class="jumbotron p-0 m-0">
  <div class="container">
    <div class="row align-items-center">
      <div class="col-7">
        <h1 class="display-5 font-weight-bold text-dark">Title</h1>
        <p class="lead text-light">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Incidunt voluptatum consequatur deserunt vel dicta voluptatibus sit asperiores minus dolore quidem assumenda amet officiis sequi facere harum accusamus, possimus omnis reiciendis.</p>
      </div>

      <div class="col-5">
        <img src="https://via.placeholder.com/490" width="490" height="300">
      </div>
    </div>
  </div>
</div>

<div class="container">
  <div class="col p-0 m-0">
    <ul class="categories_menu">
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 1</a>
      </li>
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 2</a>
      </li>
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 3</a>
      </li>
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 4</a>
      </li>
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 5</a>
      </li>
      <li><a data-toggle="modal" id="" data-target="" href="">More
        <i class="fa fa-caret-down" aria-hidden="true"></i></a></li>
    </ul>

  </div>
</div>

CSS

.categories_menu {
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  width: 100%;
  -moz-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  transition: all 100ms ease-out;

  li {
    -moz-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    border-bottom: 5px solid transparent;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
    -moz-box-flex: 1;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    height: 59px;
    -moz-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    padding: 10px 0 5px 0;
    border-left: 1px solid red;
    border-bottom: 1px solid red;

    &:first-child {
      border-left: 0;
    }

    &:hover {
      border-bottom: 5px solid red;
      color: #000;
      cursor: pointer;
      text-decoration: none
    }
    a {
      color: #414e5f;
      font-size: 18px;
      font-weight: bold;
    }
    &.active {
      border-bottom: 5px solid red;

    }

  }
}

Answer №1

If you want to create a full-width container, consider using container-flex instead of container. Inside the container, add a row and then insert the col.

<div class="container-flex">
<div class="menu-row row">
<div class="col p-0 m-0">
    <ul class="categories_menu">
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 1</a>
      </li>
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 2</a>
      </li>
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 3</a>
      </li>
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 4</a>
      </li>
      <li class="list-item--hidden">
        <a href="javascript:void(0)" name="category" id="">Item 5</a>
      </li>
      <li><a data-toggle="modal" id="" data-target="" href="">More
        <i class="fa fa-caret-down" aria-hidden="true"></i></a></li>
    </ul>

  </div>
</div>

To style it, use:

.menu-row {
    border-bottom: 1px solid red;
}
.menu-row ul {
    margin-bottom: 0;
}

In order to prevent hover issues with <li>, apply this style:

a {
    color: #414e5f;
    font-size: 18px;
    font-weight: bold;
    border-bottom: 5px solid transparent;
}
&.active {
    border-bottom: 5px solid red;
}

.categories_menu {
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  width: 100%;
  -moz-box-pack: justify;
  -ms-flex-pack: justify;
  justify-content: space-between;
  transition: all 100ms ease-out;
}

li {
    -moz-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    border-bottom: 5px solid transparent;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    display: -moz-box;
    display: -ms-flexbox;
    display: flex;
    -moz-box-flex: 1;
    -ms-flex: 1 1 auto;
    flex: 1 1 auto;
    height: 59px;
    -moz-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    padding: 10px 0 5px 0;
    border-left: 1px solid red;
}

    li:first-child {
      border-left: 0;
    }

    li:hover {
      border-bottom: 5px solid red;
      color: #000;
      cursor: pointer;
      text-decoration: none
    }
    a {
      color: #414e5f;
      font-size: 18px;
      font-weight: bold;
      border-bottom: 5px solid transparent;
    }
    &.active {
      border-bottom: 5px solid red;
    }

.menu-row {
  border-bottom: 1px solid red;
}
    
.menu-row ul {
  margin-bottom: 0;
}
    
<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
</head>
<body>

    <div class="container-flex">
    <div class="menu-row row">
    <div class="col p-0 m-0">
        <ul class="categories_menu">
          <li class="list-item--hidden">
            <a href="javascript:void(0)" name="category" id="">Item 1</a>
          </li>
          <li class="list-item--hidden">
            <a href="javascript:void(0)" name="category" id="">Item 2</a>
          </li>
          <li class="list-item--hidden">
            <a href="javascript:void(0)" name="category" id="">Item 3</a>
          </li>
          <li class="list-item--hidden">
            <a href="javascript:void(0)" name="category" id="">Item 4</a>
          </li>
          <li class="list-item--hidden">
            <a href="javascript:void(0)" name="category" id="">Item 5</a>
          </li>
          <li><a data-toggle="modal" id="" data-target="" href="">More
            <i class="fa fa-caret-down" aria-hidden="true"></i></a></li>
        </ul>
      </div>
    </div>
</div>
</body>
</html>

Answer №2

UPDATE: After reading your previous comment, would it be possible to generate a fresh div?

<div class="bordered-bottom-div">
    ....beginning with the main container div
</div>

Add a bottom border to contain your menu within the width of the container.

Answer №3

The menu has padding on the left side

.categories_menu {
    padding-left: 0;
}

When you hover over the menu item, it moves because of the following CSS:

Hover

border-bottom: 5px solid red

Non-hover

border-bottom: 1px solid red;

There is a difference of 4px between the hover and non-hover states, causing the item to move down by 4px when hovered over.

To fix this, apply the border to the <a> element when hovering instead of the <li>

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

My website's links are fully functional with Mozilla Firefox, providing a seamless browsing experience for users

When accessing my website using Google Chrome, Safari, and Internet Explorer from different computers in various locations, I noticed that certain links do not work properly. Surprisingly, these links function perfectly when using Firefox. For instance, o ...

The essence of my design disappears when I generate a canvas object using Fabric.js

After defining top and left attributes for a Canvas Object using a JavaScript function, I encounter an issue when creating a fabric Canvas object. var fabricCanvas = new fabric.Canvas('mycanvas'); Upon creation, my HTML Canvas has its top and ...

Top scroll button malfunctioning on this page

Updated question for better understanding. In my current project, let's imagine I am on the following URL: http://127.0.0.1:8000/blog/ and within that page I have the following HTML: <a href="#top">Back to top</a> Upon hovering over tha ...

Creating a dynamic background color that pulses with animation

I recently created a script to animate the menu li element when hovering over the corresponding a element. Everything is functioning as expected, but now I'm looking to enhance the effect by having it continue as long as the mouse remains over the a e ...

Customize WordPress zerif-lite theme with CSS to decrease page width temporarily

Is there a way to decrease the width of a specific page on my website without modifying the current theme that I am using (zerif-lite)? I want to accomplish this task by adding custom CSS to styles.css. However, I am facing difficulties as I only want to a ...

What purpose does the blank space above the navigation bar serve?

Looking to create a fixed navigation bar but encountering space above the menu. I've tried various solutions to no avail, searching through the code for any potential spacing issues. #nav { position: fixed; text-align: center; font-size: 22px ...

An Angular JS interceptor that verifies the response data comes back as HTML

In my current Angular JS project, I am working on implementing an interceptor to handle a specific response and redirect the user to another page. This is the code for my custom interceptor: App.factory('InterceptorService', ['$q', &ap ...

Is it possible to incorporate an element using absolute positioning using jQuery or Javascript?

When trying to add a new element on the screen, I am facing an issue with the absolute positioning not working properly. Sample Code in Javascript function drawElement(e,name){ $("#canvas").append("<div id='" + name + "' class='e ...

Troublesome Outlook display problem with responsive email template

Could someone take a look at the following code snippets and point out any errors that I may have made? While testing my template on litmus, everything appears to be fine. However, when I send a test email to my outlook account, the template displays ver ...

How to Align Unstyled Bulleted List in the Center

I currently have a ul element nested within a table using HTML. I found that I am able to horizontally center the ul by adding the following inline style: style="display:inline-table" However, I'm wondering if there is a way to achieve this centerin ...

Converting an HTML div to a string for export

In the process of developing my application, I am utilizing an angular widget to construct a dynamic dashboard. Here is the snippet of HTML code along with the associated JavaScript that enables this functionality: <div class="page" gridster="gridsterO ...

Is the scrapy user agent programmed to overlook custom data attributes?

https://i.sstatic.net/y82uq.png According to user agents, custom data-attributes are likely to be ignored. Referencing an image from w3schools, I am wondering if scrapy is also disregarding these tags since I am receiving an empty list, possibly due to th ...

Encountering a Source map error in my React project: Issue arises from Error: request unsuccessful due to status

Encountering a Source Map Error with status 403 in my React project console I suspect the UseEffect hook is not functioning properly in displaying the list from the API response The API successfully returns the response as a list, but when iterating thro ...

Modify the div's max-width attribute based on checkbox selection in HTML

There is a coding challenge involving a checkbox and a div. When the checkbox is checked, the max-width attribute of the div should decrease (causing it to shrink in size), and vice versa. function adjustTableWidth(checkbox) { var table = document. ...

Utilize CSS to specifically target the image source within a button and swap it with a different image in the Woocommerce Wishlist Plugin on your Wordpress

I have integrated the Woocommerce Wishlist plugin into my Wordpress website and I am looking to customize the appearance of the 'Add to Wishlist' button. Upon inspecting the source code, I noticed that the button is styled with a GIF image. I wou ...

Drawing a line beneath the mouse's center using JavaScript

Struggling with my JavaScript drawing tool, particularly the draw() function. The line is consistently off-center below the mouse cursor. How do I fix this issue? My aim is to have the line always follow the center of the mouse as it moves. Could someone c ...

What is the best way to make AngularJS acknowledge invalid input that has already been identified by the browser?

Encountering an issue (specifically in Chrome) where a number input is deemed invalid by the browser, but valid as per Angular. <form name="form_name"> <input type="number" step="any" id="a_number" name="a_number" min="0" ng:model="aN ...

Tips for showcasing personalized validation alerts with jQuery in the HTML5 format?

One of the Javascript functions I designed is for validating file extensions before uploading: function validateFileExtension(field, extensions){ file_extension = field.val().split('.').pop().toLowerCase(); if ($.inArray(file_extension,exten ...

Using both position: absolute and position: relative simultaneously does not yield the desired results

Can someone help me figure out why my announcement is showing up in the wrong place on different browsers? Here's the code: This is my HTML code: and this is my CSS code: .announce { height: 45px; width: 100%; position: relative; } ...