Size of HTML question

  • Is it possible to autosize a HTML question, so that there is not a 40px spacing around it? 

    Let say we have a HTML question with a simple rectangle, like this: 

    <div style="width:100px;height:100px;border:1px solid #000;">Rectangle</div>

    If we preview the question, the size of the containing iframe is changed after exactly 1 second to a size of 140px times 140px. 

    • Is it possible to remove this unwanted extra 40px? 
    • Is it possible to autosize a HTML question to fill up the entire width of the page?
    • Is it possible to reduce this time delay of 1 second?

  • The following is a dirty hack and definitely not perfect (because of the 3 seconds delay), but it sort of autoresizes HTML questions to their contents. 

    Add the following code to the first HTML question inside a maple TA question:

    jQuery(function() { window.setTimeout(function() { 
    var iframes = parent.document.querySelectorAll("iframe"); 
    for( var i = 0; i < iframes.length; i++) { 
    iframes[i].style.setProperty("height", (iframes[i].contentWindow.document.body.scrollHeight - 40) + "px", "important"); }}, 3000);});

    If somebody finds a real solution to the problem of autosizing HTML questions, that would be great. 

  • The 40px spacing applies to the iframe for the entire HTML question. Whilst your trick worked for me, I'd suggest moving all of your Question Text to inside the Question HTML: part of the response area:

Log in to reply