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

MySQL 8.0.22 winx64 installation and configuration method graphic tutorial

The database installation tutorial of MySQL-8.0.2...

How to shut down/restart/start nginx

closure service nginx stop systemctl stop nginx s...

Detailed tutorial on installing MySQL database on Alibaba Cloud Server

Table of contents Preface 1. Uninstall MySQL 2. I...

Introduction to the use of base link tag base

<br />When you click the link, the web page ...

Small paging design

Let our users choose whether to move forward or ba...

How to install FastDFS in Docker

Pull the image docker pull season/fastdfs:1.2 Sta...

Basic knowledge of MySQL database

Table of contents 1. Understanding Databases 1.1 ...

A brief discussion on VUE uni-app template syntax

1.v-bind (abbreviation:) To use data variables de...

CSS scroll bar style modification code

CSS scroll bar style modification code .scroll::-...

A brief discussion on JavaScript scope

Table of contents 1. Scope 1. Global scope 2. Loc...

Example of how to build a Mysql cluster with docker

Docker basic instructions: Update Packages yum -y...

Detailed process of Vue front-end packaging

Table of contents 1. Add packaging command 2. Run...

A useful mobile scrolling plugin BetterScroll

Table of contents Make scrolling smoother BetterS...