I have this code:
<script type='text/javascript' src='//code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(window).load(function(){
$('#content-left').css('width', '100%').css('width', '-=320px');
$(window).on('resize', function(){
$('#content-left').css('width', '100%').css('width', '-=320px');
});
});
//]]>
</script>
The above code works great but what I need is for this code to stop working or switch back to just 100% width (without subtracting the 320px) when the screen size is 768px or less.
I did some google searches and found this:
if ($(window).width() <= 768){
// do something here
}
But I'm not sure how to add this to my existing code.
Background:
My sidebar is a fixed sidebar on the right side of the page at 300px. And I have a padding of 20px between the sidebar (#content-right) and the main section (#content-left). My main section (#content-left) is using the above script of 100% - 320px.
I am using two CSS. One is a regular CSS. The other uses:
@media all and (max-width: 768px) {}
Thank you. :)