Answer the question
In order to leave comments, you need to log in
Elements with position: absolute, when scaled, are positioned relative to the window and fly apart. Why and how to fix?
example
<div class="parent">
<div class="child"></div>
<div class="child"></div>
</div>
.parent{
position: relative;
}
/*блок слева сверху:*/
.child{
position: absolute;
top: 0;
left: 0;
}
/* блок справа сверху:*/
.child:last-child{
right: 0;
left: auto;
}
Answer the question
In order to leave comments, you need to log in
Use another div . The one with 100% width is the parent. Inside it is a div with margin: 0 auto; with a fixed width, and it already has your absolute childrens . Hope I figured out the problem.
Set the value for absolutely positioned elements not in absolute values (px), but in relative values (%, em).
So, left: 345px with a layout width of 1000px would be: (345/1000)*100% = 34.5%
Why do you need an absolute? What prevents to make a float, and set the width of the blocks as a percentage?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question