HTML question

  • Thread starter Thread starter antispatula
  • Start date Start date
antispatula

antispatula

Active member
So everyone uses different resolutions and screen sizes. When I put up a background image on lets say my homepage, it may look great on my screen, but on others it is too small to fit the whole screen and looks bad. Is there a way to make it so it looks uniform on any screen? Maybe by centering the image or something using a code? Please help me out if you can, thank you.
 
antispatula said:
So everyone uses different resolutions and screen sizes. When I put up a background image on lets say my homepage, it may look great on my screen, but on others it is too small to fit the whole screen and looks bad. Is there a way to make it so it looks uniform on any screen? Maybe by centering the image or something using a code? Please help me out if you can, thank you.


unforunately, the only way that i've come across is a javascript that will automatically adjust for screen resizing. We use one we've called minmax.

I could give you a copy of it, however, you'll need an understanding of javascript to utlize it.

Other than that, you can get some success out of CSS as positioning is coordinate based and not linearly based*(cascading stylesheets). If you don't use CSS already, you will love it once you do.

*for instance, you can position a graphic like this

#jpg {
position:relative;
top: 25px;
right: 100px;
}

meaning the graphic is 25 pixels from the top edge and 100 px from the right edge.

CSS allows you to name attributes for an element, say name a font type "font 1" now if you reference "font 1" from inside an html document, the parser will run to your CSS code, pick up the font attributes, and apply them to your font. This makes it easy to change certain styles of elements, without recoding all your HTML.

there are lots of site on CSS
 
aw man. thanks for the thoughful help but none of that sounds familiar to me, I only know simple html codes.
 
Here's another idea which I've done in the past. It only works well if the background of your image is a solid color. For this example, say: black.

You have 3 images. One is the background image that you made. The other 2 simply sit on the left side and right side. You have them in this order:

Left image (plain black) | Your Image | Right image (plain black)

This will give the illusion that your image is longer. The left/right images simply fill in the space that your image doesn't. So it appears to fit the page exactly.

I believe this can be done in CSS but I did it in PHP, the left/right images were generated on-the-fly depending on the screen resolution.

Sorry if this makes no sense, I'm a little drunk. ;)
 
antispatula said:
aw man. thanks for the thoughful help but none of that sounds familiar to me, I only know simple html codes.


well that's ok. CSS seems intimidating, but once you do it once and get it, it's really cool.
 
I used to use tables and then use xx% for the width of the columns. that way the layout (an invisible table with no borders) would stretch to accomodate any screen size.

For example
<html><body>

<table border=0 width=100%>
<tr>
<td>header code</td>
</tr>

<tr colspan=2>
<td width=25%>Left BAR CODE</td>

<td width=75%>Main Window Code</td>
</tr>
</table>
</body></html>
 
I just realized that I didn't answer your question. you could center it and have the edges of the bg picture blend into the chosen background color. You could also use DIV tags and center an image that way, then layer it under the rest of the page.
 
nukeitout said:
I used to use tables and then use xx% for the width of the columns. that way the layout (an invisible table with no borders) would stretch to accomodate any screen size.

For example
<html><body>

<table border=0 width=100%>
<tr>
<td>header code</td>
</tr>

<tr colspan=2>
<td width=25%>Left BAR CODE</td>

<td width=75%>Main Window Code</td>
</tr>
</table>
</body></html>

i'm going to attempt to dispel the notion that css is difficult by using your example and adding css tags

<html>

<style type='text/css'>

table1 {

position:absolute;
top:25px;
left:50px;
z-index:0;
}
</style>
<body>

<table class='table1' border=0 width=100%>
<tr>
<td>header code</td>
</tr>

<tr colspan=2>
<td width=25%>Left BAR CODE</td>

<td width=75%>Main Window Code</td>
</tr>
</table>
</body></html>[/QUOTE]


in this example, i've added a style tag to the header of the HTML doc. table1 is the name of the class of the style. position:absolute; is the first tag. It means that table one will be positioned using a coordinate regardless of window size or resolution. meaning that at a low resolution, it's still at it's position relative to the resolution.

top:25px; means that the element (table1) will be positioned 25 pixels from the top border of the window.

left:50px; means that table1 will be 50pixels from the left border of the window.
z-index:0; refers to css's ability to layer elements. What it means is that table1 resides in the "0" layer. you could make it reside in z-index:50; if you wanted. You could layer 1000 images over 1000 tables all in their respective z-index. but that would be confusing. So, you can opt to include a z-index or not, it doesn't matter.

What this means is that if a window is resized, the element remains in a fixed position, whereas with HTML, the table can become jumbled if the % are off. ESPECIALLY if you used fixed widths (which nuke has not).



But.....making HTML elements actually resize to fit different windows is a complex script. here is our minmax.js file in text.


// minmax.js

/*@cc_on
@if (@_win32 && @_jscript_version>4)

var minmax_elements;

minmax_props= new Array(
new Array('min-width', 'minWidth'),
new Array('max-width', 'maxWidth'),
new Array('min-height','minHeight'),
new Array('max-height','maxHeight')
);

// Binding. Called on all new elements. If <body>, initialise; check all
// elements for minmax properties

function minmax_bind(el) {
var i, em, ms;
var st= el.style, cs= el.currentStyle;

if (minmax_elements==window.undefined) {
// initialise when body element has turned up, but only on IE
if (!document.body || !document.body.currentStyle) return;
minmax_elements= new Array();
window.attachEvent('onresize', minmax_delayout);
// make font size listener
em= document.createElement('div');
em.setAttribute('id', 'minmax_em');
em.style.position= 'absolute'; em.style.visibility= 'hidden';
em.style.fontSize= 'xx-large'; em.style.height= '5em';
em.style.top='-5em'; em.style.left= '0';
if (em.style.setExpression) {
em.style.setExpression('width', 'minmax_checkFont()');
document.body.insertBefore(em, document.body.firstChild);
}
}

// transform hyphenated properties the browser has not caught to camelCase
for (i= minmax_props.length; i-->0;)
if (cs[minmax_props[0]])
st[minmax_props[1]]= cs[minmax_props[0]];
// add element with properties to list, store optimal size values
for (i= minmax_props.length; i-->0;) {
ms= cs[minmax_props[1]];
if (ms && ms!='auto' && ms!='none' && ms!='0' && ms!='') {
st.minmaxWidth= cs.width; st.minmaxHeight= cs.height;
minmax_elements[minmax_elements.length]= el;
// will need a layout later
minmax_delayout();
break;
} }
}

// check for font size changes

var minmax_fontsize= 0;
function minmax_checkFont() {
var fs= document.getElementById('minmax_em').offsetHeight;
if (minmax_fontsize!=fs && minmax_fontsize!=0)
minmax_delayout();
minmax_fontsize= fs;
return '5em';
}

// Layout. Called after window and font size-change. Go through elements we
// picked out earlier and set their size to the minimum, maximum and optimum,
// choosing whichever is appropriate

// Request re-layout at next available moment
var minmax_delaying= false;
function minmax_delayout() {
if (minmax_delaying) return;

basically, all elements referencing the min max will have their attributes defined by the script.

it's tough.. now imagine designing websites that will automatically detect what browser you're using and tailor it's presentation to your browser.

Like some site detect a PDA browser and reformat to fit a PDA screen.

It's pretty nutty. but CSS will take your sites to a new level of presentation that you may like. here's a reference

http://www.w3schools.com/css/default.asp
 
brendandwyer said:
i'm going to attempt to dispel the notion that css is difficult by using your example and adding css tags

<html>

<style type='text/css'>

table1 {

position:absolute;
top:25px;
left:50px;
z-index:0;
}
</style>
<body>

<table class='table1' border=0 width=100%>
<tr>
<td>header code</td>
</tr>

<tr colspan=2>
<td width=25%>Left BAR CODE</td>

<td width=75%>Main Window Code</td>
</tr>
</table>
</body></html>


in this example, i've added a style tag to the header of the HTML doc. table1 is the name of the class of the style. position:absolute; is the first tag. It means that table one will be positioned using a coordinate regardless of window size or resolution. meaning that at a low resolution, it's still at it's position relative to the resolution.

top:25px; means that the element (table1) will be positioned 25 pixels from the top border of the window.

left:50px; means that table1 will be 50pixels from the left border of the window.
z-index:0; refers to css's ability to layer elements. What it means is that table1 resides in the "0" layer. you could make it reside in z-index:50; if you wanted. You could layer 1000 images over 1000 tables all in their respective z-index. but that would be confusing. So, you can opt to include a z-index or not, it doesn't matter.

What this means is that if a window is resized, the element remains in a fixed position, whereas with HTML, the table can become jumbled if the % are off. ESPECIALLY if you used fixed widths (which nuke has not).



But.....making HTML elements actually resize to fit different windows is a complex script. here is our minmax.js file in text.


// minmax.js

/*@cc_on
@if (@_win32 && @_jscript_version>4)

var minmax_elements;

minmax_props= new Array(
new Array('min-width', 'minWidth'),
new Array('max-width', 'maxWidth'),
new Array('min-height','minHeight'),
new Array('max-height','maxHeight')
);

// Binding. Called on all new elements. If <body>, initialise; check all
// elements for minmax properties

function minmax_bind(el) {
var i, em, ms;
var st= el.style, cs= el.currentStyle;

if (minmax_elements==window.undefined) {
// initialise when body element has turned up, but only on IE
if (!document.body || !document.body.currentStyle) return;
minmax_elements= new Array();
window.attachEvent('onresize', minmax_delayout);
// make font size listener
em= document.createElement('div');
em.setAttribute('id', 'minmax_em');
em.style.position= 'absolute'; em.style.visibility= 'hidden';
em.style.fontSize= 'xx-large'; em.style.height= '5em';
em.style.top='-5em'; em.style.left= '0';
if (em.style.setExpression) {
em.style.setExpression('width', 'minmax_checkFont()');
document.body.insertBefore(em, document.body.firstChild);
}
}

// transform hyphenated properties the browser has not caught to camelCase
for (i= minmax_props.length; i-->0;)
if (cs[minmax_props[0]])
st[minmax_props[1]]= cs[minmax_props[0]];
// add element with properties to list, store optimal size values
for (i= minmax_props.length; i-->0;) {
ms= cs[minmax_props[1]];
if (ms && ms!='auto' && ms!='none' && ms!='0' && ms!='') {
st.minmaxWidth= cs.width; st.minmaxHeight= cs.height;
minmax_elements[minmax_elements.length]= el;
// will need a layout later
minmax_delayout();
break;
} }
}

// check for font size changes

var minmax_fontsize= 0;
function minmax_checkFont() {
var fs= document.getElementById('minmax_em').offsetHeight;
if (minmax_fontsize!=fs && minmax_fontsize!=0)
minmax_delayout();
minmax_fontsize= fs;
return '5em';
}

// Layout. Called after window and font size-change. Go through elements we
// picked out earlier and set their size to the minimum, maximum and optimum,
// choosing whichever is appropriate

// Request re-layout at next available moment
var minmax_delaying= false;
function minmax_delayout() {
if (minmax_delaying) return;

basically, all elements referencing the min max will have their attributes defined by the script.

it's tough.. now imagine designing websites that will automatically detect what browser you're using and tailor it's presentation to your browser.

Like some site detect a PDA browser and reformat to fit a PDA screen.

It's pretty nutty. but CSS will take your sites to a new level of presentation that you may like. here's a reference

http://www.w3schools.com/css/default.asp[/QUOTE]
Most complicated post ever. :D
 
Back
Top