How do I center an iframe?

This question already has an answer here:

  • How to horizontally center a <div> in another <div>? 82 answers

  • http://codepen.io/mlegg10/pen/zqLdJy改变CSS填充顶部和底部以满足您的需求

    /* Flexible iFrame */
    
    .Flexible-container {
      position: relative;
      padding-bottom: 56.25%;
      padding-top: 30px;
      height: 0;
      overflow: hidden;
    }
    .Flexible-container iframe,
    .Flexible-container object,
    .Flexible-container embed {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }
    <!-- Responsive iFrame -->
    <div class="flexible-container">
      <object width="100%" data=""https://drive.google.com/file/d/0BxrMaW3xINrsR3h2cWx0OUlwRms/preview"&amp;toolbar=0&amp;navpanes=0" type="application/pdf">
          <embed width="100%" type="application/pdf" src="https://drive.google.com/file/d/0BxrMaW3xINrsR3h2cWx0OUlwRms/preview"?scrollbar=0&amp;toolbar=0&amp;navpanes=0">
        </object>
    </div>

    display:block + margin:auto;

    iframe {
      display:block;
      margin:auto;
    }
    <iframe></iframe>
    链接地址: http://www.djcxy.com/p/13212.html

    上一篇: 如何使用CSS将<div>标签居中?

    下一篇: 我如何居中一个iframe?