是否可以使用 CSS 以类似于框架的方式更新 HTML 页面的部分内容?

发布于 2024-08-13 05:52:40 字数 114 浏览 5 评论 0原文

是否可以使用 CSS 像框架一样工作?

我的意思是,当我们使用框架(例如左、右)时,单击左侧将使用“目标”属性仅刷新右侧部分。

可以用CSS来实现这种效果吗?

谢谢。

Is it possible to use CSS to work like frames?

What I mean is, when we use frames (left, right for example), clicking on left will refresh only the right section using the 'target' attribute.

Is it possible to create this effect with CSS?

Thanks.

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

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

发布评论

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

评论(4

死开点丶别碍眼 2024-08-20 05:52:41

不,这与 CSS 无关。 CSS 仅用于样式元素。您正在寻找的是 IFRAME。可以为 IFRAME 指定一个名称

<iframe name="my_iframe" src="xyz.htm"></ifram>

,然后将其定位到链接中。

No, this has nothing to do with CSS. CSS is for styling elements only. What you are looking for is an IFRAME. And IFRAME can be given a name

<iframe name="my_iframe" src="xyz.htm"></ifram>

and then be targeted in a link.

要走就滚别墨迹 2024-08-20 05:52:41

我的设计依赖于使用 CSS 的框架内容。您可以使用 overflow:auto 来完成此操作,但它不会执行您想要的操作,即加载页面的某些部分。为此,您需要使用一些 AJAX 库(例如 jQuery)来动态加载内容区域。这是相当危险的,因为您的 URL 可能与页面的当前内容无关。

I've got a design that relies on framed content using CSS. You can do this by using overflow:auto, however it won't do what you want, i.e. loading certain portions of a page. To do this you'd need to use some AJAX library such as jQuery to load the content area dynamically. This is quite dangerous though as your URL may not relate to the current content of the page.

瞄了个咪的 2024-08-20 05:52:41

你也许可以用 CSS 的溢出部分做一些事情。

如果你设置了一个带有overflow:auto的div,具有固定的宽度和高度,并且包含大量内容,你将得到滚动条。您可能可以使用锚点来移动内容以在 div 内查看。

这意味着您的所有内容都在一页中,并且只是随锚点移动。您也可以使用 jquery tabs 插件做类似的事情。

我从来没有尝试过这个,它可能需要 javascript 才能让它完全工作。

You could probably do something with the overflow part of CSS.

If you set up a div with overflow:auto with a fixed width and height with alot of content you will get scrollbars. Potentially you could use anchors to get content to move to be viewed within the div.

This means that all your content is in one page and it is just moved around with the anchors. You could do a similar thing using a jquery tabs plugin too.

I have never tried this and it might need javascript to get it to work fully.

旧夏天 2024-08-20 05:52:40

使用框架通常是一个坏主意

要回答你的问题,不,CSS 不能像框架一样工作。 CSS 用于更改 HTML 的样式,因此实际上不能更改页面的内容。它可用于隐藏内容,但我认为这不是您所需要的。

但是,我觉得在这种情况下您可能问了错误的问题。因为框架通常是错误的方法。

当开始网页设计时,框架似乎是一个好主意。您可以将导航与内容分开,您的网站将加载得更快,因为导航不会每次都加载,并且菜单始终可见,即使在页面加载时也是如此。

但是,实际上,框架对于您的可用性来说非常糟糕

  • 您的用户无法为单个页面
  • 添加书签 打印损坏
  • 浏览器中的标准功能(例如在新选项卡中打开)经常会损坏
  • 用户无法复制/粘贴特定页面的网址以发送给朋友

框架确实有其用途(例如 Google 图像搜索),但对于标准导航菜单,不建议使用它们。尝试使用动态服务器语言(例如 PHP 或 ASP.NET)创建页面。

这些语言可以在不使用框架的情况下创建标准元素(例如导航菜单)。

Using frames is usually a bad idea

To answer your question, no, CSS cannot be used to work like frames. CSS is used to changing the style of HTML and as such, cannot actually change the content of a page. It can be used to hide content, but I don't think that is what you require.

However, I feel in this case you may be asking the wrong question. As frames are usually the wrong approach.

When starting out in web design, frames seem like a great idea. You can seperate your navigation from your content, your site will load quicker because the navigation is not loaded every time and the menu is always visible, even when the page is loading.

But, actually, frames are incredibly bad for your usability.

  • Your users cannot bookmark individual pages
  • Printing is broken
  • Standard features in a browser like open in new tab often breaks
  • Users cannot copy/paste the web address for a specific page for sending to a friend

Frames do have their uses (e.g. Google image search), but for standard navigation menus they are not recommended. Try creating a page in a dynamic server language such as PHP or ASP.NET.

These languages have ways of creating standard elements such as your navigation menu without the use of frames.

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