0
I created dynamically Labels with a certain position. The problem is that when I minimize the browser its position changes. How can I fix this?
//creation labels
var labeltemp = document.createElement("Label");
labeltemp.style.left = x2-10;
labeltemp.style.top = y2+5;
labeltemp.style.position='absolute';
var number = document.createTextNode(number);
labeltemp.appendChild(number);
document.body.appendChild(labeltemp);
Example: http://jsfiddle.net/zy6nLcgL/2/
I didn’t quite understand the question and maybe the solution I will present does not solve your problem, but remember to add the measure when changing sizes and positions.
labeltemp.style.left = x2-10 + "px"; labeltemp.style.top = y2+5 + "px";
– user20212
Using "absolute" position always makes a good result difficult when resizing the browser window.
– Joao Paulo
The Labels move out of the starting position. The position should be the same, but as the window gets smaller, it changes.
– akm
@akm so when you say "minimizo" you mean "I change the size of the window"? is that here in PT "minimizo" means close, put in the background. Then you must have
position: fixed;
or working with percentages. You have an example that you can set?– Sergio
Exactly, when I resize the window.
– akm
Okay, so when the window changes size do you want to maintain exactly the same position? or do you want to maintain a proportionality between the Abels?
– Sergio
Set the size and position in percentage instead of pixels.
– Renan Gomes
The example: http://jsfiddle.net/zy6nLcgL/2/ In this case I cannot show here the Bees in the right positions.
– akm