M
M
Mak3542018-02-18 13:37:21
css
Mak354, 2018-02-18 13:37:21

How to write the position property correctly?

There are 3 div blocks, I assigned them a certain height and width and there is an img, there is a picture in it, I want to place 3 div blocks inside the picture, I write it like this: img {position: relative} and div blocks position absolute, left: 0, top: 0, but they appear in the upper left corner, i.e. they are positioned relative to the body, I don't understand why?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ink, 2018-02-18
@Mak354

img is a photo and it cannot be a parent for anyone
, but if img wraps a div and makes it a parent, i.e. relative, in this case the absolute elements will be exactly inside it

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question