Display:inline-block in CSS, GAP resolution

Source: Internet
Author: User

When the label uses Display:inline-block, the object is presented as an inline object, but the object's contents are presented as a block object. Adjacent inline objects are presented in the same line, allowing spaces. (To be exact, the element to which this attribute is applied renders as an inline object and the surrounding elements remain on the same line, but you can set the properties of the width and height plot elements)

With inline-block horizontally rendered elements, there will be spacing between line-wrapping or space-separated, a simple example:

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>Document</title>
<style>
UL Li {
List-style:none;
}
UL Li Span {
Display:inline-block;
width:40px;
height:20px;
Background:pink;
}
</style>
<body>
<ul>
<li>
<span>1</span>
<span>2</span>
</li>
</ul>
</body>

The effect of the page rendering is as shown in the following illustration:

Picture 1

Two elements between the space, and browser, the size of the space resolution is also different, which is to restore the effect of the picture to a certain extent, how to solve it

First, use a folded line annotation, as shown in the following figure

Second, do not fold lines or leave blank (code is not very readable), as shown in the following figure

Three, the previous end tag and the next closing label are placed on one line (no spaces left), as shown in the following figure

Four, the use of margin-right or margin-left negative values, has been achieved to eliminate whitespace, as shown in the following figure

Five, use JS to write HTML + as shown in the following figure

Use font-size:0 using the parent element; As shown in the following figure

Seven, use float float, as shown in the following figure

Viii. use position to position each label individually (too troublesome, not recommended)

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.