0

I have an iframe and with it a body and a div

 <iframe name="myiframe">
    <html><head></head>
    <body>
    <div style="width: 100%;">This is my test text</div>
    </body>
    </html>
 </iframe>

The iframe has specific width. Let's say 100px. And the div get the 100% of it. The problem is that the text I have in the div is not all visible. I can see only what fits to 100px and the rest is hidden, while I want it to split into two lines in case is not fit.

Does anyone know how I can do that?

Thanks in advance

4

1 回答 1

0

首先,请注意身体不应该在头部(如您的示例所示)。

接下来,我相信 iframe 中的文本是浏览器不支持 iframe 时查看的内容。要正确使用 iframe,您必须将 html 保存到单独的文件中并使用 src 属性将文件加载到框架中。

像这样的东西应该工作:

page1.html

<html>
<head></head>
<body>
    <iframe src="page2.html">
        <p>Your browser does not support iframes.</p>
    </iframe>
</body>
</html>

page2.html

<html>
<head></head>
<body>
<div style="width: 100%;">This is my test text</div>
</body>
</html>

有关更多信息,请查看 W3Schools:

于 2012-08-17T13:30:45.300 回答