开发者

Webpage layout breaking on window resize

开发者 https://www.devze.com 2023-01-30 00:14 出处:网络
The images below illustrate what the actual problem is So as you can see this is a puzzle, and is being created by javascript. Each row is created like this.

The images below illustrate what the actual problem is

Webpage layout breaking on window resize

So as you can see this is a puzzle, and is being created by javascript. Each row is created like this.

document.write("<div style='float:none'>");
for(i=0; i < 4 ; i++) { 
        for(j=0; j < 4 ; j++) {
         imgArray[i] = "Images/" + x + ".jpg";
         document.write("<img id= " + x + " src='Images/" + x + ".jpg' width='120' height='120' style='positio开发者_JAVA技巧n:relative;top:50px;left:50px' onclick='checkMove(parseInt(id))'/>");
         x = x + 1;
        }
        document.write("<br>");
}
document.write("</div>");

Even using float style keeps this problem. Is there a way to lock a window not to be resized smaller than x? Could you please point me in the right direction as in what im doing wrong, or not doing.


Have you tried to add a fixed width to your div?

<div style='float:none;width:480px;'>


If you give your div a width (in px), resizing will cause a scrollbar to appear.

document.write("<div style='float:none;width:600px'>");


Just use css to set the width of the container div to the width of 4 images, which should be 480px.


Try putting

white-space: nowrap;

on the style of the div. That should prevent its contents from wrapping. Instead you'll get a horizontal scrollbar.


Also consider min-width http://www.w3schools.com/jsref/prop_style_minwidth.asp and the CSS equivalent.

0

精彩评论

暂无评论...
验证码 换一张
取 消