你可以使用CSS来显示HTML中的背景。

huangapple go评论64阅读模式
英文:

How can i display my background in html using css?

问题

<!DOCTYPE html>
<html>
    <head>
        <title>StockAdi</title>
        <link rel="stylesheet" href="style.css">
    </head>
    <body>
        <img src="logo.jpg" alt="Cafe Adi" width="175" height="175">
        <h1>StockAdi</h1>
    </body>
</html>
body {
    background: linear-gradient(to left, #C09B30, #ffffff);
}

Your HTML and CSS code appears to be correct. If the background isn't displaying as expected, please ensure that your CSS file ("style.css") is in the correct location and that there are no typos or errors in your CSS code. Also, make sure that the HTML file is linked to the CSS file properly.

英文:

*html
//

&lt;!DOCTYPE html&gt;
	&lt;html&gt;
		&lt;head&gt;
			&lt;title&gt; StockAdi &lt;/title&gt;
			&lt;link rel=&quot;stylesheet&quot; href=&quot;style.css&quot;&gt;
		&lt;/head&gt;
		&lt;body&gt;
			&lt;img src=&quot;logo.jpg&quot; alt=&quot;Cafe Adi&quot; width=&quot;175&quot; height=&quot;175&quot;&gt;
			&lt;h1&gt; StockAdi &lt;/h1&gt;
		&lt;/body&gt;
	&lt;/html&gt;	

//
*css

body{
    background: linear-gradient (to left, #C09B30, #ffffff);
}

here is my code in my project, but it seems that it won't display the background that i want. What can i do?

答案1

得分: 2

It's because you had an extra space behind linear-gradient, the syntax was invalid. Removing the space resolves your issue:

body {
  background: linear-gradient(to left, #C09B30, #ffffff);
}
<!DOCTYPE html>
<html>
  <body>
    <img src="logo.jpg" alt="Cafe Adi" width="175" height="175">
    <h1>StockAdi</h1>
  </body>
</html>
英文:

It's because you had an extra space behind linear-gradient, the syntax was invalid. Removing the space resolves your issue:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

body {
  background: linear-gradient(to left, #C09B30, #ffffff);
}

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;body&gt;
    &lt;img src=&quot;logo.jpg&quot; alt=&quot;Cafe Adi&quot; width=&quot;175&quot; height=&quot;175&quot;&gt;
    &lt;h1&gt; StockAdi &lt;/h1&gt;
  &lt;/body&gt;
&lt;/html&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年5月13日 22:12:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76243168.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定