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

28 Famous Blog Redesign Examples

1. WebDesignerWall 2. Veerle's Blog 3. Tutori...

Analysis on the problem of data loss caused by forced refresh of vuex

vuex-persistedstate Core principle: store all vue...

What you need to know about creating MySQL indexes

Table of contents Preface: 1. Create index method...

Detailed explanation of the wonderful uses of SUID, SGID and SBIT in Linux

Preface Linux's file permission management is...

Several methods to execute sql files under mysql command line

Table of contents The first method: When the MySQ...

Front-end JavaScript Promise

Table of contents 1. What is Promise 2. Basic usa...

How to block IP and IP range in Nginx

Written in front Nginx is not just a reverse prox...

Records of using ssh commands on Windows 8

1. Open the virtual machine and git bash window a...

Implementation of CSS child element selection parent element

Usually a CSS selector selects from top to bottom...

Detailed explanation of Vue's sync modifier

Table of contents 1. Instructions 2. Modifiers 3....

How to stop CSS animation midway and maintain the posture

Preface I once encountered a difficult problem. I...