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

Extracting text from an HTML file and passing it to an Express.js server: A beginner

Currently, I'm attempting to retrieve the values from an HTML text field and store them in variables. I require HTML to capture these values and return the response within the .html file. HTML: <body> <form> ...

Changing the Position of HTML Scripts in React

I am facing an issue where I need to relocate an external script within a specific section of my page. However, I am unable to access the CSS attributes associated with this item. It seems that it is displayed as an iFrame, making it difficult to modify th ...

Despite using twitter bootstrap, the elements on my webpage are still overlapping one another

While implementing Twitter Bootstrap on my website, I encountered a problem where elements start overlapping if the window size is reduced. This issue does not look appealing, and I expected Twitter Bootstrap to ensure that my website is fully responsive a ...

Centering items within grid columns for optimal alignment

I have successfully designed a contact form using a CSS grid layout that features 4 input fields and a submit button spanning across 2 columns. Two of the input fields take up 1fr of space each, while the remaining two are 1/3 wide. My challenge lies in c ...

Guide on displaying JSON information upon clicking using JavaScript

I'm having difficulty writing the logic for this code. I have extracted data from a vast API. The current code fetches all program titles (some may be repeated) and compares them with an array of late night shows, then displays them once in their own ...

Choosing jQuery over JQuery Mobile for a standard web application to effectively manage different devices

Creating a Unique Web Application In the works is a unique web application, similar to Trello, that divides a page into columns where tasks/cards can be added and moved between them. This desktop-focused platform will feature an information column on the ...

In search of a regular expression for identifying any of several classes

In the process of upgrading all my websites, I decided to redesign them so that all URL's default to lower case. This meant changing all image names and paths to lower case as well, which was accomplished using regexes. However, this action inadverten ...

Switching between div elements in ReactJS

I am currently working on a web application built with ReactJS. One feature that I would like to include is similar to the following: My query is as follows: What is this specific effect called? How can I go about implementing it? I am not looking for ...

Retrieve information from an external JSON file and present it in a table format - Obtain the most recent data available

I am attempting to extract the data from On the website, there is a dropdown menu that displays two different screenshots. I want to modify my code so that it shows the most recent screenshot data in a table. Here is my current code: http://jsfiddle.net ...

Tips for aligning the timing of two CSS animations

I'm struggling to achieve a synchronized CSS animation where a progress bar fills up and a background changes simultaneously. For example, I want the progress bar to fill in 5000ms, with the background image changing every 5000ms as well. Despite se ...

Learn how to incorporate a newly created page URL into a customized version of django-oscar

Just starting out with django-oscar and trying to set up a new view on the page. I've successfully created two pages using django-oscar dashboard, https://ibb.co/cM9r0v and added new buttons in the templates: Lib/site-packages/oscar/templates/osca ...

Spilling over into the adjacent DIV

<html> <head> <title>Pixafy</title> <style> html { background: url(wp.jpg) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; backgrou ...

display the table without providing a preview

Hey everyone, I am currently utilizing vue.js to develop a table and I am looking for a way to add a button that can print the data in the table without displaying a preview dialog. What modifications should I make to my javascript code in vue? Here is an ...

How to extract information from a shared notebook on Evernote using Python

Trying to retrieve data from a shared Evernote notebook, such as this one: Initially attempted using Beautiful Soup: url = 'https://www.evernote.com/pub/missrspink/evernoteexamples#st=p&n=56b67555-158e-4d10-96e2-3b2c57ee372c' r = requests.g ...

Looking to create a centered 'ul' using Bootstrap

I am looking to center the list with a specific width. body { background-color: rgb(26, 40, 114); } h1 { color: white; text-shadow: 7px 7px 10px black; } li { list-style: none; border-radius: 5px; border: 2px solid white; background-colo ...

Toggle nested menu within another submenu

Looking for help with toggling menu items? I currently have a menu setup with 3 icons where clicking on an icon opens the dropdown-mobile UL under it. The goal is to toggle different submenu items when 'Main menu item' or 'sub-menu item&apos ...

Moving the sidebar from the app component to a separate component in Angular results in a situation where the sidebar does not maintain full height when the page is scrolled down

Within my Angular application, I have implemented a sidebar as a separate component. Previously, the content of the sidebar was housed within the main app component's HTML page, and it functioned properly by taking up the full height of the page when ...

Use PHP to highlight the row that has been selected in an HTML table

I am currently working on a project where I have styled multiple HTML tables on my website using alternating gray and white bands. Now, my goal is to highlight the selected row in a darker shade of gray. I have experimented with various solutions, and the ...

Ways to extract metadata from a given URL

Recently, I've delved into the world of JavaScript and I'm looking to extract metadata from a given URL. Whenever a URL is entered into an input field, I want to retrieve its meta data - a simple task in HTML using JavaScript. However, every time ...

Utilizing Jquery to Add Elements and Adjust Element Height

Encountering an unusual issue where the height of a div is not updating when content is appended to it using JQuery. To demonstrate the problem, I have created a simple JSFiddle: http://jsfiddle.net/hf66v/5/ Here is the initial HTML structure: <div i ...