css - 背景图像没有显示css
问题描述
我正在尝试在我的 Vue 项目中使用响应式全屏图像背景,但无法显示图像,并且不确定出了什么问题,我看到的大多数示例在我的代码示例中都使用了 css
<template>
<div id="myDiv">
</div>
</template>
<script>
</script>
<style scoped>
#myDiv {
/*background: url('../../Images/Toronto.jpg');*/
background: url('https://images.pexels.com/photos/374870/pexels-photo-374870.jpeg?auto=compress&cs=tinysrgb&dpr=3&h=750&w=1260');
height: 100%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
解决方案
HTML 和 body 标签需要有min-height: 100%
.
如果你不能这样做,其他选择是申请min-height: 100vh
和min-width: 100vw
.
推荐阅读
- reactjs - React-Transition-Group 在添加 *-enter 类之前添加延迟
- vb6 - 正在删除第一个列表项而不是选定项
- wordpress - 如何更改 .html 格式的 WordPress 帖子永久链接结构?
- reactjs - 计数器应用程序中的重置计数功能未将计数设置为 0
- c# - 使用 AngularJS 请求调用 WebMethod 时没有被触发
- android - 通过 Room db 中的回调创建触发器后,未创建触发器
- python - 如何绕过 TensorFlow 中的部分(但不是全部)功能的神经网络
- postgresql - 是否可以从 WAL 中恢复 db 两次?
- objective-c - playerItemDidReachEnd 移动到错误的 ViewController
- css - 如何微调列表项目符号/编号的位置