python - 如何在 CSS 中为烧瓶应用程序链接英雄图像
问题描述
我正在尝试在我的烧瓶应用页面上添加一个英雄图像。以下是我的烧瓶项目的目录结构。
-static
|--css_files
|--my.css
|--images
|--img.jpg
-templates
|--layout.html
现在,为了添加英雄形象,我HTML
在layout.html
-
<div class="hero-image">
<div class="hero-text">
<h1>My Heading</h1>
<p>Some paragraph</p>
</div>
</div>
要添加样式,我CSS
在my.css
-
.hero-image {
background-image: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url({{ url_for('static',filename='images/img.jpg') }});
/* Set a specific height */
height: 50%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
但是,我只能看到hero-text
而不是图像。我怎样才能将它链接img.jpg
到my.css
?
我也尝试了绝对路径,backgrouond: url('/static/images/img.jpg')
但没有奏效。
解决方案
像这样更改网址
background:url('../static/images/img.jpg') ;
推荐阅读
- julia - Machine中X的scitype与模型不兼容
- google-sheets - 每 60 秒将 Google 电子表格数据更新为 Discord 嵌入消息
- c# - OpenSsl 在 Windows 操作系统的 Visual Studio 中可用吗?
- c++ - 将值放入 std::vector 中的空位置
- php - 在管理产品常规框中获取 WooCommerce 产品变体属性术语
- php - 显示 WooCommerce 产品价格的自定义简码:显示零价格文本
- c# - 寻找一种方法来避免应用程序授权上的 IP 欺骗
- javascript - 例外:发送电子邮件失败:没有收件人,不知道出了什么问题
- powerbi - Power Query - 会计月开始和结束日期
- r - 如何通过R中的多列计算逻辑值?