<template>
<div id="logo">
</div>
</template>
<script>
import meadiaurl from '../../api/mediaurl'
export default {
name: "logo"
</script>
<style scoped>
#logo{
background: url("../../assets/images/Login.png");
background-size: 100% 100%;
height: 100%;
}
</style>
如果像以上代码写,高度为100%时,会发现背景图片只是内容撑起来的,却不能使整个屏幕铺满背景图;
解决方案:
我们要让#logo脱离文档流,为他添加个fixed属性
#logo{
background: url("../../assets/images/Login.png");
background-size: 100% 100%;
height: 100%;
position: fixed;
width: 100%
}
以上是本章全部内容
本文介绍了一个常见的网页设计问题,即当背景图片设置为100%高度时,图片仅填充内容区域而非整个屏幕。通过为元素添加fixed定位和100%宽度的解决方案,确保了背景图片能够完全覆盖屏幕。

被折叠的 条评论
为什么被折叠?



