html - Background image won't show via URL (HTML & CSS)
问题描述
So I had been watching tutorials on how to code with html, and I succeeded at first with the whole background-image: url('somePicture.jpg'); but my issue now is that it doesn't show up at all. I've been learning all week last week but over the weekend I took a break and now I come back to my office and I ruined everything. Here's what I have now:
body{
font-family: 'Syne', serif;
}
#help{
color: purple;
}
.what{
font-weight: bold;
}
section{
border: solid 5px purple;
padding: 20px 5px 10px 5px;
margin: 0px auto 0px auto;
width: 500px;
}
main{
background-image: rgb(59, 59, 187) url("https://photographylife.com/wp-content/uploads/2017/05/img013-1200-copy.jpg") center/contain no-repeat;
}
<!DOCTYPE html>
<html>
<head>
<link href="https://fonts.googleapis.com/css2?family=Syne&display=swap" rel="stylesheet">
<link rel="stylesheet" href="Christ.css">
<title>
Wow
</title>
</head>
<body>
<main>
<section>
<h1 id="help">Oh.</h1>
<p class="what">Hello, I exist. This is text. Welcome.</p>
</section>
</main>
</body>
</html>
解决方案
I think the property you've gotten confused between the background
property and background-image
property. I just changed the CSS code to use background
instead of background-image
and it works expectedly.
推荐阅读
- .net - 如何在 Blazor Server 应用程序中获取引荐网站
- python - 曲线拟合 - 有没有办法更加重视曲线拟合的后端?
- javascript - 在使用内联编辑器实现的 DialogFlow Messenger 中,setContext() 干扰 setFollowupEvent()
- javascript - Chart.js 如何创建带有可点击按钮的动态工具提示
- visual-studio-code - Visual Studio Code:如何在视图容器中添加复选框
- r - 将数据框边缘列表转换为矩阵,同时保留行名和列名
- google-api - Youtube API 的 Google API 配额限制
- arrays - 在 Julia 的同心球体中取两个区间的数字
- google-kubernetes-engine - 创建 nginx-ingress 控制器后无法创建 Ingress
- sql - 在 Where 语句中执行 SQL 查询时出现错误消息