Positioning is a large module in CSS and allows you to describe how an element within an HTML document can be placed outside the normal document flow. As discussed in the last lesson, normal document flow is where all elements are rendered in the sequence in which they are entered within the HTML document.
One commonly used positioning type is relative positioning. The main question you might have from the very beginning is: "What will the element be positioned relative to?" The answer is simple enough, relative to its original position. The item stays in the document flow, and no other elements try to take its place.
Relative positioning is often used for visual effects, such as creating a shadow with a second block, or for a small animation when the mouse pointer hovers over an element.
When the mouse is moved over an element (you can use the
.animate-hover:hover selector for this), we used the CSS rule
position: relative, which means we're applying relative positioning to the element.
You can control the positioning of an element with the position property by using four CSS properties:
Each of these properties takes a value by which the element will be moved. These values do not have to be positive, the properties also take negative values. Try changing the values in the example above and see how the different values of the
left properties work.
The Hexlet support team or other students will answer you.
A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.
Programming courses for beginners and experienced developers. Start training for free
Our graduates work in companies:
Sign up or sign in
Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.