<span> and <a> the margin up and down and padding up and down does not work for reasons and solutions

Source: Internet
Author: User

Use to <span> and <a> tags, found in the style directly write Margin-top, Margin-bottom and Padding-top, Padding-bottom are not working, page style of things do not know much, Search, found because <span> and <a> are not block-level elements, so these properties are not valid.

Workaround: Add Display:block to the style and solve the problem.

In the style of span, to ensure that text is centered horizontally and vertically, you need to add the following attributes:
Text-align:center;
line-height:20px;
which text-align:center; As the name implies, no need to explain. line-height:20px; The value of this property needs to be consistent with the height of span.

Display:inline-block is a block-level element in the row, it has the characteristics of block-level elements, you can set the length of the width, you can set the margin and padding value, but it is not exclusive line, its broadband does not occupy the parent element, but the same as the element in the row, Can be in the same row as other inline elements. It combines the characteristics of block-level elements and inline elements.

Position:absolute and float implicitly change the display type, regardless of the previous type of element (except Display:none), as long as Position:absolute, float:left, or float are set: Any of right allows the element to be displayed in a display:inline-block way. Even if we display the Display:inline or display:block, it is still invalid (float in IE 6 double margin bug is the use of add display:inline to solve).

It is important to note that Position:relative does not implicitly change the type of display.

<span> and <a> the margin up and down and padding up and down does not work for reasons and solutions

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.