如何使对象标签内的PDF响应?

时间:2014-03-12 00:44:14

标签: html css

我正在尝试让我的网站做出响应,我在身体中的对象标签中有一个PDF查看器,就像这样:

<object width="950" height="800" data="images/ah.pdf"></object>

由于定义了宽度和高度,我将其更改为:

<div id="custom">
<object data="images/ah.pdf"></object>
</div>

然后使用百分比调整css部分中的div。我的问题是整个PDF查看器没有显示,而是一个侧面有滚动条的小盒子,所以你必须向左和向上滚动。我有什么方法可以根据窗口大小来调整PDF大小,而不是仅仅调整PDF查看器?我希望这一点尽可能清楚。谢谢!

2 个答案:

答案 0 :(得分:4)

将您的对象标记更改为:

<object data="images/ah.pdf" style="width: 100%; height: 100%; display: block;"></object>

您可以将样式添加到类中,然后在对象标记中包含该类。或者使用其他变体来应用样式。宽度和高度将与其父容器的大小相同。

答案 1 :(得分:4)

@Adam答案可能有用。老实说,我不会处理太多/ BUt我会告诉你我已经为显示设置了iframe并且它们具有响应兼容性

这就是我要做的事情

<div class="content">
    <div class="embed-container">
        <iframe src="/images/myPDF.pdf" frameborder="0"></iframe>
    </div>
</div>

.content {
   width: 50%;
   margin: 0px auto;
}

.embed-container {
   height: 0;
   width: 100%;
   padding-bottom: 56.25%; /* play with this until right */
   overflow: hidden;
   position: relative;
}

.embed-container iframe {
   width: 100%;
   height: 100%;
   position: absolute;
   top: 0;
   left: 0;
}
相关问题