I am new to sof so please let me know if the information I have given is incomplete or insufficient.
I have to iFrames sitting side by side. I want to be able to resize them on the x-axis and when I resize one of them, the other resizes accordingly to fit the screen.
I got the resizing one of them part down but the other element does not resize specifically the that contains "docWindow" iFrame.
Here is the relevant html (let know if insufficient):
.resizable {
display: flex;
margin: 0;
padding: 0;
resize: horizontal;
overflow: hidden
}
.resizable>.resized {
flex-grow: 1;
margin: 0;
padding: 0;
border: 0
}
.ugly {
background: red;
border: 4px dashed black;
}
#container2 {
flex: 0 0 225px;
left: 25px;
top: 108px;
height: 828px;
border: thin solid black;
position: absolute;
width: 225px;
margin-bottom: 100px;
background-color: #e9e9ed;
word-wrap: break-word;
}
#container1 {
flex: 1;
border-left: none;
border-right: thin solid black;
border-bottom: thin solid black;
border-top: thin solid black;
position: relative;
left: 245px;
top: 100px;
background-color: #e9e9ed;
}
<div style="display: flex;">
<div class="resizable ugly" id="container1">
<iframe class="resized" frameborder="1" height="828" width="1580" id="docWindow" name="docWindow" scrolling="yes" src="placeholder_page.html" style="position:relative;"></iframe>
</div>
<div class="resizable ugly" id="container2">
<iframe class="resized" frameborder="1" height="830" id="navbarFrame" name="navbarFrame" scrolling="yes" width="225" src="parent-nav-buttons.html" style="position:relative;"></iframe>
</div>
</div>
2
Answers
No need to use those complex relative and absolute positioning. You only need two flex element with
felx-grow:1
andwidth="100%"
andheight="100%"
for iframes. That’s all.Grid works better than flexbox for this scenario, because you can set the width of the left column to
auto
so that it adjusts to fit its contents (the resizable iframe) and set the width of the right column to1fr
to consume all of the remaining space. Give the left iframe a specified width, and make the right iframe 100% width.