ComputersInformation Technology

Top of page CSS: content positioning

The CSS layout has always been rectangular. Any smooth lines - the competence of the developer. Style rules provide enough options to give the page a smooth shape within the screen resolution. But any element of layout is always a rectangle in which the arrangement of information is regulated by CSS rules.

Indentation on all sides is important for each page element when it is absolutely positioned, and the margin on top of CSS is defined specifically, because it is important for various elements, especially lowercase.

Basic positioning rules

The block element has a rule of indentation from the sides of the element in which the margin is located, an indentation rule for elements inside it (padding) and a border width (border), which can also be used.

Of particular importance is the indentation from above. CSS inside the block links the rules of internal indentation to rules of absolutely and relatively positioned elements within this block.

The usual practice of CSS-rules: you can specify indents from all sides equally, in pairs top / bottom and right / left or for each side separately. For example,

  • Margin: 10px;
  • Padding: 10px20px;
  • Padding: 10px20px30px40px.

In the first case, the element is indented from the sides of the external container in which it is located. In the second case, the padding at the top and bottom is 10px, the left and right margins are 20px. In the third case, the size of the indentation is indicated on all sides: top, right, bottom and left.

In all these cases, the margin on top of the CSS is 10 px.

Rules that change the position of elements

If the layout element is not positioned absolutely, it is located in the general order of page formation.

If you define an indent on top of the CSS in the scCurrInfo element, the target will be reached, and if at the li level, no.

In this example, using the padding rule: 40px; Requires an adequate reduction of the width and height rules by 80px. Otherwise, the size of the scCurrInfo block will go outside the outer block.

If you remove the padding rule from the scCurrInfo description, but add it with a value of 20px to the description of the style of the list item, we get just indent from the top. CSS will not apply this value to other parties.

Naturally, this use of the indentation rule applies to each li element.

Common practice of formatting content

Some developers achieve perfection by typing pages with block elements. Apparently, it's a classic practice to start from the tables and finish your own educational process on the blocks.

The freedom inherent in block layout is fascinating, and the developer's imagination may not be limited to strict tabular rules: only rows, only cells, merge only horizontally and vertically. Nothing inherent in relational ideas.

Meanwhile, the tables, in addition to obvious drawbacks, there are many qualitative advantages. Creating indents from the top, CSS takes into account the indents on the left, right (bottom - this is a special moment). The table cells rules allow you to control alignment both vertically and horizontally. Using row styles, combining them with cell styles, you can create complex content views.

The usual representation of a page in the form of rectangles (block layout) does not prevent it from being presented in the form of a table. These are also rectangles, but they are also table cells, that is, they have their own rules that complement the rules of the blocks.

Absolute positioning

; Block with the POSITION rule: absolute ; Will be in the place set by its coordinates relative to the block in which it is located.

A characteristic feature of CSS rules is "practice is the best criterion of truth" in most cases, especially when cross-browser compatibility is required and layout is done manually, it is preferable to study full-fledged manuals for cascading style sheets.

Using tables often leads to problems in the displacement of the contents of cells. A similar displacement within the block does not always affect all elements. Experimenting, you can achieve the desired result. The trivial task: how to remove indent from the top, CSS does not always solve trivially.

In some cases, when it is necessary to make elements of a page in the depths of any popular content management system of the site, it is nevertheless necessary to pay attention not only to experimental practice, but also to look at the experience of colleagues.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.unansea.com. Theme powered by WordPress.