Jump to content
  • 0

Позиционирование и скроллинг.


Deomon
 Share

Question

<html>
<head>
<title>test</title>
<script type="text/javascript">
function drawdiv(){
if (document.getElementById("new_div")){
document.body.removeChild(document.getElementById("new_div"));
}
var d=document.createElement("div");
d.id="new_div";
d.style.position="absolute"
d.style.top="50px";
d.style.left="50px";
d.style.background="#009900"
d.innerHTML="шминдер бокс"
document.getElementById("main").appendChild(d);
}
</script>
</head>
<body style="margin:15px 15px 15px 15px; background:#FFFFFF">
<div id="main" style="width:240px; height:385px; float:left; overflow:auto; border:solid 1px #880000" onclick="drawdiv()">
"Get money," she replied; "for you must know that when you reach the ground under the tree, you will find yourself in a large hall, lighted up by three hundred lamps; you will then see three doors, which can be easily opened, for the keys are in all the locks. On entering the first of the chambers, to which these doors lead, you will see a large chest, standing in the middle of the floor, and upon it a dog seated, with a pair of eyes as large as teacups. But you need not be at all afraid of him; I will give you my blue checked apron, which you must spread upon the floor, and then boldly seize hold of the dog, and place him upon it. You can then open the chest, and take from it as many pence as you please, they are only copper pence; but if you would rather have silver money, you must go into the second chamber. Here you will find another dog, with eyes as big as mill-wheels; but do not let that trouble you. Place him upon my apron, and then take what money you please. If, however, you like gold best, enter the third chamber, where there is another chest full of it. The dog who sits on this chest is very dreadful; his eyes are as big as a tower, but do not mind him. If he also is placed upon my apron, he cannot hurt you, and you may take from the chest what gold you will."
</div>
</body>
</html>

Несложно увидеть, что создаваемый по клику DIV не скроллируется вместе с текстом основного дива. Можно ли сделать так, чтобы он двигался вместе с текстом?

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy