Icon is in perfect alignment with the surrounding text

I've encountered an issue while using linearicons - I'm trying to align the icon vertically with the text on my navbar, but it's not working as expected. The icon doesn't seem to be positioned correctly at the top of the navbar, causing a misalignment. Here's an image illustrating the problem:

https://i.sstatic.net/X7aLY.png

My goal is to align the icon vertically with the text and ensure that the entire menu is aligned with the navbar. I hope this explanation clarifies the issue for you.

Here's the HTML:

<div class="navbar navbar-default top-bar">
  <div class="container">
    <div class="infos pull-right">

      <span class="lnr lnr-clock infos-icons"></span>
      <p class="infos-text">Mon-Fri: 08:00 - 12:00</p>
      <span class="divider-vertical"></span>

      <span class="lnr lnr-envelope infos-icons"></span>
      <p class="infos-text">mail.example.com</p>
      <span class="divider-vertical"></span>

      <span class="lnr lnr-phone infos-icons"></span>
      <p class="infos-text">(880)123-456-7890</p>

    </div>
  </div>
</div>

Below is the CSS code I have been using to try and resolve this alignment issue:

.top-bar {
margin-bottom: 0;
border: none;
background-color: #9E87FF;
color: #fff;
height: 50px;
}

.navbar .divider-vertical {
    height: 50px;
    margin: 0 9px;
    border-left: 1px solid #ffffff;
    border-right: 1px solid #ffffff;
}

.infos-text {
    display: inline-block;
}

.infos .infos-icons {
    padding-right: 10px;
    font-size: 20px;
    vertical-align: middle;
    display: inline-block;
}

Answer №1

Here's the suggested CSS code:

.top-bar {
    margin-bottom: 0;
    border: none;
    background-color: #9E87FF;
    color: #fff;
    height: 50px;
    display: table-cell;
    vertical-align: middle;
}

.navbar .divider-vertical {
    height: 50px;
    margin: 0 9px;
    border-left: 1px solid #ffffff;
    border-right: 1px solid #ffffff;
}

.infos-text {
    display: inline-block;

}

.infos .infos-icons {
    padding-right: 10px;
    font-size: 20px;       
    display: inline-block;      
}

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

Tips for utilizing the onkeyup and onchange events in jQuery for automating form fields

I am looking for a way to update the input field whenever any value is changed. Specifically, I want the total value to be automatically updated when either the rate/kg or quantity is changed. ...

Changing the Checkbox Color in Bootstrap 4: Quick and easy method!

https://i.sstatic.net/znS8O.png <div class="modal-footer"> <label class="checkbox-inline pull-left" for="rme" style="background-color: green;"><input type="checkbox" class="custom-checkbox checkbox-primary" id="rme"> Remember me</ ...

What is the best way to dim the entire webpage when a popup appears?

I need help with changing the background of my sidebar to dark when clicked. I used this code, but the posts remain white and the dark background doesn't disappear when I close the sidebar. Can anyone suggest what I should do? Below is the HTML code s ...

Automated task to save HTML Table data to an Excel spreadsheet on a daily basis at a set time

Every day at 18:00 Hrs, I need to save a table from a website into an Excel sheet named with the current date and time. However, I have no programming knowledge and tried searching through Google and Stackoverflow for a solution. After some research, I fo ...

using dynamic CSS classes in a Vue app

I am currently in the process of developing a component with vuejs and tailwindcss. I have run into an issue where the colors for the background and text are not being applied properly. <template> <div :class="[isDark ? `bg-${color}-900 t ...

Using Tailwind @apply within an Angular application's CSS file

I've noticed a yellow line appearing under the @apply in my CSS files, even though the styles are being applied correctly to the HTML components. This seems to be happening in every CSS file I use. Can anyone shed light on this issue? Removing these ...

The HTML elements in my JSX code seem to constantly shift around whenever I resize my webpage

Using react.js, I'm currently developing a website that appears like this before resizing: pre-resize_screenshot_website However, upon vertical or diagonal resizing, the layout becomes distorted especially in the 'availability search bar' ...

Performing various JavaScript functions within a single hyperlink

I've implemented the Tab Content Script by dynamicdrive.com on my website. The script creates tabbed navigation, and I find it to be quite useful. Currently, I am trying to figure out how to make a single link select two tabs at once. Essentially, I ...

Style slipping away when dynamically altering CSS file with JavaScript

My webpage has a style similar to this https://i.sstatic.net/k6TGg.png I am attempting to modify the CSS using JavaScript when a button is clicked. This is my JavaScript code: this.document.getElementById('style-bandle').setAttribute('hre ...

"Ensuring content remains within the confines of a modal box

My goal is to integrate a month calendar pop-up within my app using a material UI Modal where users can choose the day. However, I am encountering an issue with the size of the modal not adapting to the calendar properly. How can I resolve this? (To open t ...

Storing dynamic content on a server and retrieving it for future use

I'm working on a webpage that allows users to create elements dynamically and I want to save those elements to the server. When someone else visits the page, I want them to see those saved elements as well. I'm not too familiar with web programm ...

How to extract and display data when clicking on a Bootstrap switch

I have integrated BootStrap Switch like this: <?php while ($arr = mysql_fetch_array($res)) { ?> <td class="center"> <?php if ($arr['status'] == 1) { ?> <input class="switch" type="checkbo ...

Whenever I open my collapsible dropdown, it seems to leap up unexpectedly

When I interact with the collapsible card, it has a jerky animation. I would like it to open smoothly instead. The issue lies with the tooltip-cus class. If I remove position: relative;, the opening animation is smooth, but then the position of the toolti ...

Encountering a Node Js post handling error with the message "Cannot GET /url

This is my ejs file titled Post_handling.ejs: <!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta charset="utf-8"> <title>POST-Handling Page</title> </head> <body& ...

Using JQuery for Smooth Image Scrolling

My goal is to create a scrolling function for images similar to the one on this website bethellery.com. Currently, my code is somewhat functional, but I am facing a major issue: the size of the scrolling bar is almost as large as my div, making it difficul ...

VueJS does not support loading Jquery

When setting up my project with Bootstrap, I encountered an issue where even though I imported the jquery.min file before Bootstrap in my main.js file using require(), Bootstrap still threw an error saying that it requires jQuery. In my main.js file, I ha ...

Utilizing Reveal and Interchange for an Adaptive Lightbox in Foundation 4

Can Foundation 4 Reveal be used with images in a way that they are only loaded when the user clicks an element to open the modal? My objective is to create an Adaptive Lightbox using Interchange. When a user clicks on a thumbnail, it should display an ima ...

CSS - positioning the sidebar on the far left edge of the screen (refer to image)

Is there a way to create a layout similar to this design: https://i.sstatic.net/yjkeD.png For a demonstration, see here: http://jsfiddle.net/ymC82/ Current HTML code: <div class="wrapper"> <aside> Sidebar </aside& ...

Difficulty with selecting the nth-child element within an Ember application

In my current project using Ember, I am faced with the challenge of targeting nth-child elements with CSS due to the presence of Ember script tags. Is there a consistent method to achieve this in an Ember application? Instead of the conventional approach: ...

MUI Datepicker options for selecting dates

Is there a way to selectively enable certain dates and disable all others in the MUI Datepicker? For example, I need to only allow dates that are 7 days later or earlier to be selectable, while all other dates should be disabled. How can this be achieved? ...