• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

Website in all screen resolutions?

Web Developer
Loyal Member
Joined
Nov 5, 2009
Messages
1,229
Reaction score
309
I've developed an website, and as far as I'm aware from testing on the site is compatible with all screen sizes 13" and above. This means its not compatible with 11" and 12" NetBooks. (and all mobile devices of course - which isn't an big concern for me at the moment).

check here.

Is there some sort of Javascript code which would be able to resolve this issue? Every time I create an width: 100% website I come across issues like this. Or is there an easy CSS fix?

Live preview here,

Any help is appreciated thanks.
 
Joined
May 17, 2007
Messages
2,474
Reaction score
681
Take a look at . It can be done by both CSS and JavaScript. More people use CSS for this type of stuff though (using ). Some frameworks already come with responsive designs, such as bootstrap and foundation. You can see a good comparison here: There are ways to do this using JS, but sometimes more complex. Stick with CSS, which was made for things like this.
 
Web Developer
Loyal Member
Joined
Nov 5, 2009
Messages
1,229
Reaction score
309
Thanks. I cant seem to find an simple CSS solution.. there probably is one I just can't see it. This code is from an old project a friend did with me, What do you think?

PHP:
// onresize
$(window).resize(function(){
	dim(); // set dimensions
	sidebar(); // resize sidebar
    topbar();
    header();
    mainheadercontent();
	limit(); // resize contents accordingly
});

// get/ set dimensions of window when called
function dim(){
	height = $(window).height();
	width = $(window).width();
}
 
Joined
May 17, 2007
Messages
2,474
Reaction score
681
Thanks. I cant seem to find an simple CSS solution..

There's no such thing as "complex" CSS haha, it's the easiest thing.

Like I said, look at media queries:

The point is, for different device sizes, you use a different set of styles.

Maybe this template will help you:

Code:
/* Smartphones (portrait and landscape) ----------- */ 
@[I][B][URL="http://forum.ragezone.com/members/1333434998.html"]Media[/URL][/B][/I] only screen 
and (min-device-width : 320px) 
and (max-device-width : 480px) {
/* Styles */
}


/* Smartphones (landscape) ----------- */ 
@[I][B][URL="http://forum.ragezone.com/members/1333434998.html"]Media[/URL][/B][/I] only screen 
and (min-width : 321px) {
/* Styles */
}


/* Smartphones (portrait) ----------- */ 
@[I][B][URL="http://forum.ragezone.com/members/1333434998.html"]Media[/URL][/B][/I] only screen 
and (max-width : 320px) {
/* Styles */
}


/* iPads (portrait and landscape) ----------- */ 
@[I][B][URL="http://forum.ragezone.com/members/1333434998.html"]Media[/URL][/B][/I] only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) {
/* Styles */
}


/* iPads (landscape) ----------- */ 
@[I][B][URL="http://forum.ragezone.com/members/1333434998.html"]Media[/URL][/B][/I] only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : landscape) {
/* Styles */
}


/* iPads (portrait) ----------- */ 
@[I][B][URL="http://forum.ragezone.com/members/1333434998.html"]Media[/URL][/B][/I] only screen 
and (min-device-width : 768px) 
and (max-device-width : 1024px) 
and (orientation : portrait) {
/* Styles */
}


/* Desktops and laptops ----------- */ 
@[I][B][URL="http://forum.ragezone.com/members/1333434998.html"]Media[/URL][/B][/I] only screen 
and (min-width : 1224px) {
/* Styles */
}


/* Large screens ----------- */ 
@[I][B][URL="http://forum.ragezone.com/members/1333434998.html"]Media[/URL][/B][/I] only screen 
and (min-width : 1824px) {
/* Styles */
}


/* iPhone 4 ----------- */ 
@[I][B][URL="http://forum.ragezone.com/members/1333434998.html"]Media[/URL][/B][/I]
only screen and (-webkit-min-device-pixel-ratio : 1.5),
only screen and (min-device-pixel-ratio : 1.5) {
/* Styles */
}

About your javascript code, depending on how the functions inside the resize event works, it could be the solution. But I would highly recommend CSS for this.
 
Joined
Oct 31, 2005
Messages
3,113
Reaction score
1,539
Basically you do not set a fixed width to your elements. You operate with "min-width" and "max-width" only. It's a bit tricky when it comes to floating elements, but it can be done. See live example here I made the same way " ". Try resizing your browser window.
 
Back
Top