Issue with spacing between rows of inline-block elements and adjacent rows

Just to clarify, this is not a table. I used "row" as a placeholder term.

My issue involves a set of inline-block elements with a gap below them when compared to another element on the page. This is different from the space between the inline elements themselves. I attempted a solution mentioned here, adjusting the line-height and font-size properties, but it didn't resolve the problem (which explains why it's not included in the code below)

Below is my code:

HTML

    <div id="letterhead">
        <div class="name"></div><div class="logo"></div><div class="name"></div>
        <div class="subtext"></div>
    </div>

CSS

body{
    background:#eee;
    width: 100%;
}
#letterhead {
    position: absolute;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    width: 100%;
    height: 12rem;
    font: 32px Tahoma;
    color: #777;
    padding: 2rem;
}
    .logo {
        display: inline-block;
        width: 7rem;
        height: 7rem;
        background: #000;
    }
    .name {
        display: inline-block;
        height: 7rem;
        width: calc((100% - 7rem) / 2);
        background: #fff;
    }
    .subtext {
        //position: absolute;
        margin: 0;
        padding: 0;
        top: 9rem;
        text-align: center;
        width: 100%;
        height: 1rem;
        background: #555;
    } 

I created a Fiddle here.

Appreciate any assistance you can provide.

Answer №1

The issue lies with the font-size and line-height settings in your CSS on #letterhead. To remove the excess white-space, simply set these values to 0. Remember to adjust the font-size and line-height for the children elements of #letterhead if you plan on adding content there.

For example: http://jsfiddle.net/skeurentjes/69MkQ/1/

Answer №2

Simply include margin:0 -4px 0 0 in your inline-block elements to solve the spacing issue between them. Additionally, to eliminate space between rows, remember to set vertical-align: top. Take a look at the DEMO for reference.

CSS Style:

.logo {
        ...
        display: inline-block;
        margin: 0 -4px 0 0;
        vertical-align: top;
        ...
    }
    .name {
        ...
        display: inline-block;
        margin: 0 -4px 0 0;
        vertical-align: top;
        ...     
    }

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 I incorporate classes from multiple CSS files into my WordPress theme?

Currently, I am utilizing wp_enqueue_style to incorporate two CSS files within a single function. However, the issue that arises is when I try to apply a class, it seems that only classes from one of the files can be utilized and it ends up overriding anot ...

Develop a unique card design using HTML and CSS

I am attempting to recreate a card design similar to the one shown in the image, but I am struggling to identify the name on the right side. Even though it is supposed to be clear, I always rely on the image as a reference. https://i.sstatic.net/hDh22.png ...

Tips for displaying just the image name without the entire image file path

When I try to upload an image, the path displayed is "C:\fakepath\promotion1.JPG". This fake path is causing the image not to upload to my project media folder. How can I solve this issue? Instead of the complete path, I only want to capture the ...

Using Mat-Error for Two Way Binding leads to frequent triggering of ngModelChange事件

I am working with a mat input field that has two-way data binding using ngModel, and I want to add validation using mat-error and formControl. <mat-form-field [formGroup]="myForm"> <input matInput formControlName="myFormName" autocomplete="off" ...

reCAPTCHA failing to prevent users from accessing their accounts

I recently implemented Google reCAPTCHA on my login form to combat spam. Despite following all the necessary steps to set it up, users are still able to log in without checking the checkbox, which is not ideal. My initial thought was that the issue might ...

The code is malfunctioning on this site (yet functions perfectly on a different website)

So I have a question that may seem silly, but it's worth asking. I'm attempting to create a sticky div element that stays in place when you scroll past a certain point on the page. This is the script I have: <script type="text/javascript"> ...

Is there a way to reduce the height of the border-left property in CSS?

In creating a simple address panel, I have divided it into three sections: address, phone number, and email. Each section includes an icon and a paragraph next to it. To align these sections side by side, I used the vertical-align: top and display: table p ...

What are some effective techniques for personalizing Bootstrap?

Recently, I have found myself facing numerous challenges with Bootstrap. Although I used it to create a website in the past, I haven't touched it since. However, circumstances have now led me to incorporate it into my current project. I have downloade ...

Deactivate the signup button automatically when the user is not present, without the need to refresh

To determine user availability, the system will check the table of users. If the user is available, the signup button will be displayed; otherwise, the button will remain disabled or its color may change. ...

Utilizing a Custom Validator to Compare Two Values in a Dynamic FormArray in Angular 7

Within the "additionalForm" group, there is a formArray named "validations" that dynamically binds values to the validtionsField array. The validtionsField array contains three objects with two values that need to be compared: Min-length and Max-Length. F ...

Setting the height of a Bootstrap radio button

My Bootstrap radio buttons are set to a width of 200px. However, when the text inside the button exceeds this width, it wraps onto two lines leading to changes in button height. How can I ensure that all other buttons displayed scale to the same height? h ...

What is the best way to center the dialogue on a GMap embed?

After embedding a Google Map using the Google Map Embed feature, I noticed that the info dialogue is not centered by default. You can see an example of this here. I came across another website where the dialogue is centered on the screen by default. You ...

Ensure that the initial section of the page spans the full height of the browser, while all subsequent sections have a

I have a website composed of various blocks with different heights, all extending to full width. My goal is to make the first block the full height and width of the browser window, while keeping the other blocks at a set height as seen on this site: After ...

How can you trigger a modal to appear when an image is clicked?

There are images inside <div> tags. When one of the images is clicked, a modal appears to display information about the specific image. Each modal has a unique id or class, such as modal4. My example: <image type="image" src="Images/Drake.jpg" ...

The animation for the Bootstrap modal is not functioning correctly

Whenever I click the button to open the modal window, it just pops up without any animation or fade effect. I attempted to add classes like .fade and .modal-fade to the modal, but nothing changed. You can see it in action on my test page. Simply click th ...

Saving JSON data into an HTML element using Handlebars templating

Is there a way to save the entire JSON object within an HTML element as a data attribute? let a = {name : "sample", age : "34"} $.find('#someDiv').data('adata', a); Is it possible to achieve the same result using Handlebars when creat ...

Ways to customize the default CSS styles of angularJS for elements like search box and more

Looking for a way to customize the appearance of an AngularJs search box? <div ng-controller="PersonListCtrl"> <div class="bar">Search: <input ng-model="query"> </div> <ul cl ...

Guide on incorporating foreign keys into conditional statements in Django HTML pages

Can anyone tell me why this condition isn't working? In the h4 tag, "Receita" is being displayed for lancamento.tipo, but the condition is not being met. Any help would be greatly appreciated. lancamento_list.html <div class="list-group&q ...

Certain tags may not be properly interpreted when using the read_html function

After using read_html to scrape data from a Korean portal site focused on the stock trading market, I encountered a peculiar issue. Upon examining the webpage elements, I found a table along with tags such as tbody, tr, td, and a nested underneath. However ...

Leveraging jQuery chosen for interactive form elements

This Table Row contains 5 input fields, with the first being a select box. I am utilizing the chosen jQuery plugin to enable search functionality for the select items. Since this is a dynamic form, I am duplicating these rows. However, I am facing an issu ...