Mysterious area located within a flexbox set to display items in a column arrangement

There is a mysterious gap within a flexbox that has a column direction.

In the header-left div, I have set up a flexbox with a column direction. It consists of three nested divs: left_text_heading, hero-img, and hero-text. Strangely, there is an unknown space between the hero-img and hero-text elements despite no margin or padding being applied to them. Click here to see the red area where this space exists.

*{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body{
    background: #091A29;
    font-family: 'DM Sans', sans-serif;
    font-style: normal;
    font-weight: 400;
    font-size: 20px;
    line-height: 30px;
    color: #fff;
}

.container{
    margin-left: 80px;
}

.header{
    width: 100%;
    display: flex;
}

.header-left{
    display: flex;
    flex-direction: column;
    width: 584px;
    margin-top: 38px;
}

.nav{
    display: flex;
    align-items: center;
    margin-bottom: 25px;
}

.nav>ul{
    display: flex;
    list-style: none;
    gap: 68px;
}

.nav>ul>li>a{
    text-decoration: none;
    color: #193A58;
}

.left_text_heading{
    display: flex;
    align-items: center;
    justify-content: flex-start;
    height: 366px;
    margin-top: 25px;
    font-weight: bold;
}

.left_text_heading > h1{
    position: relative;
    font-size: 500px;
    left: -35px;
    color: #183a58;
}

.hero-img{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 144px;
    position: relative;
    bottom: 75px;
}

.hero-text{
    width: 550px;
    display: flex;
    flex-direction: column;
}

.hero-text>p{
    font-weight: 400;
    font-size: 50px;
    line-height: 65px;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PortFolio</title>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div class="container">
        <div class="header">
            <div class="header-left">
                <div class="nav">
                    <ul>
                        <li><a href="#">Home</a></li>
                        <li><a href="#">About me</a></li>
                        <li><a href="#">Product</a></li>
                        <li><a href="#">Contact</a></li>
                    </ul>
                </div>
                <div class="left_text_heading">
                    <h1>HI</h1>
                </div>
                <div class="hero-img">
                    <img src="./images/person.svg" alt="person">
                </div>
                <div class="hero-text">
                    <p>My name is Shallom, I am a product designer</p>
                </div>
            </div>
            <div class="header-right"></div>
        </div>
    </div>
</body>
</html>

Answer №1

The extra spacing is a result of the descender height in the h1 element's font.

To eliminate this space, you can set a negative value for the margin-bottom property. Make sure to adjust the bottom property of the image accordingly.

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
  background: #091A29;
  font-family: 'DM Sans', sans-serif;
  font-style: normal;
  font-weight: 400;
  font-size: 20px;
  line-height: 30px;
  color: #fff;
}

.container {
  margin-left: 80px;
}

.header {
  width: 100%;
  display: flex;
}

.header-left {
  display: flex;
  flex-direction: column;
  width: 584px;
  margin-top: 38px;
}

.nav {
  display: flex;
  align-items: center;
  margin-bottom: 25px;
}

.nav > ul {
  display: flex;
  list-style: none;
  gap: 68px;
}

.nav > ul > li > a {
  text-decoration: none;
  color: #193A58;
}

.left_text_heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  height: 366px;
  margin-top: 25px;
  font-weight: bold;
}

.left_text_heading > h1 {
  position: relative;
  font-size: 500px;
  left: -35px;
  color: #183a58;
  margin-bottom: -0.5em;
}

.hero-img {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 144px;
  position: relative;
  bottom: 0;
}

.hero-img img {
  border-radius: 50%;
}

.hero-text {
  width: 550px;
  display: flex;
  flex-direction: column;
}

.hero-text > p {
  font-weight: 400;
  font-size: 50px;
  line-height: 65px;
}
<div class="container">
  <div class="header">
    <div class="header-left">
      <div class="nav">
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About me</a></li>
          <li><a href="#">Product</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </div>
      <div class="left_text_heading">
        <h1>HI</h1>
      </div>
      <div class="hero-img">
        <img src="https://randomuser.me/api/portraits/men/5.jpg" alt="person">
      </div>
      <div class="hero-text">
        <p>My name is Shallom, I am a product designer</p>
      </div>
    </div>
    <div class="header-right"></div>
  </div>
</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

How can you employ moment.js to display the most recent update time of mongoDB/mongoose?

I am facing an issue with displaying the last date/time when any entry in my table was edited and updated using moment.js. It seems to be updating the date/time in real-time rather than only showing when a database entry was modified. How can I ensure tha ...

Strange Behavior When Floating Right in Chrome

There's a strange issue that I'm facing, only in Chrome. It seems to be adding some extra space on top of an element with float: right, but only when the browser window is resized (you can see how the name then shifts under the header): This pro ...

How can I prevent StateHasChanged() from affecting all open browsers in a Blazor Server-Side application?

Hey there, I'm new to Blazor but familiar with C#. This is my first time asking a question here so please bear with me. :) I am working on a Blazor server-side application where users can enter information and validate it based on server data. So far ...

Functionality problem with adjusting font size in jQuery date picker

Recently, I integrated jQuery and datapicker features into my ASP .NET MVC 3 (Razor) project and noticed that the font size of the datapicker is exorbitantly large. Does anyone have any suggestions on how to adjust this issue? Your help would be greatly ...

Issue with directive not activating when attribute is changed

I am facing an issue with my website where users can make selections from two dropdowns, and based on those values, attributes are sent to directives for a corresponding function to be called. The problem I'm encountering is that the directives are n ...

Increase the size of the Iframe tag to a larger scale

Can someone help me figure out how to make my iframe content fill the entire screen? Any assistance would be greatly appreciated. Photos: Current Output: Desired Output <!DOCTYPE html> <html lang="en"> ...

What is the reason behind the fact that the "transform" property of document.getElementById().style.transform="translateX()" only translates the element once?

I'm currently in the process of developing a new online game. With just a simple click of a button, my goal is to have the red square move horizontally by 50 pixels. Here's a snippet of the HTML code: <!DOCTYPE html> <html> <hea ...

Using @font-face to include several files for different font-weight variations

I have a collection of font files that I want to assign to specific font weights. @font-face { font-family: "custom-font"; src: url("font300.eot"); src: url("font300.eot?#iefix") format("embedded-opentype"), url("font300.woff2") format ...

The height of the <div> element is not increasing along with the content inside. If I set the height to "auto

I encountered an issue with my webpage design. It has set dimensions with blue borders on the sides and bottom. The problem arises when I add Facebook comments to the page - as more comments are added, they extend beyond the bottom of the webpage, below ...

CSS for decorating an image with a border and transparent background

Struggling to add a border while converting a PSD to HTML? Is it possible to apply a border to an image with a transparent background? For instance, let's consider the following image: Imagine wanting to place a border around the caret in the image l ...

Can adjusting the viewport by using touch controls alter the size of the viewing screen?

When I tried to zoom in on a webpage using touch instead of the keyboard shortcut Ctrl +, I noticed that the elements stayed the same size but the screen itself was enlarged. It seems like this method does not affect the size of the viewport. However, whe ...

"Learn the process of connecting an HTML5 element to Angular 2 source code while in a saving mode

In this Angular2 implementation, I have created some HTML code for user access. However, I am facing an issue where the data is not binding at the Angular2 source code side. HTML Code <form class="form-horizontal" novalidate [formGroup]="EmployeeForm" ...

Seeking a material design template for mandatory form patterns

I'm struggling with getting my required field patterns to work using regular expressions. Additionally, I'd like to center my 'onboard' button on the page. You can find my code at this StackBlitz link: https://stackblitz.com/edit/angula ...

Why do identical elements show different scrollHeights when overflowed and how can this discrepancy be resolved?

I am using a plugin that generates a <p> element and continuously fills it with the content from a <textarea>. This plugin positions the <p> directly below the <textarea>, and styles them so that they appear identical in terms of th ...

How to make a letter stretch all the way down the paper?

As I'm creating a table of contents for my website, I was inspired by an interesting design idea that I came across: I am particularly drawn to how the T extends down and each section is numbered with the title wrapped around it. How can I achieve th ...

Creating a mouse hover effect for irregular shapes on an image map

Is it possible to implement a mouse hover effect on irregular shapes within an image map? These irregular shapes are not basic polygons like rectangles, triangles, or circles, but rather complex designs such as lanterns or animals. Can this be achieved? ...

Exploring High-Density Mobile Devices with Bootstrap 3 Landscape Mode

After completing my first Bootstrap site using version 3, I noticed a display issue when viewing it on an iPhone 5 or LG G2 in landscape mode due to the pixel density. This was not a problem with the Responsive Grid system I previously used. Although I sp ...

The route seems to be downloading the page instead of properly rendering it for display

I'm facing a simple issue with my Express page - when I navigate to the FAQ route, instead of displaying the page it downloads it. The index page loads fine, and the FAQ page is the only other page available at the moment. I am using EJS templating, a ...

Adjusting the text color based on the dynamically set background color

If I have a calendar where each entry has a unique background color assigned to it (one color per user), including both light and dark colors that users can choose from, how can I set the text color to match the background style? Where should I begin wit ...

Guide on generating a child element in a React application using server response

I have developed a react application with multiple nested routes. One of the nested routes utilizes a backend API that returns complete HTML content. My goal is to display this HTML content with the same styling in my UI without directly manipulating the ...