The image element img has extra blank space in IE6

The image element img has extra blank space in IE6

When doing DIV+CSS layout of the page, it is very common to encounter the problem of extra space under the image element img in IE6 (of course, it sometimes happens in Firefox). The solution to this problem is to "act according to the situation". Different solutions should be used according to different causes. Here are the common methods to solve the BUG of extra space under the image layout for your reference.
1. Convert the image into a block-level object
That is, set img to: display:block;
In this example, add a set of CSS code: #sub img {display:block;}
2. Set the vertical alignment of the image
That is, setting the vertical-align property of the image to "top, text-top, bottom, text-bottom" can also solve the problem. For example, add a set of CSS codes in this example: #sub img {vertical-align:top;}
3. Set the text size of the parent object to 0px
That is, add a line in #sub: font-size:0;
can solve the problem. But this also caused a new problem, the text in the parent object could not be displayed. Even if part of the text is enclosed by child objects, you can still display it by setting the child object text size, but when validating the CSS, an error message indicating that the text is too small will be displayed.
4. Change the properties of the parent object
If the width and height of the parent object are fixed, and the image size depends on the parent object, you can set overflow:hidden;
to solve. For example, you can add the following code to #sub: width:88px;height:31px;overflow:hidden;
5. Set the floating properties of the image
That is, add a line of CSS code in this example: #sub img {float:left;}
If you want to achieve mixed text and graphics, this method is a good choice.
This method should be emphasized. In actual development, this method may cause problems. Because when writing code, in order to make the code more semantic and hierarchical, it is inevitable to use the IDE to provide code indentation display, which will inevitably cause labels and other labels to be displayed in new lines, such as DW's "Apply Source Formatting" command. Therefore, this method can help us understand a situation in which a BUG occurs, but the specific solution depends on your own experience.

<<:  JavaScript pre-analysis, object details

>>:  How to package the project into docker through idea

Recommend

Configure nginx to redirect to the system maintenance page

Last weekend, a brother project was preparing to ...

Detailed explanation of Vue's custom event content distribution

1. This is a bit complicated to understand, I hop...

How to enable TLS and CA authentication in Docker

Table of contents 1. Generate a certificate 2. En...

Issues with Rancher deployment and importing K8S clusters

Rancher deployment can have three architectures: ...

Detailed explanation of two points to note in vue3: setup

Table of contents In vue2 In vue3 Notes on setup ...

How to introduce scss into react project

First download the dependencies yarn add sass-loa...

MySQL 5.7.13 installation and configuration method graphic tutorial on Mac

MySQL 5.7.13 installation tutorial for Mac, very ...

Nginx signal control

Introduction to Nginx Nginx is a high-performance...

Use Docker Compose to quickly deploy ELK (tested and effective)

Table of contents 1. Overview 1.1 Definition 1.2 ...

Native JS to implement real-time clock

Share a real-time clock effect implemented with n...

React's reconciliation algorithm Diffing algorithm strategy detailed explanation

Table of contents Algorithmic Strategy Single-nod...

JavaScript implementation of the back to top button example

This article shares the specific code for JavaScr...

VScode Remote SSH remote editing and debugging code

The latest Insider version of Visual Studio Code ...