Solve the problem of blank gap at the bottom of Img picture

Solve the problem of blank gap at the bottom of Img picture

When working on a recent project, I found that there was always a blank space below when referencing pictures, as shown in the figure below.

<style>
    .img-box {
        border: 2px solid red;
        width: 550px;
    }
</style>

<div class="img-box">
    <img src="./img.png" alt="">
</div>

Later I found out that the reason is that the inline block elements will be aligned with the text baseline. To solve this problem is actually very simple, there are two main methods:

1. Add vertical-align: middle | top | bottom, etc. to the image. (Recommended)

img {
    vertical-align: bottom;
}

2. Convert the image to a block-level element display: block; (Converting block-level elements may affect your layout, so the first method is recommended)

g {
    display: block;
} 

Well, the problem is solved so simply.
If you have any better methods, please feel free to share and leave a message in the comment area.

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

<<:  Vue custom directive details

>>:  MySQL data table partitioning strategy and advantages and disadvantages analysis

Recommend

MySql sets the specified user database view query permissions

1. Create a new user: 1. Execute SQL statement to...

An article to solve the echarts map carousel highlight

Table of contents Preface toDoList just do it Pre...

InnoDB type MySql restore table structure and data

Prerequisite: Save the .frm and .ibd files that n...

12 types of component communications in Vue2

Table of contents 1. props 2..sync 3.v-model 4.re...

MySQL 8.0.12 installation steps and basic usage tutorial under Windows

This article shares the installation steps and us...

Do designers need to learn to code?

Often, after a web design is completed, the desig...

Vue directives v-html and v-text

Table of contents 1. v-text text rendering instru...

Detailed explanation of DIV+CSS naming rules can help achieve SEO optimization

1. CSS file naming conventions Suggestion: Use le...

Detailed explanation of Angular dynamic components

Table of contents Usage scenarios How to achieve ...

Classes in TypeScript

Table of contents 1. Overview 2. Define a simple ...

WeChat applet to determine whether the mobile phone number is legal example code

Table of contents Scenario Effect Code Summarize ...

Detailed description of the life cycle of React components

Table of contents 1. What is the life cycle 2. Lo...

How to configure eureka in docker

eureka: 1. Build a JDK image Start the eureka con...

JavaScript to implement simple carousel chart most complete code analysis (ES5)

This article shares the specific code for JavaScr...