Current location: Hot Scripts Forums » General Web Coding » CSS » Problem with browser window size


Problem with browser window size

Reply
  #1 (permalink)  
Old 02-22-09, 01:18 PM
ianb ianb is offline
Newbie Coder
 
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Problem with browser window size

Hi

I have a fairly simple looking style sheet that gives me a 3 column page with fixed width left and right columns in which I have put an image each side and a fluid center column.

The only problem that I have is that right hand image is only partly shown and the browser window always opens up with the bottom scroll bar indicating that there is more content to the right ie the missing part of the image.

I would be really grateful if somebody could point me in the right direction with this please

Example can be seen at havenswift dot co dot uk slash ian dot html

Thanks
Ian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 02-23-09, 04:24 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
Hi Ian,

This solution works better for all browsers I think. I couldn't fix your current code to work in FF2, FF3, IE6 and IE7. Hope it helps:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css"> 
<!-- 
body  {
	font: 100% Verdana, Arial, Helvetica, sans-serif;
	background: #000000;
	margin: 0; 
	padding: 0;
	text-align: center; 
	color: #000000;
}

.mybody #container { 
	width: 100%;
	text-align: left; 
	background: #000000;
	color: red;
} 

.mybody #left {
	float: left; 
	width: 200px;
	height:844px;
	padding: 15px 0;
	background: #000000;
	background-image:url(http://havenswift.co.uk/images/RedCurtainLeft.jpg);
	background-repeat:no-repeat;
}
.mybody #right {
	float: right; 
	width: 200px;
	height:844px;
	padding: 15px 0;
	background: #000000;
	background-image:url(http://havenswift.co.uk/images/RedCurtainRight.jpg);
	background-repeat:no-repeat;
}

.mybody #left h3, .mybody #left p, .mybody #right p, .mybody #right h3 {
	margin-left: 10px; 
	margin-right: 10px;
}

.mybody #mainContent {
  margin: 0 12em 0 12em; 
  padding: 0 2em 0 2em; 
} 

.clearfloat {
	clear:both;
    height:0;
    font-size: 1px;
    line-height: 0px;
}
--> 
</style>

</head>

<body class="mybody">

<div id="container">
  <div id="left">
  </div>
  <div id="right">
  </div>
  <div id="mainContent">
    &nbsp;</div>
<br class="clearfloat" />
</div>
</body>
</html>
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 02-23-09, 08:08 AM
ianb ianb is offline
Newbie Coder
 
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks for help - one small ongoing problem

Hiya and thanks for your help with this so far !

Your solution has got rid of the initial problem that I had but I now have an issue when I add images to the centre block.

When I make the browser window smaller than the width of the largest image all of the text and images disappear completely.

I have had a play around with different things and I guess it is something to do with the way that I have added the images in the html code but I am still learning about all of this and not sure how to change it so this doesnt happen.

Thanks
Ian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 02-23-09, 08:27 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
Hi,

I was able to re-produce the problem. Question now is how you want it solved. If the image is too big, what do you want to happen?

- Should the image auto scale to fit?
- Should there be a horizontal scroll bar and the right curtain should shift to the right to create room for the image
- Other options?
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 02-23-09, 08:52 AM
ianb ianb is offline
Newbie Coder
 
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hiya and thanks for the very quick response.

1) I would be very interested to know how to auto scale the images to fit the available width - I think this would be useful although I am not sure if that would be the best way for this page

2) I presume you are saying that the left and right curtains would stay the same width and a horizontal scroll bar would appear when the width is less than the image width. I guess this would then make it appear that the curtain would slide across the centre column.

I think option 2 would be the best way but as I said above I would be very interested in both solutions.

Thanks
Ian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 02-23-09, 09:31 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
OK here's the first solution. Note that if you change the Width, the Height gets adjusted relative to the width change. So heigth and width aspect ratio stay the same. However, because you are changing the width/height on screen, images could look pretty poor. Just test to see if it works for you. Changes in red. I will get back to you with the second option soon. Just add id='img' to all images on your main content pane.

The best option by the way would be not having to display images that are too wide to fit the content

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css"> 
<!-- 
body  {
	font: 100% Verdana, Arial, Helvetica, sans-serif;
	background: #000000;
	margin: 0; 
	padding: 0;
	text-align: center; 
	color: #000000;
}

.mybody #container { 
	width: 100%;
	text-align: left; 
	background: #000000;
	color: red;
} 


.mybody #img { 
	/* Width of screen - side curtains and padding and margin  */
	width:expression(document.body.clientWidth - 460);
} 

.mybody #left {
	float: left; 
	width: 200px;
	height:844px;
	padding: 15px 0;
	background: #000000;
	background-image:url(http://havenswift.co.uk/images/RedCurtainLeft.jpg);
	background-repeat:no-repeat;
}
.mybody #right {
	float: right; 
	width: 200px;
	height:844px;
	padding: 15px 0;
	background: #000000;
	background-image:url(http://havenswift.co.uk/images/RedCurtainRight.jpg);
	background-repeat:no-repeat;
}

.mybody #left h3, .mybody #left p, .mybody #right p, .mybody #right h3 {
	margin-left: 10px; 
	margin-right: 10px;
}

.mybody #mainContent {
  margin: 0 12em 0 12em; 
  padding: 0 2em 0 2em; 
} 

.clearfloat {
	clear:both;
    height:0;
    font-size: 1px;
    line-height: 0px;
}
--> 
</style>
</head>

<body class="mybody">

<div id="container">
  <div id="left">
  </div>
  <div id="right">
  </div>
  <div id="mainContent">
	<img src='yourimage.jpg' id='img'><br />
	Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  

</div>
<br class="clearfloat" />
</div>
</body>
</html>
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 02-23-09, 09:56 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
OK and here a solution where:

Left and right curtain stay where they are. If needed (because of wide image or long text) a horizontal and vertical scrollbars gets displayed on the maincontent div. So not all the way to the right of the screen to the right of the right curtain, but on its left side. When you scroll left/right or top/down the curtains stay where they are. Changes in red:

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css"> 
<!-- 
body  {
	font: 100% Verdana, Arial, Helvetica, sans-serif;
	background: #000000;
	margin: 0; 
	padding: 0;
	text-align: center; 
	color: #000000;
	overflow:hidden;	
}

.mybody #container { 
	width: 100%;
	text-align: left; 
	background: #000000;
	color: red;
	overflow:hidden;	
} 


.mybody #left {
	float: left; 
	width: 200px;
	height:844px;
	padding: 15px 0;
	background: #000000;
	background-image:url(http://havenswift.co.uk/images/RedCurtainLeft.jpg);
	background-repeat:no-repeat;
}
.mybody #right {
	float: right; 
	width: 200px;
	height:844px;
	padding: 15px 0;
	background: #000000;
	background-image:url(http://havenswift.co.uk/images/RedCurtainRight.jpg);
	background-repeat:no-repeat;
}

.mybody #left h3, .mybody #left p, .mybody #right p, .mybody #right h3 {
	margin-left: 10px; 
	margin-right: 10px;
}

.mybody #mainContent {
  margin: 0 12em 0 12em; 
  padding: 0 2em 0 2em; 
  height:844px;
  overflow:auto;

} 


.clearfloat {
	clear:both;
    height:0;
    font-size: 1px;
    line-height: 0px;
}
--> 
</style>
</head>

<body class="mybody">

<div id="container">
  <div id="left">
  </div>
  <div id="right">
  </div>
  <div id="mainContent">
		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.  
	

</div>
<br class="clearfloat" />
</div>
</body>
</html>
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish

Last edited by Yeroon; 02-23-09 at 09:58 AM. Reason: Changes in red
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 02-23-09, 10:01 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
Please note that in the current setup you assume a visitor always has a minimal browser window height of 844pixels. People with a smaller viewport might get a weird effect where the bottom arrow of the vertical scrollbar sits outside the visible part.

Will think of a better solution. But the high side curtain images kind off force us to use the big height.
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 02-26-09, 05:41 AM
ianb ianb is offline
Newbie Coder
 
Join Date: Feb 2009
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Hi there Yeroon

Many thanks for all your suggestions and apologies for not coming back to you sooner - I never received an email to say that there had been an update to this thread so didnt come back and see your answers straight away !!

I have chosen to go with the second option and while I know that having images of this size isnt ideal my partner is insisting that this is the look that she wants !!

Is there any way of preventing the scroll bars from appearing in the maincontent div as I think it would look much better if these didnt show

Slowly starting to get to grips with CSS now so many thanks to you again !!

Ian
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 02-26-09, 05:45 AM
Yeroon's Avatar
Yeroon Yeroon is offline
Code Master
 
Join Date: Aug 2007
Location: Netherlands, Nijmegen
Posts: 850
Thanks: 2
Thanked 20 Times in 20 Posts
To hide scrollbars on any element specify the overflow:hidden; css attribute for it.
__________________
Feel free to thank people if they help you by clicking thanks at a post.
=================================
Make it idiot proof and someone will make a better idiot.
=================================
Realise the impotence of proof reading everything you publish
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How 2 Open a New Browser Window & Click a Submit Button Wildhalf JavaScript 3 12-08-06 04:34 PM
Code for opening a window to the size of the image jdsmith8 JavaScript 0 11-20-06 04:56 PM
Set browser window size Andy128 JavaScript 9 06-18-06 06:35 PM
window size Seeker HTML/XHTML/XML 2 09-15-05 05:20 PM
limiting size of pop-up window on Mac magda JavaScript 0 05-10-04 09:28 PM


All times are GMT -5. The time now is 01:07 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.