vue頁面右下角添加懸浮按鈕組件的方法代碼
效果圖:



如上圖所示,需要在頁面的左下角添加一個懸浮按鈕,鼠標(biāo)放上去時候展示更多詳細(xì)按鈕,點(diǎn)擊觸發(fā)相應(yīng)方法。
<div class="floating-component">
<!-- 懸浮內(nèi)容 -->
<el-tooltip placement="left" effect="light" popper-class="too">
<div slot="content">
<el-button icon="el-icon-s-comment" class="butto" @click="handleQuestion">問題反饋 </el-button>
<br/>
<el-button icon="el-icon-question" class="butto" @click="handleHelp">幫助手冊 </el-button>
</div>
<el-button icon="el-icon-menu" circle class="but"></el-button>
</el-tooltip>
</div><style scoped>
.floating-component {
position: fixed; /* 固定位置 */
bottom: 5%; /* 下邊距 */
right: 1%; /* 右邊距 */
padding: 0;
border-radius: 50%; /* 圓角 */
z-index: 10000; /* 設(shè)置 z-index 確保懸浮在頂層 */
}
.but {
font-size: larger;
color: rgb(0,119,216);
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2); /* 陰影 */
}
.butto {
border: 0;
padding: 10px;
margin: 0;
}
</style>
<style>
.too.el-tooltip__popper.is-light {
border: none !important;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.2);
padding: 5px
}
/* 修改箭頭邊框 這里方位是left,所以 x-placement^="left" 并且是設(shè)置 border-right-color 的顏色*/
.too.el-tooltip__popper.is-light[x-placement^="left"] .popper__arrow {
border-left-color: #eaeaea !important;
}
.too.el-tooltip__popper[x-placement^="left"] .popper__arrow {
border-left-color: #eaeaea !important;
}
</style>如果需要在所有頁面上層展示,在vue項目的頂層路由文件中添加即可。
總結(jié)
到此這篇關(guān)于vue頁面右下角添加懸浮按鈕組件的文章就介紹到這了,更多相關(guān)vue右下角添加懸浮按鈕組件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
在vue中實現(xiàn)點(diǎn)擊選擇框阻止彈出層消失的方法
今天小編就為大家分享一篇在vue中實現(xiàn)點(diǎn)擊選擇框阻止彈出層消失的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-09-09
Vue-admin-template?報Uncaught?(in?promise)?error問題及解決
這篇文章主要介紹了Vue-admin-template?報Uncaught?(in?promise)?error問題及解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-07-07
vue-treeselect及el-tree點(diǎn)擊節(jié)點(diǎn)獲取上級節(jié)點(diǎn)的數(shù)據(jù)方式
這篇文章主要介紹了vue-treeselect及el-tree點(diǎn)擊節(jié)點(diǎn)獲取上級節(jié)點(diǎn)的數(shù)據(jù)方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-07-07

