Iframe does not support the "resize:" property in Mozilla Firefox

2

I have a function that directs the WYSIHTML5 plugin into a textarea, this plugin migrates the textarea to an iframe:

<iframe 
    class="wysihtml5-sandbox" 
    security="restricted" 
    allowtransparency="true" 
    marginwidth="0" 
    marginheight="0" 
    style="resize: vertical !important; 
           background-color: rgb(255, 255, 255); 
           border-collapse: separate; 
           border-color: rgb(194, 202, 216); 
           border-style: solid; 
           border-width: 1.25px; 
           clear: none; 
           display: block; 
           float: none; 
           margin: 0px; 
           outline: 0px none rgb(85, 85, 85); 
           outline-offset: 0px; 
           padding: 6px 12px; 
           position: static; 
           top: auto;            
           left: auto;            
           right: auto; 
           bottom: auto; 
           z-index: auto; 
           vertical-align: text-bottom;            
           text-align: start; 
           box-sizing: border-box; 
           box-shadow: none; 
           border-radius: 0px; 
           width: 100%; 
           height: auto;" 
   width="0" 
   height="0" 
   frameborder="0">
</iframe>

The resize by default comes with: rezise:both (Not working), I'm changing with:

$('.wysihtml5-sandbox').prop('style', 'resize: vertical !important');

But I still can not apply the change in size, other browsers do not.

  

Knowing that I need to apply resize only vertically, how do I get around this problem?

    
asked by anonymous 10.11.2017 / 17:07

2 answers

2

Although the resize: property is not supported in Firefox when used in iframes , as already mentioned in the other response that was mentioned in MDN, it is still a property that will work perfectly on some others elements.

You do not need a hack or smart library to get the desired effect, just create a <div> and in it you will add resize: the display: inline-block; ), then put the size you want and within <div> put your <iframe> , defining the width and height as 100%

I've created an example that works with horizontal, vertical, and both:

  

Note1: You must add overflow: hidden or overflow: auto or overflow: scroll to the element you want to use resize: , except for elements <textarea> that already has scroll by default ( except you use overflow: visible; )

     

Note²: position:relative; is required to work in Chrome, otherwise the cursor to resize will be overridden by the iframe

.resize, .resize-v, .resize-h {
    position: relative;
    display: inline-block;
    overflow: hidden;
    min-width: 50px;  /* define largura minima */
    min-height: 50px; /* define altura minima */
    width: 200px;  /* define largura padrão/inicial */
    height: 200px; /* define altura padrão/inicial */
}

.resize-v {
   resize: vertical;
}

.resize-h {
    resize: horizontal;
}

.resize {
   resize: both !important; /*prioridade, acaso adicione resize com as outras classes*/
}

.resize > iframe,
.resize-v > iframe,
.resize-h > iframe {
   background-color: transparent;
   width: 100%;
   height: 100%;
   resize: none;
   border: none;
}

/* as cores abaixo são apenas para você diferenciar, pode remove-las */

.resize {
    background-color: #f00;
}

.resize-v {
    background-color: #00f;
}

.resize-h {
    background-color: #fc0;
}
<div class="resize">
    <iframe srcdoc="redimensiona vertical e horizontal"></iframe>
</div>

<hr>

<div class="resize-h">
    <iframe srcdoc="redimensiona horizontal"></iframe>
</div>

<hr>

<div class="resize-v">
    <iframe srcdoc="redimensiona vertical"></iframe>
</div>

Alternative

The only problem in the example is that in Chrome when the iframe gets small the "cursor" to drag some when the scroll appears, a way around this would be by discounting the height of iframes, like this:

height: calc(100% - 14px);

An example:

.resize, .resize-v, .resize-h {
    position: relative;
    display: inline-block;
    overflow: hidden;
    min-width: 50px;  /* define largura minima */
    min-height: 50px; /* define altura minima */
    width: 200px;  /* define largura padrão/inicial */
    height: 200px; /* define altura padrão/inicial */
}

.resize-v {
   resize: vertical;
}

.resize-h {
    resize: horizontal;
}

.resize {
   resize: both !important; /*prioridade, acaso adicione resize com as outras classes*/
}

.resize > iframe,
.resize-v > iframe,
.resize-h > iframe {
   background-color: transparent;
   width: 100%;
   height: calc(100% - 14px);
   resize: none;
   border: none;
}

/* as cores abaixo são apenas para você diferenciar, pode remove-las */

.resize {
    background-color: #f00;
}

.resize-v {
    background-color: #00f;
}

.resize-h {
    background-color: #fc0;
}
<div class="resize">
    <iframe srcdoc="redimensiona vertical e horizontal"></iframe>
</div>

<hr>

<div class="resize-h">
    <iframe srcdoc="redimensiona horizontal"></iframe>
</div>

<hr>

<div class="resize-v">
    <iframe srcdoc="redimensiona vertical"></iframe>
</div>
    
10.11.2017 / 20:52
1

Unfortunately this is not possible because Firefox does not support resize in iframes , according to MDN documentation:

Links:

10.11.2017 / 19:41