The navigation bar designed with flex boxes is experiencing an issue where the "Login" button positioned on the right is being partially hidden

My website's navbar has a display: flex property to provide padding around the links, but it is causing some issues with overflow. For more details, you can check the JSfiddle link here: https://jsfiddle.net/Bradley_/3bhroby2/3/

I have noticed that my "Login" link gets cut off slightly, especially when zooming in or when there is overflow. Is there a way to fix this while maintaining its position and slight indentation? Any help would be appreciated.

Below is the CSS code:

body {

  margin: 0;
  overflow: visible;
}

#navbar {
  overflow: hidden;
    background-color: #D50000;
    padding:13px 20px;
      display: flex;
    justify-content: flex-start;

}

#navbar a {
        font-family: 'Exo', sans-serif;
    font-size: 15px;
    float: left;

    color: #f2f2f2;
    font-size: 15px;
    padding:13px 20px;
    text-decoration: none;

}

#navbar a:hover {
  background-color: rgba(0,0,0, 0.03);
  color: black;

}

#navbar a.active {
  background-color: #e60000;
  color: white;
}

.content {
  padding: 16px;
}

.sticky {
  position: fixed;
  top: 0;
  width: 100%
}

.sticky + .content {
  padding-top: 70px;
}

.right {
  margin-left: auto;
}

Here is the HTML code snippet:

    <div id="navbar" class="sticky">
    <a class="active" href="index.php">Home</a>
        <a href='matchday.php'>Matchday</a>
        <a href='news.php'>News</a>
        <a href='stats.php'>Stats</a>
        <a href='gallery.php'>Gallery</a>
        <a href='forum.php'>Forum</a>
    <a href='more.php'>More...</a>
        <?php if( isset($_SESSION['username']) && !empty($_SESSION['username']) )
{
?>

        <a style="float:right;" class="open profile dropbtn" href="profile.php"></a>




<?php }else{ ?>
              <a class="right" href="#about">Sign Up </a>
              <a href="#about">Login</a>


<?php } ?>

Answer №1

There is a problem with the padding on #navbar as it is being added to the width, causing it to overflow the viewport. To fix this issue, you can add the box-sizing rule. For more information, you can visit this link: more info here

If you want to see the updated fiddle, click on this link: updated fiddle

html {
  box-sizing: border-box;
}

*,
*:before,
*:after {
  box-sizing: inherit;
}

body {
  margin: 0;
  overflow: visible;
}

#navbar {
  overflow: hidden;
  background-color: #D50000;
  padding: 13px 20px;
  display: flex;
  justify-content: flex-start;
}

#navbar a {
  font-family: 'Exo', sans-serif;
  font-size: 15px;
  float: left;
  color: #f2f2f2;
  font-size: 15px;
  padding: 13px 20px;
  text-decoration: none;
}

#navbar a:hover {
  background-color: rgba(0, 0, 0, 0.03);
  color: black;
}

#navbar a.active {
  background-color: #e60000;
  color: white;
}

.content {
  padding: 16px;
}

.sticky {
  position: fixed;
  top: 0;
  width: 100%
}

.sticky+.content {
  padding-top: 70px;
}

.right {
  margin-left: auto;
}
<div id="navbar" class="sticky">
  <a class="active" href="index.php">Home</a>
  <a href='matchday.php'>Matchday</a>
  <a href='news.php'>News</a>
  <a href='stats.php'>Stats</a>
  <a href='gallery.php'>Gallery</a>
  <a href='forum.php'>Forum</a>
  <a href='more.php'>More...</a>
  <a style="float:right;" class="open profile dropbtn" href="profile.php"></a>
  <a class="right" href="#about">Sign Up </a>
  <a href="#about">Login</a>
</div>

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

jQuery: Struggling with removing dynamically generated elements

Hey, I've hit a roadblock with this issue and can't figure out why it's not working. To give you an idea of what I'm trying to do, I've put together a jsfiddle: http://jsfiddle.net/ZNbm8/ This is my jQuery code: var count = 0; $ ...

concealing the date selection feature on the data picker

$('.year').datepicker({ changeMonth: true, changeYear: true, showButtonPanel: true, dateFormat: 'MM yy', onOpen: function(dateText, inst) { $("table.ui-datepicker-calendar").addClass('hide') }, onClos ...

The text box remains disabled even after clearing a correlated text box with Selenium WebDriver

My webpage has two text boxes: Name input box: <input type="text" onblur="matchUserName(true)" onkeyup="clearOther('txtUserName','txtUserID')" onkeydown="Search_OnKeyDown(event,this)" style="width: 250px; background-color: rgb(255, ...

Is it possible to automatically adjust the size of components on a html/cshtml page based on the current window size?

Currently, I am facing an issue with my website where multiple panels are created using a foreach loop that includes textareas/textboxes. Whenever I resize my browser window, it messes up the UI by shifting the position of the textareas and other elements. ...

I'm wondering why my typography components display correctly on my local host, but not on my aws server. Any insights on

I've encountered an issue with the typography component I'm using for my headings. When I publish the website, the headings do not render properly and the styles are not applied correctly. Strangely, everything looks fine during npm run dev, but ...

Creating a toggle label using just CSS: a step-by-step guide

Recently, I was trying to create a toggle label using HTML, CSS, and JavaScript. Here is the code snippet that I experimented with: function genre_itemclick(item){ if(item.classList.contains('light_blue_border_button')) { ...

LESS: Using variable values in mixin and variable names

I am looking to simplify the process of generating icons from svg-files while also creating a png-sprite fallback for IE8 support. I am using grunt.js and less. I was inspired by the implementation on 2gis.ru: (in Russian), where they used technologies s ...

Css styling for text highlighting

It's been some time since I encountered a CSS problem, but here I am facing one. In short, I want to highlight text with a gradient background, which I managed to achieve using the <span> tag and setting a background image on it. However, I ran ...

The dragging and dropping feature for HTML input type="file" is not functioning properly in Edge and IE11

I've developed an Angular app using this sample where I have included only an input control on the screen. Within my project, I constructed a custom file-uploader component. While I am able to drag and drop files in Chrome, I encountered issues with d ...

Utilize text alignment effectively by considering language direction - left-to-right for English and right-to-left for Arabic

I am managing a community website and I am looking to customize the text direction based on the language of the posts. For English posts, I want the direction to be LTR with text-align: left) For Arabic posts, I want the direction to be RTL with text-ali ...

Tips for extracting data from a table's options:

Can someone help me with this HTML table issue? In columns col6 and col7, I have select elements that store different options. What I'm trying to do is retrieve all the data from the table based on the options selected in columns col6 and col7. Howev ...

Utilizing Django for tables with over two items in a template

I've been on the lookout for a solution to create a Django template that can display more than just 2 values per row in a table. Imagine having a class with 5 attributes, and wanting these attribute values showcased in a table on your HTML page. Init ...

Add a new to-do list item to the current list using jQuery

Currently, I am in the process of developing a todo list application using jQuery. However, I have encountered some issues and bugs that are causing challenges. Initially, my objective was to set the first element through HTML code, which is functioning as ...

Fuzzy division following a CSS transformation/animation

I have been working on a content slider, using the guidelines from this demonstration However, I have encountered an issue where my content, which consists of a few divs, appears slightly blurry after the CSS transition completes. This problem only seems ...

Create a surplus of information

I'm currently working on a project where I need to replicate all the entries multiple times and then have them spin and gradually land on a color. However, I'm encountering an issue with duplicating the colors without increasing the width. How ca ...

Adjusting the CSS link using jQuery isn't as effective as expected

I am in the process of developing a web application that users will use in the field, and they have requested the ability to manually switch between light and dark styles based on the ambient lighting conditions. I am utilizing jQuery for this project. I ...

How can I ensure that Chakra UI MenuList items are always visible on the screen?

Currently, I am utilizing Chakra UI to design a menu and here is what I have so far: <Menu> <MenuButton>hover over this</MenuButton> <MenuList> <Flex>To show/hide this</Flex> </MenuList> </ ...

What's the reason for the font weight property in CSS not affecting the font family?

The code structure in my HTML file includes a link to Google Fonts with the following call: <link href="https://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet"> Following that, I specify the font family and weight in the CSS section: ...

After clicking on a specific href element with a designated class, trigger the display of a custom dialog styled using CSS

I recently added a unique class to certain links on my website. When these specific links are clicked, I want them to trigger a customized dialog box. My goal is to modify the CSS of this special dialog box. Only links with this particular class should ...

What is the trick to have a CSS element overflow the boundaries of its containing div entirely?

Currently, I have a JS Fiddle project where I am attempting to achieve a specific effect. In the project, there is a circle positioned at the center of a div. When the script runs, the circle expands evenly in all directions until it reaches the borders on ...