python - 如何在固定的背景图像下方滚动
问题描述
我对 html 和 css 真的很陌生,所以如果问题听起来很基本,请原谅。
我想要实现的是我在页面顶部固定了一个背景图像。我希望一切都在这个背景图像下方滚动。bg 的代码是
def set_png_as_page_bg(png_file):
bin_str = get_base64_of_bin_file(png_file)
page_bg_img = '''
<style>
.stApp {
background-image: url("data:image/png;base64,%s");
background-size: contain;
background-repeat: no-repeat;
background-attachment: scroll;
}
</style>
''' % bin_str
st.markdown(page_bg_img, unsafe_allow_html=True)
return
但是,我希望文本在图像下方滚动。有一个简单的技巧吗?如果有人可以为这个问题提供资源,我也将不胜感激。
P:S: 我也试过 '''background-attachment: scroll''' 但背景不随内容滚动。
解决方案
你有没有尝试过
<style>
.stApp {
background-image: url("data:image/png;base64,%s");
background-size: contain;
background-repeat: no-repeat;
background-attachment: fixed;
overflow-y: scroll;
}
</style>
并设定高度?
推荐阅读
- ubuntu-18.04 - wxPython 安装失败
- c++ - 派生传递给超级移动构造函数
- python - Scrapy 使用 getall() 获取 xPath 属性
- git - 在 git 上设置 umask 权限新分支
- c# - T4 模板在构建期间未转换
- .net - 是否有可能以及如何从 dotnet 4.6 应用程序使用 Grpc.Core 并在没有身份验证的情况下使用 https
- reactjs - 如何导入material-ui组件?
- html - 如何在 Emacs 的 Org 模式下在 Source Block 的“#+RESULTS”预览输出周围添加“#+ATTR_HTML”?
- javascript - 如何在 React 中重新加载表中的数据
- azure - Azure VMSS 自定义脚本扩展错误 - 无法下载脚本文件