代码之家  ›  专栏  ›  技术社区  ›  Datacrawler

iFrames没有并排响应(当屏幕变小时,内联块中断)

  •  0
  • Datacrawler  · 技术社区  · 6 年前

    我用两个 iframes 我已经删除了任何 padding margin

    body{
        background:#0d3852;
        margin:0;
        padding:0;
    }
    iframe{
        background:#ccc;
        border:0;
        margin:0;
        padding:0;
    }
    .box { 
        margin:0;
        padding:0;
        display:inline-block;
        width:49.77%;
    }
    <!DOCTYPE html>
    <html>
        <body>
            <div class="box">
                    <iframe src="https://open.spotify.com/embed/user/radomer/playlist/4S4lTBokwOjIvEHkz3klTj" width="100%" height="500" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
            </div>
            <div class="box">
                <iframe src="https://open.spotify.com/embed/user/radomer/playlist/4S4lTBokwOjIvEHkz3klTj" width="100%" height="500" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
            </div>    
        </body>
    </html
    2 回复  |  直到 6 年前
        1
  •  0
  •   Gayantha    6 年前

    让它浮动将解决问题。请参阅 .盒子

    body{
        background:#0d3852;
        margin:0;
        padding:0;
    }
    iframe{
        background:#ccc;
        border:0;
        margin:0;
        padding:0;
    }
    .box { 
        margin:0;
        padding:0;
        float : left;
        width:50%;
    }
    <!DOCTYPE html>
    <html>
        <body>
            <div class="box">
                    <iframe src="https://open.spotify.com/embed/user/radomer/playlist/4S4lTBokwOjIvEHkz3klTj" width="100%" height="500" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
            </div>
            <div class="box">
                <iframe src="https://www.sheldonbrown.com/web_sample1.html" width="100%" height="500" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
            </div>    
        </body>
    </html
        2
  •  1
  •   Vikas Jadhav    6 年前

    使用 display:flex; 而不是 display:inline-block;

    body {
      background: #0d3852;
      margin: 0;
      padding: 0;
    }
    
    iframe {
      background: #ccc;
      border: 0;
      margin: 0;
      padding: 0;
    }
    
    .box {
      margin: 0;
      padding: 0;
      display: flex;
      width: 49.77%;
    }
    <!DOCTYPE html>
    <html>
    
    <body>
      <div class="box">
        <iframe src="https://open.spotify.com/embed/user/radomer/playlist/4S4lTBokwOjIvEHkz3klTj" width="100%" height="500" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
      </div>
      <div class="box">
        <iframe src="https://open.spotify.com/embed/user/radomer/playlist/4S4lTBokwOjIvEHkz3klTj" width="100%" height="500" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>
      </div>
    </body>
    </html