Inline-block compatibility

Source: Internet
Author: User

If an element is set to Display:inline-block, then this element will behave as a property of the inline block. Elements that are set as inline blocks

The inner (child element) is represented as a block-level box, in which the height width can be set, vertical margin and padding can be set, etc. on sibling elements

is displayed in the inline box, in which the adjacent inline block can be shown on the same line, with the characteristics of the inline element, which can appear between the box and the box

Blank, resulting in a blank way to make "whitespace characters, tabs, newline characters".

A simple way to eliminate whitespace between blocks in rows is to set properties on the containing block of a block within a row:

  

. wrapper{font-size:0;*word-spacing: -1px;}

Font-size is set to 0, which allows the size of these whitespace characters to be 0, which is not displayed. However, there are 1px intervals under ie6,7, which can be

Set word-spacing to fix.

However, for Safari, the font size of 0 is not supported, so additional corrections are required:

@media screen and (-webkit-min-device-pixel-ratio:0) {            . wrapper {                letter-spacing: -4px;/* Fix safari */            }        }

In addition, ie6,7 does not have a Inline-block attribute, but can be simulated by triggering haslayout on inline elements.

In summary, the implementation of the method of correcting whitespace between block elements in rows:

        @media screen and (-webkit-min-device-pixel-ratio:0) {            . wrapper {                letter-spacing: -4px;/* Safari, etc. does not support browse with font size 0 To adjust the */}} According to the parent font        . wrapper{font-size:0;*word-spacing: -1px;}        . il{border:1px Solid #000000;d Isplay:inline-block;word-spacing:normal;letter-spacing:normal;*display:inline;*zoom : 1;width:80px;height:100px;background: #cecece; font-size:14px;vertical-align:top;}        . bl{border:1px solid #000000; Width:80px;height:100px;word-spacing:normal;letter-spacing:normal;background: #d0e9c6 ;d isplay:inline-block;*display:inline;*zoom:1;font-size:14px;vertical-align:top;}        img{border:1px solid #000000;}            

<div class= "wrapper" >
<span class= "Il" >inline-block 1</span>
<span class= "Il" >inline-block 2</span>
<span class= "Il" >inline-block 3</span>
<div class= "BL" >block 1</div>
<div class= "BL" >block 2</div>
<div class= "BL" >block 3</div>


</div>

  

Inline-block compatibility

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.