Iframe是我唯一的选择吗?

cyg*_*ggi 1 html iframe

我有一份工作来开发一个网站.我的客户想要它,以便有一个标题,菜单和内容一个类似矩形的框,您可以在其中滚动文本.因此标题和菜单不会移动,但框中的文本会移动.

它应该如下所示:

***********header image ***********
menu menu menu menu

--------------
| you       ||
| can       || 
| scroll in ||
| this box  ||
|_____________
Run Code Online (Sandbox Code Playgroud)
  • 我唯一的选择是实现这个iframe吗?
  • 使用iframe是不好的做法?

Bar*_*der 9

不,去DIV:

<div id="iframeReplacement">
  <p>CONTENT GOES HERE :)</p>
</div>
Run Code Online (Sandbox Code Playgroud)

使用CSS:

#iframeReplacement {
  height: 400px; /* set to your height */
  width: 400px; /* set to your width */
  overflow-x: auto; /* can be auto, scroll or hidden */
  overflow-y: auto; 
}
Run Code Online (Sandbox Code Playgroud)


che*_*vim 5

你可以使用一个div,它具有指定的widthheightcss值为overflowto auto.

使用iframe执行此操作在以下方面具有过度杀伤力:

  • 客户端性能(更多http请求)
  • 服务器端带宽
  • 增加网站的复杂性和维护