Connect with an icon link in the header bar

My header has three sections: left, center, and right. The left section is currently empty. In the center section, I have placed my page title, while in the right section, there is an "Account" link with an icon next to it. However, the icon appears to be slightly pushed towards the top, leaving a gap below it beside the word. I want both the word and the icon to align on the same line and at the same height. How can I correct this? To illustrate the issue better, I have added a red background.

html {
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

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

body {
  background-color: #f5f5f5;
  margin: 0;
  padding: 0;
  position: relative;
  height: 100%;
}

#in {
  width: 1000px;
  margin-left: auto;
  margin-right: auto;
  height: 100%;
}


/* ------------------------------------------------------------------------ */


/* -------------------------------- HEADER -------------------------------- */


/* ------------------------------------------------------------------------ */

header {
  background-color: #131b23;
  border-bottom: 6px solid #0f151a;
  text-align: center;
  left: 0;
  top: 0;
  width: 100%;
  height: 170px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  z-index: 99;
}

#left {
  background-color: green;
  width: 20%;
  position: absolute;
  height: 164px;
}

#center {
  background-color: red;
  width: 60%;
  margin-left: auto;
  margin-right: auto;
  height: 100%;
  position: absolute;
  left: 20%;
  right: 20%;
  height: 164px;
}

#right {
  background-color: blue;
  width: 20%;
  height: 100%;
  position: absolute;
  right: 0;
  height: 164px;
}

#heading {
  font-size: 60px;
  display: block;
  margin-bottom: -7px;
  margin-top: 15px;
}

.accountlink {
  font-family: "Helvetica";
  text-decoration: none;
  font-weight: 800;
  color: #ffffff;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  background-color: red;
  position: absolute;
  right: 30px;
  top: 15px;
}

.navigationicon {
  position: relative;
  width: 24px;
  margin: 0;
  padding: 0;
  top: 50%;
  bottom: 50%;
}
<header>
    <div id="left">
    </div>
    <div id="center">
      <h1 id="heading">My Page</h1>
    </div>
    <div id="right">
      <a class="accountlink" href="login.html">Account <img class="navigationicon" src="https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/user_male2-512.png"></a>
    </div>
  </header>

Answer №1

Could you please review this for me?

html {
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

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

body {
  background-color: #f5f5f5;
  margin: 0;
  padding: 0;
  position: relative;
  height: 100%;
}

#in {
  width: 1000px;
  margin-left: auto;
  margin-right: auto;
  height: 100%;
}


/* ------------------------------------------------------------------------ */


/* -------------------------------- HEADER -------------------------------- */


/* ------------------------------------------------------------------------ */

header {
  background-color: #131b23;
  border-bottom: 6px solid #0f151a;
  text-align: center;
  left: 0;
  top: 0;
  width: 100%;
  height: 170px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  z-index: 99;
}

#left {
  background-color: green;
  width: 20%;
  position: absolute;
  height: 164px;
}

#center {
  background-color: red;
  width: 60%;
  margin-left: auto;
  margin-right: auto;
  height: 100%;
  position: absolute;
  left: 20%;
  right: 25%;
  height: 164px;
}

#right {
  background-color: blue;
  width: 20%;
  height: 100%;
  position: absolute;
  right: 0;
  height: 164px;
}

#heading {
  font-size: 60px;
  display: block;
  margin-bottom: -7px;
  margin-top: 15px;
}

.accountlink {
  font-family: "Helvetica";
  text-decoration: none;
  font-weight: 800;
  color: #ffffff;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  background-color: white;
  position: absolute;
  left: 50px;
  top: 20px;
  background: url("https://cdn2.iconfinder.com/data/icons/ios-7-icons/50/user_male2-512.png");
  background-size: 24px;
  background-repeat: no-repeat;
  background-position-x: right;
  background-position-y: 0px;
  width: 40%;
  line-height: 2;
}
<header>
    <div id="left">
    </div>
    <div id="center">
      <h1 id="heading">My Page</h1>
    </div>
    <div id="right">      
      <a class="accountlink" href="login.html">Account </a>
    </div>
  </header>

Answer №2

To achieve the desired outcome, you will need to make four modifications in your CSS code: two in the .navigationicon class and two in the .accountlink class.

.accountlink {
  font-family: "Helvetica";
  text-decoration: none;
  font-weight: 800;
  color: #ffffff;
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  background-color: red;
  position: absolute;
  right: 80px;
  top: 70px;
}

.navigationicon {
  position: relative;
  width: 12px;
  margin: 0;
  padding: 0;
  top: 50%;
  bottom: 50%;
}

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

PhantomJS in Python Selenium fails to retrieve source code after element click

View the code here import webdriver from selenium driver = webdriver.PhantomJS() driver.get("http://www.metasozluk.com/?r=girdi/goster&g=298794") driver.page_source # The result is a full HTML page. driver.find_element_by_css_selector(".entry-list-c ...

The element div is not permitted as a child of the element h5 in this particular scenario

My code snippet is as follows: $compile .= "<h5 data-count='".$acctemmpi. "' class='shortcode_accordion_item_title expanded_". $expanded_state . "'>" . $title . "<div class='ico'&g ...

`Is there a way to hide inline text on small screens using Boostrap 4?`

Within this specific scenario, my goal is to conceal the text when viewed on smaller screens and solely display the icon located to the left (an icon representing comments from font awesome): <a id="newCommentLink" href="#"> & ...

Transforming a sequence of characters into a multidimensional array

I have a nested for loop that generates an empty string value representing a multidimensional array. After the loops finish, the output looks like this: "[[0,0,0,0],[0,0,0,0]]" Now, I want to insert this into a multidimensional array within my code. How ...

Create movement for an object when it is clicked and when the mouse cursor enters or leaves the object, as well as other

I am struggling with the layout of my webpage, which consists of 3 main div elements. https://jsfiddle.net/wpztofb7/ <body> <div id="topBox" class="otherBox"> TEST TOP </div> <div id="middleBox" class="middleBox"> ...

Working with JavaScript Arrays within a JSON file data

I am currently learning React and attempting to display random images from the Picsum website using their API. The JSON file I receive contains various information, but I am specifically interested in extracting the image URLs. Although it appears that my ...

How can I implement a dynamic sidebar drawer in Bootstrap for my navbar?

Is it possible to achieve a layout similar to this example: I've come across some online examples using different versions of bootstrap, but they tend to alter the css too much, making it harder to grasp the concepts of bootstrap. I am curious if it ...

Material-UI Grid in Full Width Mode is malfunctioning

I've been delving into the Material-UI@next grid layout system to grasp its intricacies. What I'm aiming for is to have two papers that stretch across the entire width of the screen and collapse into one paper when the screen size shrinks. The d ...

Additional room on the right-hand side

I've been working on my website, www.ribbonhill.co.uk, and I'm facing an issue with a white space on the right side that only appears on mobile phones. Interestingly, this problem doesn't show up in full mode on Chrome and Edge browsers. Ho ...

Remove a error notification rather than appending it using javascript

Within this HTML form, I aim to notify the user that they must input a level into the text box. If the user clicks the button again, I want to erase the error message and display it once more. Moreover, I intend to include additional error messages; howeve ...

Ways to eliminate the gap between the currency symbol and the numerical value in HTML

Is there a way to eliminate the gap between the Currency Symbol and Amount? I've been attempting to get rid of the space between the currency symbol and the amount in my HTML code. However, even when I input decimals, there remains a gap between the ...

What could be causing Line Clamp to fail when using text alignment justify?

How can I get proper ellipsis to show with -webkit-line-clamp when using text-align:justify? It's functioning correctly with text-align:left/right. Does anyone have any suggestions or tricks? div { text-align: justify; width:150px; pad ...

Older browser compatibility for Flexbox flex-flow alternative

<template> <div> <h2>Kanal Listesi</h2> <div class="container"> <div v-for="(channel,index) in channels" :key="index"> <div v-if="channel.ChName"> <img :src="'h ...

Utilizing CSS for showcasing XSTL table

I've hit a roadblock with my initial XML project and I need some help. My goal is to create an address book using an XML file containing contact data, which is then transformed in XSLT. While both the XML and XSLT files function correctly, I encounter ...

Tips for sending every individual string object within an array as post data via ajax

I have a scenario where I am dealing with dynamically generated text boxes. Each value from these text boxes needs to be stored in a JSON array when submitted. The approach I took was to push all the values into an array and upon submission, these values a ...

Trigger animation once you've scrolled past a designated point in the document

I created a count-up counter animation using JavaScript, but the issue is that the counter starts animating as soon as I refresh the page regardless of where I am on the page or if the counter is even visible. I would like the counter to only start workin ...

Assigning a value to data-ng-model in JavaScript

I am facing a challenge in setting the data-ng-model attribute of an HTML input field using JavaScript. I have attempted to do it like this: element.data-ng-model = "..."; However, I realized that it doesn't work due to the presence of dashes. So, I ...

How can I import HTML code containing JS from an external source in just one line of code?

I am looking to add external functionality to my web page using a single line .js import that works similar to a plugin. Here is what I currently have: <!--index.html--> <head> </head> <body> <!-- Here is the one-line scrip ...

What might be causing my website to appear differently on mobile devices?

I am currently using a MacBook with a display size of 15.4 inches (2880 x 1800). Below is a screenshot showing how each section of my homepage appears on my website. QUERY 1 How can I make my h3 text responsive on mobile devices? As shown in the screensh ...

Matching Two HTML Tables in Django Template is Imperative

Two dynamic tables have been created with calculated column widths. The width values are output both inside the cells and in the style attribute. Using 2 tables in this way allows for a layout where the top part appears locked while the bottom moves. Des ...