vue設置頁面背景及背景圖片簡單示例
更新時間:2023年08月11日 11:43:39 作者:liyinchi1988
這篇文章主要給大家介紹了關于vue設置頁面背景及背景圖片的相關資料,在Vue項目開發(fā)中我們經常要向頁面中添加背景圖片,文中通過代碼示例介紹的非常詳細,需要的朋友可以參考下
本地靜態(tài)圖片
<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>
實戰(zhàn)-PC web登錄頁
實戰(zhàn)-小程序登錄頁
<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設置頁面背景及圖片內容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
vue3使用vue-i18n的方法詳解(ts中使用$t,?vue3不用this)
所謂的vue-i18n國際化方案就是根據(jù)它的規(guī)則自己建立一套語言字典,對于每一個字(message)都有一個統(tǒng)一的標識符,下面這篇文章主要給大家介紹了關于vue3使用vue-i18n(ts中使用$t,?vue3不用this)的相關資料,需要的朋友可以參考下2022-12-12Vue實現(xiàn)動態(tài)創(chuàng)建和刪除數(shù)據(jù)的方法
下面小編就為大家分享一篇Vue實現(xiàn)動態(tài)創(chuàng)建和刪除數(shù)據(jù)的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-03-03使用WebStorm導入已有Vue項目并運行的詳細步驟與注意事項
這篇文章主要介紹了如何使用WebStorm導入、運行和管理Vue項目,包括環(huán)境配置、Node.js和npm版本管理、項目依賴管理以及常見問題的解決方案,文中通過代碼介紹的非常詳細,需要的朋友可以參考下2024-11-11Vue+ElementUI踩坑之動態(tài)顯示/隱藏表格的列el-table-column問題
這篇文章主要介紹了Vue+ElementUI踩坑之動態(tài)顯示/隱藏表格的列el-table-column問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-11-11Vue編譯器源碼分析compileToFunctions作用詳解
這篇文章主要為大家介紹了Vue編譯器源碼分析compileToFunctions作用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2022-07-07基于vue+echarts數(shù)據(jù)可視化大屏展示的實現(xiàn)
這篇文章主要介紹了基于vue+echarts數(shù)據(jù)可視化大屏展示的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-12-12