即使在将frameborder设置为0之后,iframe边框周围仍然存在空白区域

时间:2010-10-26 08:48:22

标签: html css iframe whitespace

甚至在将iframe中的frameborder属性设置为0后,iframe边框周围仍然存在一些空白区域(与原始网址/链接页面不同)。有没有其他方法摆脱白色空间或iframe周围必须呈现一些白色,因为它在网页(或其中的一部分)内,它不能是整个页面?谢谢。

8 个答案:

答案 0 :(得分:11)

也许这个空格实际上是<iframe>中加载的文档的外边距。尝试使用以下方式设置已加载文档的样式:

html, body {
    border: 0px;
    margin: 0px;
    padding: 0px;
}

答案 1 :(得分:5)

将以下内容应用于iframe

display: block

答案 2 :(得分:1)

试试这个:

  <iframe bgcolor=#FFFFFF frameborder=0 vspace=0 hspace=0 marginwidth=0 marginheight=0 width=100%
   height="340" 
   src="myframe.html">
 </iframe>

答案 3 :(得分:1)

通过添加此CSS,我们可以全屏制作iframe

body,html
{
    background-color:#DDEEDD;
    padding:0px;
    margin:0px;
    height:100%;
    width:100%;
    overflow:hidden;
}
iframe
{
    margin:0;
    padding:0;
    border:none;
    overflow:hidden;
    background-color:#DDEEDD;
}

答案 4 :(得分:0)

只需在style="margin: 0 0 0 0"标记内添加 <iframe >

示例:

<iframe src="http://www.yahoo.com" style="margin: 0 0 0 0"></iframe>

如果您想要保证金,您必须在数字

后添加'px'

(感谢Safari浏览器的“Inspect Element”工具)这解决了我的解决方案。

答案 5 :(得分:0)

Frederic的建议解决了我的问题:如何在Safari浏览器的全屏幻灯片中摆脱白色边框。完善!非常感谢,wimsch [因为我无法对他的答案添加评论[[&lt; 50]]:我把它放在这里让他知道我的感激]

答案 6 :(得分:0)

试试这个

    public class StartStopActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_start_stop);
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON);
        Button returnButton = (Button) findViewById(R.id.button3);
        returnButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                moveTaskToBack(true);
            }
        });
        //returnButton.performClick();


    }

    @Override
    protected void onDestroy() {
        super.onDestroy();


    }
}

答案 7 :(得分:0)

我遇到了类似的问题:我在figure标记内嵌入了iframe,iframe和figcaption元素之间有一些空格。

<figure>
  <iframe></iframe>
  <!-- white space was here -->
  <figcaption></figcaption>
</figure>

在我的情况下,只需添加iframe { display:block }即可解决问题。