【问题标题】:background property issue后台属性问题
【发布时间】:2023-02-10 01:20:30
【问题描述】:

我的后台输出没有按预期出现。

我期待这个

只有我使用的代码是带有外部 css 和空 body 标签的 html <body></body> CSS代码是:

body{ background: linear-gradient(to bottom right, red, blue); }

但输出是这样的。

【问题讨论】:

  • 这与 chrome 完美配合。
  • 好的,它不适用于勇敢吗?
  • 我猜你有一个没有内容(因此没有高度)的body,你试过在那个元素上设置一个height(或min-height)吗?
  • 不,<body> 是空的,没有其他方法不使用任何特定高度和空内容

标签: html css


【解决方案1】:

我无法检测到任何问题,因为您写的是&lt;body&gt;&lt;/boyd&gt;而不是&lt;body&gt;&lt;/body&gt;

【讨论】:

  • 对不起,我的错误,但代码是正确的我在发布时犯了错误,但代码格式正确。
【解决方案2】:

如果你的 body 没有内容,它就没有高度,渐变将显示为一条小线(基于 body 元素上的默认填充)并默认重复。您可以通过像这样禁用重复来查看正在重复的内容:

body {
  background: linear-gradient(to bottom right, red, blue);
  background-repeat: no-repeat;
}

要解决此问题,请在正文中添加 min-height

body {
  background: linear-gradient(to bottom right, red, blue);
  min-height: 100vh;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-01-13
    • 2020-04-10
    • 2013-12-19
    • 2012-10-16
    • 1970-01-01
    • 1970-01-01
    • 2010-10-18
    • 1970-01-01
    相关资源
    最近更新 更多