Several concepts of CSS core

Source: Internet
Author: User

box model, position, float. They are the basis of CSS, seemingly independent but complementary.

element Type

Block-level elements, inline elements

There are the following differences between them:

1. Block-level elements are exclusive to one line unless the Display property is modified. Inline elements are displayed in one line.

2, block-level elements can be set width, height property, and inline elements do not.

3. The width of block-level elements defaults to 100%, while inline elements determine their widths based on their own content or child elements.

Inline elements cannot be set to height, but can be achieved by setting Display:block. The elements are then rendered in block-level form.

When Display:inline, the element is rendered inline.

To let elements in line display, but also can set the height, you can set: Display:inline-block;

Box Model

Each element displayed on the page can be viewed as a box, or box model.

The box model consists of four parts: Content->padding->border->margin

Calculation of the width of the element ...

Two other special cases

Absolute positioning, floating (position, float)

1, Position

This property determines how the element will be positioned. There are roughly five types of the following:

static: The default value, the element is equivalent to no positioning, in the page occupy position, cannot use top, right, botton, left to move the element.

Relative: relative positioning, no positioning, in the page occupy position, you can use top, right, botton, left move element.

Absolute: absolute positioning, relative to the most recent level of positioning is not static parent element to locate, element in the page does not occupy the position, you can use top, right, botton, left move element.

fixed: Absolute positioning, relative to the browser window to locate, the rest and absolute the same.

Inhenit: Inherits the value of position from the parent element.

2, float

As the name implies, is to float the elements, the value of a total of four: left, right, none, inherit.

The original float was used for text wrapping, and it is now widely used.

Several concepts of CSS core

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.