【问题标题】:How to apply css when including html file包含html文件时如何应用css
【发布时间】:2018-09-18 22:28:14
【问题描述】:

我有一个仅包含菜单的 html 文件,并使用 embed 标签将其包含在我的 html 页面中:

<embed type="text/html" src="menu.html">

如何将 css 类应用于包含的代码?我尝试将其添加到 menu.html 文件中,但没有成功

【问题讨论】:

  • 你可以在menu.html里面写内联或者内部css

标签: css


【解决方案1】:

embed标签隔离了源文件,所以父页面中的CSS不会级联到embed元素中。

您必须在 menu.html 文件中加载 CSS 文件,才能将其应用于该文件中的内容。

【讨论】:

  • 我试过了,但是加载的文档被从任何 css 中删除了
  • @CodingDuchess 你能看到运行时加载的css吗menu.html
  • 我在嵌入文档的 部分看到对 css 文件的引用
【解决方案2】:

在 menu.html 文件中尝试内联 CSS 类。

【讨论】:

    【解决方案3】:

    解决了问题 - 我需要设置嵌入标签的宽度才能看到整个内容,因为默认情况下宽度不允许我看到整个文件

    【讨论】:

      猜你喜欢
      • 2020-11-17
      • 2022-07-12
      • 2017-08-06
      • 2016-07-08
      • 1970-01-01
      • 2018-01-03
      • 1970-01-01
      • 2015-05-11
      • 1970-01-01
      相关资源
      最近更新 更多