Detailed explanation of how to clear a few pixels of blank space under an image using CSS

Detailed explanation of how to clear a few pixels of blank space under an image using CSS

Recently, a friend asked me a question:

When layout the page, I found that there is a 1-2 pixel blank space under the picture. How can I remove it?

This is a browser design issue. img is originally an inline element, but it can use width and height. When the parent element does not set the height, problems such as 3px gap will appear when the height calculated by the height of the child elements is given to the parent element.

Method 1 to remove the gap under the image

img{display:block;}

Method 2

img{vertical-align:top;}

In addition to the top value, you can also set it to text-top | middle | bottom | text-bottom, or even specific <length> and <percentage> values.

Method 3

#qdxw{font-size:0;line-height:0;}

#qdxw is the parent element of img

Summarize

This concludes this article on how to use CSS to clear a few pixels of blank space under images. For more information on how to use CSS to clear a few pixels of blank space under images, please search previous articles on 123WORDPRESS.COM or continue browsing the related articles below. We hope that you will support 123WORDPRESS.COM in the future!

<<:  In-depth understanding of Mysql transaction isolation level and locking mechanism issues

>>:  Detailed explanation of HTML programming tags and document structure

Recommend

The unreasonable MaxIdleConns of MySQL will cause short connections

1 Background Recently, some performance issues ha...

MySQL uses find_in_set() function to implement where in() order sorting

This article introduces a tutorial about how to u...

Vue3 AST parser-source code analysis

Table of contents 1. Generate AST abstract syntax...

Docker modifies the configuration information of an unstarted container

When I first used docker, I didn't use docker...

Summary of how to modify the root password in MySQL 5.7 and MySQL 8.0

MySQL 5.7 version: Method 1: Use the SET PASSWORD...

Implement full screen and monitor exit full screen in Vue

Table of contents Preface: Implementation steps: ...

How to prevent duplicate submission in jquery project

In new projects, axios can prevent duplicate subm...

Introduction to installing and configuring JDK under CentOS system

Table of contents Preface Check and uninstall Ope...

Vue advanced usage tutorial dynamic components

Table of contents Basic description AST parsing R...

Solution to blank page after Vue packaging

1. Solution to the problem that the page is blank...

JavaScript canvas realizes colorful sun halo effect

This article example shares the specific code of ...