HTML span label setting width not effective solution

Source: Internet
Author: User

Problem: When you set a sibling tag, the Width property does not work, and it automatically varies according to the content it contains.

Reason:

For inline elements (which can be inline by default, such as span elements, or display:inline elements)

Width and height only trigger haslayout under ie5.x and IE6 or later in quirks mode.

For IE6, if the browser is running in standard compatibility mode, the inline element ignores the width or Height property, so setting width or height cannot be ordered in this case to have layout of the element.
If the element with "layout" is display:inline at the same time, its behavior is similar to that of the standard Inline-block:

In the paragraph, as in the normal text in the horizontal and continuous arrangement, affected by vertical-align, and size can be adjusted according to the content adaptive . This can also explain why inline elements in Ie/win alone can contain block-level elements that are less problematic, because Display:inline is inline in other browsers, unlike Ie/win, which becomes inline-block once inline elements have layout.

Workaround:

  
If the set Display:block,width property is in effect, the span at this point is the same as the Div.
If you set Display:inline-block, span is tied to the peer, and the width property takes effect. (this is normally used)

Refer to:

Http://www.jb51.net/css/21614.html

(go) HTML span label setting width not effective solution

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.