Is the menu item a little crooked?

Working on designing a menu, and I noticed that the 'Book Now' option is slightly misaligned (pushed down) after adding a border. This seems to disrupt the horizontal alignment. Is there a way to correct this issue?

Check out my Codepen

Here is the HTML:

  <div class="navibar">
    <a class="logo" href="#">Logo</a>

    <ul class="left-bar">
      <li>
        <a href="#">ACCOMMODATIONS</a>
      </li>
      <li>
        <a href="#">DINING</a>
      </li>
      <li>
        <a href="#">SPA & WELLNESS</a>
      </li>
      <li>
        <a href="#">MEETINGS & EVENTS</a>
      </li>
      <li>
        <a href="#">ADVENTURES</a>
      </li>
    </ul>

    <ul class="right-bar">
      <li>
        <a class="btn btn-ghost" href="#">BOOK NOW</a>
      </li>
    </ul>
    <div style="clear:both"></div>

  </div>

And the CSS:

  * {
      list-style: none;
      margin: 0px;
      padding: 0px;
      text-decoration: none;
    }

    .navibar {
      margin: 0 auto;;
      width: 1100px;
      background: rgba(18, 23, 26, 0.4);
      padding: 20px;
    }

    .navibar li a {
      color: white;
      display: inline-block;
      padding-top: 5px;
      padding-bottom: 5px;
      padding-left: 20px;
      padding-right: 20px;
    }

    .logo {
      float:left;
      padding-top: 5px;
      padding-bottom: 5px;
      padding-left: 10px;
      padding-right: 10px;
      padding-right: 100px;
    }

    .navibar li {
      float: left;
    }
    .left-bar {
      float: left;
    }
    .right-bar {
      float: right;
    }

    .btn:link,
    .btn:visited {

      /*<a> is a inline element which doesn't allow padding, so need to change to inline-block */

      /* 10 on top and bottom and 30 left and right */
      font-weight: 300;
      word-spacing: 3px;
      font-family: brandon-grotesque;
      text-decoration: none;
      /*Takes away line on bottom of words */
      transition: background-color 0.2s, border 0.2s, color 0.2s;
      /* makes color subtly change instead of instantly. More applealing */
    }

    .btn-full:link, .btn-full:visited {
      background-color: #fff;
      /* From flat UI colors */
      border: 1px solid #fff;
      color: #fff;
      margin-right: 10px;
    }

    .btn-ghost:link, .btn-ghost:visited {
      border: 2px solid #fff;
      color: #fff;
    }

It seems like Borders don't affect padding or margin, but please correct me if I'm mistaken.

Just adding some filler text because apparently Stack Overflow wants more words. Is this enough?

Answer №1

To achieve the desired effect, simply utilize a negative margin-top along with a border width

.btn-ghost:link, .btn-ghost:visited {
  border: 2px solid #fff;
  margin-top: -2px;
  color: #fff;
}

Prior to adding the border, the elements were perfectly aligned, but the 2px border causes the element to shift downward. To counteract this, you can adjust the positioning of the item or introduce an invisible border or margin to the surrounding items

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

Hiding a div using the Bootstrap `.hidden-xs` class may not work as

I have been working on a website and I want to hide a specific section for users viewing it on small screens. I tried using Bootstrap's .hidden-xs class, but when I tested it using Chrome's mobile emulator set to "iPhone 5", the div did not hide ...

What is the best way to eliminate the border in IE edge that surrounds special characters?

Here is the current appearance of the cross button in IE/Edge: https://i.sstatic.net/JZ37V.png And here is how it is supposed to look: https://i.sstatic.net/Uqafg.png Upon inspecting the CSS, it reveals that the #10006 html character has a color code o ...

Adjusting the position of an element when the width of its parent div shifts

Struggling with the challenge of absolute and relative positioning in CSS. My GUI allows users to view folders and select how many columns they appear in, as shown in the images provided. Beneath each folder is an input field for renaming and a clear butto ...

Is it feasible to utilize the HTML5 video tag in conjunction with a JSON callback?

Curious about the possibility of a video page layout featuring a main screen and smaller clickable screens below it. When clicking on one of the smaller screens, the main screen would display the selected video, similar to YouTube. We have obtained data f ...

What is the best way to design a form with two dropdown menus, where the options in the second dropdown menu are determined by the selection made in the first dropdown menu

Is it possible to create two select menus using one dictionary in Django, where the values in the second menu are dependent on the key selected in the first menu? In my Django views.py file, I've constructed a dictionary with Projects as keys and cor ...

Enhanced Firefox functionality with support for multiple columns

It has come to my attention that Internet Explorer 9 and older versions do not support multiple columns. However, even with the latest version of Firefox, I am experiencing issues with this website loading correctly. Do you have any insight into what might ...

Using functions like nl2br() for new line breaks, preg_replace for replacing patterns, htmlspecialchars() for encoding special

I've reviewed all the answers on this topic, but I'm still struggling to find the correct method for sanitizing data. My task is to enter: <?php echo 'yes'; ?> <?php echo 'yes' ?> into a text area, submit it in ...

Using CSS to create a triangular background within a <div> element

I am looking to create a CSS triangle shape for a background, but I am unsure of how to achieve this or if it is even possible. Ultimately, I want the menu to resemble the image linked below: While I have come across methods to create the desired shape, ...

Inquiries about the jQuery Button Timer

Currently experimenting with jQuery to create a timer. Everything seems to be in place and the Stop Timer button is functioning properly. However, I'm facing issues with the Start Timer and Reset Timer buttons as they are not working as expected. Seek ...

Sending data to API using AngularJS Http Post

Upon clicking "Add new User", a modal pop-up will appear with a form containing a text field and a checkbox. However, upon clicking the create button, the data is not being posted to the API and the modal pop-up remains open without closing. I would like ...

The picture tag in HTML5 is failing to be responsive when used with Bootstrap

I'm experimenting with the html5 <picture> tag to set different images. I placed the 2 pictures within a bootstrap grid, allowing them to be responsive until the breakpoint 768px, where the image changes. However, when I decrease the browser si ...

Exploring CSS Shapes: Unveiling the secrets behind the star. What's the mechanism at

https://i.stack.imgur.com/0BgQr.png Take a look at the code snippet below showcasing The Shapes of CSS. I'm interested in delving into the intricacies of these CSS properties. How exactly do shapes in CSS function? This includes pseudo CSS, borders, ...

Is there a way to manipulate the direction of bouncing divs using a button?

I want to design a single button that can control the bouncing motion of my div elements. The initial configuration will have the space divs arranged in a static, straight line. Once the button is clicked, the divs should start bouncing within their conta ...

Showing Stationary Pictures at Full Size in OpenLayers

I am trying to showcase static images as maps using a StaticImage layer in ol3, with the image size set at 100% in pixels. However, I am facing difficulty in ensuring that the displayed images are always the correct size based on the extent and zoom variab ...

What is the best way to notify the user if the percentage entered is not a numeric value?

My role is to notify the user when the entered value exceeds the acceptable range: if (document.myForm.outputPercentage.value <= 0 || document.myForm.outputPercentage.value >= 100) { alert( "Please enter a percentage between 1 and 100 ...

Steps for leveraging pdfMake with live data

Recently delving into Angular, I've been exploring the capabilities of pdfMake. While I successfully incorporated static data, I'm facing challenges when attempting to utilize dynamic data. Any guidance on how to achieve this would be greatly app ...

Is jQuery causing the table to exceed the page width?

I have a table in my HTML document that is displaying too many columns in a single row (~25), causing the table to stretch beyond the size of the page and creating unwanted scrollbars. I am seeking a solution to shrink the content of each column while also ...

When `focus` is bound to a jQuery event handler, the behavior of the select element becomes erratic on

What causes the odd behavior where users need to click twice on a select-option for it to drop down/up after binding an eventhandler to the focus event using jQuery? $('input, select, textarea').focus(function() { $(this).addClass('input_ ...

Bootstrap version 5.3.0 has a unique behavior where dropdowns placed outside the collapsed area of the navbar will display the menu inside the navbar, rather than outside

Is there a way to fix the issue where the dropdown menu appears in the body of the navbar when it is collapsed? I have tried using attributes like data-bs-reference but couldn't find much information on how to resolve this. <nav class="navbar ...

Using HTML, CSS, and JavaScript, the main tab must include nested subtabs to enhance navigation and

When a user clicks on a tab, another tab should open within the main tab. Depending on the selection in the second tab, input fields should appear while others hide. Something similar to the nested tabs on expedia.com. I have experimented with the tab vie ...