我正在尝试在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;
}
答案 0 :(得分:1)
HTML和正文标记必须具有min-height: 100%
。
如果您无法执行此操作,则另一种选择是应用min-height: 100vh
和min-width: 100vw
。