Photoshop Contest PhotoshopContest.com
Creative Contests. Real Prizes. Essential Resource.
You are not logged in. Log in or Register

 


Photoshop Contest Forum Index - Computer Problems - Webdesign question: Large backgrounds - Reply to topic

Goto page Previous  1, 2

TofuTheGreat

Location: Back where I belong.

Post Mon Apr 20, 2009 10:41 am   Reply with quote         


Give this a whirl. Just copy/paste into a blank web document and save as a plain HTML file on your test server. Load the page and see what it does. Then resize your browser window and do a hard-refresh of the page to see the changes. Client-side scripting handles the fun parts and can be modified to load images dynamically. Smile

(BTW needs some extra tweaks for IE).

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" xml:lang="en" lang="en">

<head>
  <title>Testy McScreeny</title>
<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/
function GetChrome(){
  var mHeight = window.innerHeight;
  var mWidth = window.innerWidth;
  var msg = document.getElementById("wrapper");

  mHeight = window.innerHeight;
  mWidth = window.innerWidth;

  var str = "Your screen resolution is set to\nWidth:"+screen.width+"\nHeight:"+screen.height;
  str += "<p/>Browser real estate is "+mWidth+" wide and "+mHeight+" tall.";
  str += "<p/>Here's a box showing the border shrunk in by 25 pixels.<p/>";

  msg.innerHTML = str;
  msg.style.minHeight = (mHeight-25)+"px";
  msg.style.width = (mWidth-25)+"px";
  msg.style.top = "5px";
  msg.style.left = "5px";
  msg.style.border = "1px solid #cccccc"
  msg.style.margin = "0 auto"
}
/*]]>*/
</script>

<style type="text/css">
/*<![CDATA[*/
#wrapper{
  text-align:center;
  font-weight:bold;
}

/*]]>*/
</style>

</head>

<body onLoad="GetChrome()">
  <div id="wrapper"></div>
</body>

</html>


Check out this sample as well.




_________________
Why I do believe it's pants-less o'clock! - Lar deSouza
”The mind is like a parachute, it doesn’t work if it isn’t open.” - Frank Zappa
Created using photoshop and absolutely no talent. - reyrey

kinetic_be

Location: Belgium

Post Mon Apr 20, 2009 4:13 pm   Reply with quote         


I'll give that a try. In the meanwhile I tried to learn a little bit about using Javascript and so far this is working for me:

Javascript code
Code:
if ((screen.width == 1280) && (screen.height == 800)) {
document.getElementById('Body').className="bg1"
}
else if ((screen.width == 800) && (screen.height == 600)) {
document.getElementById('Body').className="bg3"
}
else if ((screen.width == 1024) && (screen.height == 768)) {
document.getElementById('Body').className="bg4"
}
else if ((screen.width == 1920) && (screen.height == 1200)) {
document.getElementById('Body').className="bg5"
}
else {
document.getElementById('Body').className="bg1";
}


And CSS-code
Code:
.bg1 {
   background-image: url(images/bg768.jpg);
   background-repeat: no-repeat;
   background-color: #000000;
   background-position: center top;
}
.bg2 {
   background-image: url(images/bg600.jpg);
   background-repeat: no-repeat;
   background-color: #000000;
   background-position: center top;
}
.bg3 {
   background-image: url(images/bg800x600.jpg);
   background-repeat: no-repeat;
   background-color: #000000;
   background-position: center top;
}
.bg4 {
   background-image: url(images/bg1024x768.jpg);
   background-repeat: no-repeat;
   background-color: #000000;
   background-position: center top;
}
.bg5 {
   background-image: url(images/bg1920x949.jpg);
   background-repeat: no-repeat;
   background-color: #000000;
   background-position: center top;
}


I link to the code and Javascript in my <head> tags and this is working just fine.
One downside, I'll probably need to make a lot of images in order to have it fit on most screens. I think I'll stick to 10 resolutions and if one visitor who hasn't got that resolution, it will just get a default Background which would basicly fit on every screen.
With a few exceptions: Not going to make my website fit in 640px and lower..

Hope this is maybe usefull for anyone.




TofuTheGreat

Location: Back where I belong.

Post Mon Apr 20, 2009 4:22 pm   Reply with quote         


Smaller resolutions are good for visitors using cell phones and/or PDAs to visit your site. Just a thought you may want to consider.

Of course then you're better off having CSS that optimizes the site for WAP browerse. Wink

Also you could simplify your CSS:


Code:

.bg1,.bg2,.bg3,.bg4,.bg5 {
   background-repeat: no-repeat;
   background-color: #000000;
   background-position: center top;
}
.bg1 {
   background-image: url(images/bg768.jpg);
}
.bg2 {
   background-image: url(images/bg600.jpg);
}
.bg3 {
   background-image: url(images/bg800x600.jpg);
}
.bg4 {
   background-image: url(images/bg1024x768.jpg);
}
.bg5 {
   background-image: url(images/bg1920x949.jpg);
}




_________________
Why I do believe it's pants-less o'clock! - Lar deSouza
”The mind is like a parachute, it doesn’t work if it isn’t open.” - Frank Zappa
Created using photoshop and absolutely no talent. - reyrey

Post Mon Apr 20, 2009 4:28 pm   Reply with quote         


could do this a lot easier imho

see http://screwedpenguins.com/kinetic/
Code:

<html>
  <head>
    <title>Test for kinetic.be</title>
    <style type="text/css">
      html, body {margin:0; padding:0; width:100%; overflow:hidden;color:#FFF}
      #background{position:absolute; z-index:1; width:100%}
      #fixed {position:absolute; top:25px; left:10px; width:100%; z-index:10; color:#FFF;}
    </style>
  </head>
  <body>
    <div>
      <img id="background" src="http://photoshopcontest.com/images/fullsize/ltediivg7b9x6mffyd8ixhvl1rpz76cc7br7.jpg" alt="" title="" />

    </div>
    <div id="fixed">
      <p>Body needs fixed width en height of 100%, to prevent resizing when the body is not heigh enough</p>
      <p>first thing in body is a div width an absolutely positioned image width to 100% (you could also add a height of 100%, but with some resolutions the image might be a bit distorted)</p>
      <p>second div (this one) is overlayed and can contain all the content</p>
    </div>
  </body>

</html>




kinetic_be

Location: Belgium

Post Mon Apr 20, 2009 4:37 pm   Reply with quote         


Thanks!

@Grefix: Sirenka offered me the same solution yesterday. Or I think it was nearly the same.
Only problem (or it's a problem for me because I don't know how to work around it)
When I'm continuing to build my design on this, each time I select something what is on top of the background (table, layers, text, etc....) I select my bg instead and can't get access to what I want to work on, unless I select it in the source code.
Am I doing something wrong here? Or should I insert the background at the end, when everything else is being made?

PS. I really appreciate all the help I've gotten so far here!!!!!!!!!




Post Mon Apr 20, 2009 4:41 pm   Reply with quote         


kinetic_be wrote:
Thanks!

@Grefix: Sirenka offered me the same solution yesterday. Or I think it was nearly the same.
Only problem (or it's a problem for me because I don't know how to work around it)
When I'm continuing to build my design on this, each time I select something what is on top of the background (table, layers, text, etc....) I select my bg instead and can't get access to what I want to work on, unless I select it in the source code.
Am I doing something wrong here? Or should I insert the background at the end, when everything else is being made?

PS. I really appreciate all the help I've gotten so far here!!!!!!!!!


Well, I'm a nerd when it comes to that, i only use a notepad Smile

But I guess you're using dreamweaver, so maybe it would be best if you ad that img div when you finished working on the markup code. (it's only 3 lines, so it should be no biggie Smile )




kinetic_be

Location: Belgium

Post Mon Apr 20, 2009 4:51 pm   Reply with quote         


Notepad? omg.....
I wouldn't call you a nerd though.. Just someone with a lot of html-knowledge and A LOT OF TIME! Smile

Btw, I'll see if I can fix that.. to write code upon the background. It should be possible.




Goto page Previous  1, 2

Photoshop Contest Forum Index - Computer Problems - Webdesign question: Large backgrounds - Reply to topic

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Navigate PSC
Contests open  completed  winners  prizes  events  rules  rss 
Galleries votes  authentic  skillful  funny  creative  theme  winners 
Interact register  log in/out  forum  chat  user lookup  contact 
Stats monthly leaders  hall of fame  record holders 
PSC advantage  news (rss)  faq  about  links  contact  home 
Help faq  search  new users  tutorials  contact  password 

Adobe, the Adobe logo, Adobe Photoshop, Creative Suite and Illustrator are registered trademarks of Adobe Systems Incorporated.
Text and images copyright © 2000-2006 Photoshop Contest. All rights reserved.
A venture of ExpertRating.com