CSS about the solution to the image elements of the extra blank Space bug

Source: Internet
Author: User
In the div+css layout of the page, it is very common to encounter the problem of extra blank in the picture element of the browser under IMG. The solution to this problem is also "play by ear", according to the different reasons for different solutions, here to solve the image of the solution directly below the layout of the redundant gaps in the common method of induction, for your reference.
1. Convert a picture to a block-level object
That is, set img as "Display:block;" In this example, add a set of CSS code: "#sub img {display:block;}".
2, set the vertical alignment of the picture
That is, setting the picture's Vertical-align property to "Top,text-top,bottom,text-bottom" can also be resolved. As in this example, add a set of CSS code: "#sub img {vertical-align:top;}".
3, set the text size of the parent object is 0px
That is, add a row to the #sub: "font-size:0;" can solve the problem. However, this raises a new problem, and the text in the parent object cannot be displayed. Even if the text part of the quilt, set child object text size can still be displayed, but in the CSS when the time will prompt text too small error.
4, change the properties of the parent object
If the parent object is wide and high fixed and the picture size depends on the parent object, you can set the Overflow:hidden. To solve. In this example, you can add the following code to the #sub: "Width:88px;height:31px;overflow:hidden;".
5, set the picture's floating properties
In this case, add a line of CSS code: "#sub img {float:left;}". This approach is a good choice if you want to implement a graphic mix.
6. Remove the space between the label of the picture and the last ending tag of its parent object
This method should be emphasized, in practice, this approach can be a mess, because in writing code in order to make the code more semantic and hierarchical clarity, it is inevitable to provide the code through the IDE indentation display, which will make the label and other labels, such as the "Apply source format" command of the DW.
Related Article

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.