Inline-block the problem of producing blank gap

Source: Internet
Author: User

A blank gap was encountered in the project to set the Display:inline-block property

Such as:

#wrapper {    border: 1px solid blue;} #wrapper Div {    width: 100px;     height:100px;     display:inline-block;     background: #eee;}
<DivID= "wrapper">    <Div>Div1</Div>    <Div>Div2</Div>    <Div>Div2</Div></Div>

Workaround: Set the font-size:0 for the parent container; The Display:inlie-block element needs to display the font and add extra.

Reason:

In fact, this problem is caused by our habit of writing code. Usually we write code, in order to make the code appear "hierarchical", usually after the end of the tag to hit a carriage return, and the carriage return will produce a carriage return, the carriage return is equivalent to a blank character, usually, multiple consecutive white space characters will be merged into a blank character, and create a "blank gap" The real reason for this is that we don't pay much attention to the whitespace.

Now that we know the cause of the problem, it's a good idea to solve the problem. Whitespace is also a character, as long as the character will be associated with the font, font size and so on. So the removal of whitespace characters only need to set the font size to zero on the line (font-size:0;)

Inline-block the problem of producing blank gap

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.