Jump to content

Adjusting according to the window size


latino.ad7

Recommended Posts

I'm not sure if this question belongs to this section of the forum. When building a website (with html, php, mysql) some people reported that the size of it is small (as I align it to the left, they have a big gap on the right).

 

How is it possible to adjust the layout based on people's window size or graphics resolution.

Link to comment
https://forums.phpfreaks.com/topic/192070-adjusting-according-to-the-window-size/
Share on other sites

Use javascript to get the window width then redirect back to the server and use php to var in  the correct css file to set the width. I use this in a controlled environment, in the wild you may want to include 680, 1152, 1280 and 1600 widths.

 

<?php
session_start();
if (!isset($_SESSION['browser_width']))
{
?>
<script type="text/javascript">

width = screen.width;
height = screen.height;

if (width > 0 && height >0) {
    window.location.href = "http://localhost/toolbar/index.php?width=" + width + "&height=" + height;
} else 
    exit();

</script>
<?php
}

if ($_GET['width'])
{
$_SESSION['browser_width']=$_GET['width'];
$width=$_GET['width'];
}
else
{
$width=$_SESSION['browser_width'];
}

include("$width.css");
?>

 

800.css

#main_div{

width: 798px;// set under for border expansion not triggering bottom scroll bar

 

1024.css

#main_div{

//width: 1024px;//skip width and expand full size

width:100%;

 

 

HTH

Teamatomic

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.