简体   繁体   English

将2个不同的iFrame与特定的宽度尺寸对齐

[英]Aligning 2 different iFrames with specific width sizes

I have been trying to align 2 different iFrames on a page, one to the right and another to its left. 我一直在尝试在页面上对齐2个不同的iFrame,一个对齐到右侧,另一个对齐到左侧。 The iFrame to the left needs to have a width of 25% and height 100%, whereas the iFrame to the right needs to have a width of 75% and height 100%. 左侧的iFrame的宽度必须为25%,高度为100%,而右侧的iFrame的宽度必须为75%,高度为100%。 They are placed inside a table having a height and width of 100%. 它们被放置在高度和宽度为100%的桌子内。 I tried running my code on JSFiddle.net and it more or less looks the way I would have expected, however, it does not appear the same in my application (it definitely is not aligned 25%-75%). 我尝试在JSFiddle.net上运行我的代码,它或多或少看起来像我期望的那样,但是,它在我的应用程序中看起来并不相同(它肯定没有对齐25%-75%)。 Here's a screenshot . 这是截图

Here's my code snippet for the table: 这是我的表格代码片段:

<table height="100%" width="100%">
   <tr style="height:100%">

       <td style="width:25%">
           <iframe name="ifrTemplateLeftPreview" id="ifrTemplateLeftPreview" width="100%" height="100%"></iframe>
       </td>

       <td style="width:75%">
             <iframe name="ifrTemplateRightPreview" id="ifrTemplateRightPreview" width="100%" height="100%"></iframe>    
       </td>

   </tr>
</table>

I tried replacing '%' with pixels (px) to set the width of both tags, however, it seemed to mess the page up a bit and didn't seem to solve the issue. 我尝试用像素(px)替换'%'来设置两个标签的宽度,但是,这似乎使页面有些混乱,而且似乎无法解决问题。

The above code is only a part of the entire ASPX page, and I am sure nothing apart from this code snippet is causing any problems with the alignment of the iFrames. 上面的代码只是整个ASPX页面的一部分,我敢肯定,除了此代码段之外,没有任何其他问题会导致iFrame的对齐出现任何问题。 I have tried different ways but hasn't helped. 我尝试了不同的方法,但没有帮助。 Any help will be highly appreciated. 任何帮助将不胜感激。

Alright, I sorted the issue myself. 好吧,我自己整理了这个问题。 Basically I changed the <td> 's to <div> 's and added a float:left attribute to both iFrames and that seems to have sorted the issue: 基本上,我将<td>更改为<div> ,并向两个iFrame添加了float:left属性,这似乎已经解决了该问题:

<table height="100%" width="100%">
  <tr>
    <td>
      <div style="width:100%">

        <div style="width:25%; float:left">
         <iframe name="ifrTemplateLeftPreview" id="ifrTemplateLeftPreview" width="100%" height="100%"></iframe>
        </div>

        <div style="width:75%; float:left">
         <iframe name="ifrTemplateRightPreview" id="ifrTemplateRightPreview" width="100%" height="100%"></iframe>    
        </div>

       </div>
    </td>
  </tr>
</table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM