Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax used to replace content div which has overflow:auto ends up adding extra scrollbars
    primarykey
    data
    text
    <p>im using a jquery ajax method to load different content divs, my content div (the div that get replaced each time i click on a link) has overflow:auto CSS on it, but when i load a page, it adds another scrollbar to my content div like so...</p> <p><img src="https://i.stack.imgur.com/b9zhm.jpg" alt="css overflow:auto with ajax"></p> <p>When it should really look like this for each page...</p> <p><img src="https://i.stack.imgur.com/HHSNS.jpg" alt="enter image description here"></p> <p>Here is my js...</p> <pre><code>$(document).ready(function() { var hash = window.location.hash.substr(1); var href = $('#links li a').each(function(){ var href = $(this).attr('href'); if(hash==href.substr(0,href.length-4)){ var toLoad = hash+'.html #cont'; $('#cont').load(toLoad) } }); $('#links li a').click(function(){ var toLoad = $(this).attr('href')+' #cont'; $('#cont').hide('fast',loadContent); $('#load').remove(); $('#wrap').append('&lt;span id="load"&gt;LOADING...&lt;/span&gt;'); $('#load').fadeIn('normal'); window.location.hash = $(this).attr('href').substr(0,$(this).attr('href').length-4); function loadContent() { $('#cont').load(toLoad,'',showNewContent()) } function showNewContent() { $('#cont').show('fast',hideLoader('fast')); } function hideLoader() { $('#load').fadeOut('normal'); } return false; }); }); </code></pre> <p>And this is the CSS for my content div...</p> <pre><code>#cont { overflow:auto ; margin:0 auto ; width:736px ; height:341px ; padding: 0 0 0 6px ; } </code></pre> <p>Can anyone think of a reason for the extra scrollbars, or can anyone think of a workaround?</p> <p>I'm using PHP include files to load my content...</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;I.C.T - St. Patrick's Academy, Lisburn&lt;/title&gt; &lt;link rel="stylesheet" type="text/css" href="assets/css/style.css"&gt; &lt;script type="text/javascript" src="assets/js/jq.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="assets/js/js.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="wrap"&gt; &lt;?php include("includes/head.php"); ?&gt; &lt;div id="screen"&gt; &lt;div id="pad"&gt; &lt;/div&gt; &lt;?php include("includes/home.php"); ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload