html 中可根据窗口大小调整大小的 div 标签

发布于 2024-10-18 06:07:18 字数 283 浏览 4 评论 0原文

我的代码如下:

<div id="frame1" style="overflow-y: auto;overflow-x: auto;width:87.5%;height:100%;" >

content

</div>

这里声明 div 作为可滚动 div,但它不会根据窗口调整大小来调整大小。

我有一种情况,我需要在同一行上,当调整窗口大小并且 div 的 最终触摸,我需要它们不换行,而是启用水平和垂直滚动。

请帮忙...

My code is as below:

<div id="frame1" style="overflow-y: auto;overflow-x: auto;width:87.5%;height:100%;" >

content

</div>

Here declared div working as a scrollable div but it doesn't resize as per window resize.

I have a situation where I need, on the same line, When the window is resized and the div's
eventually touch, I need them NOT to wrap, but instead, enable the horizontal and vertical scrolling.

Please Help...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

韶华倾负 2024-10-25 06:07:18
<div id="frame1" style="display:block; width: 87.5%">

content

</div>

高度会根据内容增加

<div id="frame1" style="display:block; width: 87.5%">

content

</div>

Height will increase based on content

寄风 2024-10-25 06:07:18

不太确定你想在这里做什么。我猜你有 2 个 div,彼此相邻,并且你希望其中一个在空间对它们来说太小时开始滚动。如果您知道另一个 div 的宽度,您可以执行类似 right: *div width* 的操作,当宽度设置为 100 时,这将使“frame 1”div 填充其余空间%。然后,如果该 div 的内容对于该 div 来说太大,则应该出现滚动条。显然,您需要将位置值设置为 static 以外的值,以使顶部、右侧、底部或左侧 css 值产生影响。

我最近在一个有 3 个固定 div 的网站上使用了类似的东西;页眉、页脚和主要内容。对于内容,我将顶部设置为页眉的高度,将底部设置为页脚的高度,高度值设置为 100%。这使得内容填充页眉和页脚之间的空间。然后,我将内容的溢出 y 值设置为滚动,以便垂直滚动条始终可见,但它仅在内容上,因为页眉和页脚无论如何都不会滚动,这给出了非常好的效果,尤其是使用 webkit 滚动条。

再说一遍,我不太确定这是否是您所问的。网站临时链接此处 (resolution-gaming.comuf .com)。

Not quite sure what you are trying to do here. I'm guessing you have 2 div's next to each other and you want one of them to start scrolling when the space is too small for them both. If you know the width of the other div you could just do something like right: *div width* which would make the 'frame 1' div fill the rest of the space when the width was set to 100%. Then if the content of this div were too large for that div, scroll bars should appear. You would obviously need to set the position value to something other than static to get the top, right, bottom or left css values to have an affect.

I recently used something similar to this on a site with 3 fixed div's; a header, a footer and the main content. For the content, I have top set to the height of the header and bottom set to the height of the footer with a height value set at 100%. This makes the content fill the space between the header and footer. I then set the overflow-y value of the content to scroll so the vertical scroll bar is always visible but it is only on the content as the header and footer don't scroll anyway which gives a really nice effect, especially with webkit scroll bars.

Again, I'm not really sure if that was what you were asking. Temporary link to site here (resolution-gaming.comuf.com).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文