Overflow css rule

It is not always necessary to make the page element visible. Often, you only need to make visible its contents, usually an image, text, table. The overflow CSS rule sets the content display mode.

overflow css

By putting block elements into each other, you can effectively regulate the display of content in the right bounds, manage scrolling strips, and make your own version of content management.

General rules of application

The overflow CSS rule accepts five values:

  • visible;
  • hidden;
  • scroll
  • auto;
  • inherit.

When visible is indicated, the content may extend beyond the element. In the case of hidden, the outside part will be clipped. Using scroll and auto allows you to add scroll bars to view content that goes beyond the element.

The element size is determined by the width and height rules. When an overflow CSS rule allows scrolling (scroll and auto values), its bars are placed inside the element. It is not always convenient and in most cases will not match the design of the page when the developer is interested in content management and does not plan to use the classic "sliders".

overflow css values

Practice, when an element with content is considered in isolation, gives little opportunity to achieve the desired result. If an element is considered as a collection of several block tags nested in or combined with each other, a host of possibilities opens up.

When overflow CSS is not a standard version of the rule, the responsibility for the correct output of the content rests on the JavaScript code.

Example: JavaScript + overflow without CSS

The only "flaw" in CSS rules is to fulfill its mission as prescribed by their syntax and purpose. In most cases, this is more than enough.

Ideally, use overflow css (auto or scroll values). When testing, you can always see what is displayed in a particular block.

Meanwhile, the design of the site, the desire of the developer to offer their own option to navigate through the content and, most importantly, the scope of the site may require a uniquely different solution than what CSS can offer.

The author's example is not a picture.

In this example, the blocks can not only contain content that “creeps” out of bounds. There is a need to move it relative to each other. One object is an emulation of the electronic currency exchange table (in fact, it’s a div), but two instances of content. In one instance, one direction of exchange, in the other - another.

Each block can stretch (shrink) in height and width, be located above the other block. Implementing these features with the standard overflow CSS is not possible. When you change the size of the main unit must rebuild all the internal divs. At the same time, the font size should change proportionally, since the option of cutting off information in financial programs seems to be poorly applicable.

Pure CSS overflow, but without sliders

The scrolling offered by HTML / CSS is undoubtedly practical, and for the debugging stage it is simply necessary, but there is one significant point. When the mouse is over a block in which there is scrolling, the content of this block is moved, and not the whole page.

This moment is not very convenient in practice: you have to control the place on the page where you can turn the mouse wheel. Some visitors do not like it, some just do not pay attention.

Meanwhile, nothing prevents the developer from combining the possible with the desired. If the content of the block goes beyond its limits, you can only bring its essence into it, prohibiting scrolling in it. But when the user paid attention to it, while holding the mouse cursor for a while, it is necessary to expand the block to the desired size and bring all the content into it.

In this embodiment, the page will be concentrated content, which, if necessary, the visitor himself can reveal.

In a general sense, when creating block elements, you should move away from the idea that one element is one “div”, “span” or “td”. Thinking with HTML tags is not a very rewarding thing. It is much more practical to think with the semantic elements of the page, and how much they require to implement HTML tags is another question.

Movement determined by content

If we take the idea of ​​“there is a block whose dimensions determine its content,” then for the overflow CSS rule this is a completely different option. There is no need to rely on standard scrolling or to write your own JavaScript code.

overflow css is

If you design a site as a collection of elements, the size and position of which are determined by their content, then depending on the actions of the visitor, certain blocks will be revealed. It is possible that they will be revealed on the whole page or on its significant part.

By and large, the movement of the visitor is his interest in information. Coming to the site, he observes his initial state and chooses what is interesting to him.The movement of the mouse on the screen or the finger on the smartphone automatically opens the current actual block, leaving it leads to its closing and opening the next one.

Currently, when creating a modern website is not so difficult, it became problematic to surprise and interest the visitor. The transition from thinking with HTML tags to manipulating information elements that are relevant to the visitor is a good idea.

Related news

Overflow css rule image, picture, imagery


Overflow css rule 21


Overflow css rule 12


Overflow css rule 43


Overflow css rule 55


Overflow css rule 80


Overflow css rule 11


Overflow css rule 22


Overflow css rule 62


Overflow css rule 44


Overflow css rule 66