vue设置页面背景及背景图片简单示例
更新时间:2023年08月11日 11:43:39 作者:liyinchi1988
这篇文章主要给大家介绍了关于vue设置页面背景及背景图片的相关资料,在Vue项目开发中我们经常要向页面中添加背景图片,文中通过代码示例介绍的非常详细,需要的朋友可以参考下
本地静态图片
<template>
<view class="max">
<image src="../../static/bg.png" mode=""></image>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.max{
image{
z-index:-1;
width:100%;
height:100%;
position: fixed;
top:0;
}
}
</style>cdn图片
<template>
<view class="">
<view class="max">
<image
src="https://vkceyugu.cdn.bspapp.com/VKCEYUGU-59f27697-00c5-4f1e-8c67-bb56e1e19e78/653c2495-cb7b-49a7-b6cb-f048e16fa5a7.jpg"
mode=""
></image>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.max{
image{
z-index:-1;
width:100%;
height:100%;
position: fixed;
top:0;
}
}
</style>设置背景色
<template>
<view class="container"> //最外层
<view class="bg-colore"></view> //此标签为最外层view标签的第一个子标签
<view class="content"></view>
</view>
</template>
<script>
</script>
</style>
.bg-colore{
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: #f4f4f4;
z-index: -1;
}
<style>实战-PC web登录页

实战-小程序登录页
<template>
<view class="container">
<image class="bg-img" :src="imgSrc"></image>
<view class="content"></view>
</view>
</template>
<script>
export default {
name: "index",
data() {
return {
imgSrc: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-59f27697-00c5-4f1e-8c67-bb56e1e19e78/653c2495-cb7b-49a7-b6cb-f048e16fa5a7.jpg',
}
}
}
</script>
<style>
.bg-img {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: -1;
}
</style>
总结
到此这篇关于vue设置页面背景及背景图片的文章就介绍到这了,更多相关vue设置页面背景及图片内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
vue3使用vue-i18n的方法详解(ts中使用$t, vue3不用this)
所谓的vue-i18n国际化方案就是根据它的规则自己建立一套语言字典,对于每一个字(message)都有一个统一的标识符,下面这篇文章主要给大家介绍了关于vue3使用vue-i18n(ts中使用$t, vue3不用this)的相关资料,需要的朋友可以参考下2022-12-12
使用WebStorm导入已有Vue项目并运行的详细步骤与注意事项
这篇文章主要介绍了如何使用WebStorm导入、运行和管理Vue项目,包括环境配置、Node.js和npm版本管理、项目依赖管理以及常见问题的解决方案,文中通过代码介绍的非常详细,需要的朋友可以参考下2024-11-11
Vue+ElementUI踩坑之动态显示/隐藏表格的列el-table-column问题
这篇文章主要介绍了Vue+ElementUI踩坑之动态显示/隐藏表格的列el-table-column问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2023-11-11
Vue编译器源码分析compileToFunctions作用详解
这篇文章主要为大家介绍了Vue编译器源码分析compileToFunctions作用详解,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪2022-07-07


最新评论