简体   繁体   English

将加载的内容限制为div

[英]Restrict loaded content to a div

I have a page that is basically this: 我有一个基本上是这样的页面:

<div id="thelist" style="height:100%; width:100%; position:relative"></div>

<script type="text/javascript">
  $('#thelist').load('other.aspx', function () { });
</script>

The problem is this: When the content is loaded, it expands outside the boundaries of the div and into surrounding controls. 问题是这样的:加载内容时,它会扩展到div的边界之外并扩展到周围的控件中。 Is there a way to restrict this content to the div and just have the div scroll to include all the contents? 有没有一种方法可以将此内容限制为div,仅使div滚动显示所有内容? Thanks. 谢谢。

Yes, you should be able to do this with the css overflow property setting it to either auto or scroll . 是的,您应该可以通过将css overflow属性设置为autoscroll来执行此操作。
Here's a good article detailing the ins and out and here is the w3c specification . 这是一篇很好的文章,详细介绍了内容,这是w3c规范

I would just set the div element's overflow to hidden as a style 我只是将div元素的溢出设置为隐藏为样式

div#thelist {
    overflow: hidden;
}
<div id="thelist" style="height:100%; width:100%;
position:relative; overflow:auto/scroll"></div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM