Solve the IMG gap problem in the DIV

Source: Internet
Author: User


 

What should I do if there is a gap between the image IMG and the container's bottom boundary? Here is a simple solution in step 3. First, label the image IMG with display: block. IMG {display: block} 2. Define the font size in the container as 0. Div { Width: 110px; Border: 1px solid #000000; Font-size: 0 } Third, define the image IMG label vertical-align: Bottom, vertical-align: middle, vertical-align: Top IMG {vertical-align: Bottom} In addition, you can set the bottom margin of an image to a negative value and rewrite the HTML Tag arrangement. I think the first three methods can be completely solved. The reason why there is a gap between the image and the container in IE I searched the internet and found what old9 said. By default, inline elements such as image text are aligned with the baseline of the parent element, while baseline has a certain distance (this distance is related to font-size and font-family, not necessarily 5px), so setting vertical-align: ToP/bottom/Text-top/Text-bottom can avoid this situation. Besides Li, other block elements include IMG. As for the HTML attribute align = "center" (the image browser will process it as align = "Middle"), it is equivalent to vertical-align: middle; so the same is true, as long as vertical-align does not take baseline, this gap disappears. Related Comments 1. There are several ways to display IE, which are declared at the beginning of the HTML document <! Doctype & hell; IP;.> If the statement is in strict mode, IE displays the document in W3C mode, and In W3C standards is an inline label by default, unless explicitly declared as a block 2. the gap is the default line-height and font-size for the box model of IE. to IMG desplay: block; although it can solve the problem, it does not take the structure into consideration. it can be regarded as a permanent cure

 

Solve the IMG gap problem in the DIV

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.