【问题标题】:I'm trying to add style properties within <style> tags, but it just shows up as text on my page我正在尝试在 <style> 标记中添加样式属性,但它只是在我的页面上显示为文本
【发布时间】:2017-01-19 22:44:12
【问题描述】:

我正在尝试在&lt;style&gt; 标记中添加样式属性,但它只是在我的页面上显示为文本。我正在使用方括号,它通常会选择样式属性,所以我假设我的代码是错误的。

<style> body {background-image: url(pix/background.gif); } </style>

【问题讨论】:

  • 将 type="text/css" 添加到样式标签可能会有所不同
  • 您是在尝试将其添加到正文还是标题中?将它放在正文中可能会导致它在您的页面上显示为文本。样式标签应位于 html 代码顶部附近的 head 标签之间。
  • 如果您使用的是 Adob​​e Brackets,请更新您的标签。

标签: html styles


【解决方案1】:

尝试将&lt;style&gt;&lt;/style&gt; 标签添加到 HTML 页面的标题中,在标题标签之间

<head> 
<style> 
body {background-image: url(pix/background.gif); } 
</style>
</head>

如果 htat 不起作用,请验证您的文件编码,并确保它是 UTF8 以更好地与浏览器兼容。

【讨论】:

    猜你喜欢
    • 2021-02-10
    • 2021-03-14
    • 2014-03-26
    • 1970-01-01
    • 1970-01-01
    • 2020-07-01
    • 1970-01-01
    • 2016-01-30
    • 2017-04-06
    相关资源
    最近更新 更多