You can't detect the page width of the client from the server.
if you wanted the server to the div then you would first need to call a page that captures the screen width and then passes it to the server in a request for your page:
Example javascript (using JQuery):
window.location.href = 'www.site.com/mypage.php?page_width=' + $(window).width();
This could then be accessed in php through $_GET['page_width']
Alternatively you could do the whole thing in JavaScript which would be a good and dynamic way to handle it that would also take account of resizing of the browser window during page use.
I would strongly recommend using a library like JQuery as it makes your code much neater and is very powerful. This can simply be done using the following line of code: (for a web connected site, if it is for local use you would need to download the file locally)
<script type="text/javascript" src="https://code.jquery.com/jquery-latest.min.js"></script>
Then it would be a simple matter of inserting the following code:
$(function(){
if($(window).width() < 768){
$('div.left').hide();
}
});
The $(function(){ });
runs the code when the page has loaded.
If you wanted it to work when the page was resized as well then you could put that inside a function
function checkSize(){
if($(window).width() < 768){
$('div.left').hide();
}else{
$('div.left').show();
}
}
and call it when the page is loaded and when the screen is resized, like so:
$(function(){
checkSize();
});
$( window ).resize(function() {
checkSize();
});
You have to understand that the browser will download the whole html-file, build the website and then check the css-code that styles the css. You will not be able to provide the browser from loading things with css.
– May 03 '14 at 07:45