To Change the Div width according to window size, I googled and attempt with below JQuery script (combined answer from stackoverflow posts):
JQuery script:
<script>
function checkWindowSize() {
if ($(window).width() > 1800) {
$('#divwidth').addClass('large');
}
else {
$('#divwidth').removeClass('large');
}
}
$(window).resize(checkWindowSize);
</script>
CssClass:
#divwidth{
width: 1200px;
}
#divwidth .large{
width: 2200px;
}
And here's my html using the class:
<div style="text-align: left; margin-left:auto;margin-right:auto; overflow-x:auto;" ID="divwidth">
<!-- my gridview here -->
</div>
It doesn't seems to work to set the Div width. changing giving script type "text/Javascript" does not help either.
#divwidthis more specific than.largeso.largeis being ignored.