N
N
Nikita2014-02-14 13:48:34
css
Nikita, 2014-02-14 13:48:34

How to improve css image?

Hello everyone, I'm starting to do CSS and made such a simple sketch - brackets in brackets .
The problem is that the structure consists of several layers superimposed on each other, while they are positioned relative to the browser window.
The question is how to make sure that all elements are located relative to some common container? No matter how I experimented with positioning, everything floats away.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexey Svirschevskiy, 2014-02-14
@Freeddi

codepen.io/anon/pen/Lztpo
absolute is positioned relative to relative. while absolute must be inside the relative container. Even your ID names hint at such a structure outer - wrapper and inner inner block.

S
Sergey, 2014-02-14
Protko @Fesor

position: relative will solve your problem.
Since you're learning anyway, a few implementation criticisms:
- id - don't use id, don't use them at all. This is considered bad practice. Tales about the fact that selectors with id work faster are tales. It's all about the specificity of the selector, and how much it will take to check the selector to wander through the tree, selectors are marked up for each element, so you need to try to do everything so that the browser does not have to go very far up the flattery tree to check.
If you use before/after pseudo-elements, you can get by with 2 elements.

N
Nikita, 2014-02-14
@Freeddi

the fact of the matter is that the layers float away

Y
Yuri Lobanov, 2014-02-14
@iiil

jsfiddle.net/iiil/ubRhj/1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question