Answer the question
In order to leave comments, you need to log in
How to compose a picture on a picture (adaptive)?
Here is the code:
<div style="width:100%; height: 100%; position: relative;">
<img src="/wp-content/uploads/2015/04/ban.jpg" alt="фон в шапке" style="width:100%" />
<div style="position:absolute; right:500px; top:250px; height:70px;">
<a href="#"><img src="/wp-content/uploads/2015/04/iconka.gif" style="height:80px"/></a>
</div>
</div>
Answer the question
In order to leave comments, you need to log in
The first picture is a background, the second can be done as Pavel Torbeev wrote , but there is a more universal approach where you do not need to know the size of the picture:
.center {
position:absolute;
top:50%;
left:50%;
-ms-transform: translate(-50%, -50%);
-webkit-transform: translate(-50%, -50%);
-moz-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
The first picture is a background, the second without absolute positioning. margin: 0 auto; Well, you can still do Inline-block.
A universal solution for aligning in the middle for objects with absolute positioning (if the dimensions are known, for example, 80x80):
.center {
position:absolute;
top:50%;
left:50%;
margin-left: -40px; //смещаем на половину ширины
margin-top:-40px; //смещаем на половину высоты
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question