最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to set up toolbar to be fixed in vuetify? - Stack Overflow

programmeradmin3浏览0评论

In vuetify I use a toolbar

    <v-toolbar dark color="primary">
        <v-toolbar-side-icon @click.stop="drawer.drawer = !drawer.drawer"></v-toolbar-side-icon>
        <v-toolbar-title>{{drawer.title}}</v-toolbar-title>
    </v-toolbar>
    <router-view v-bind:page="pageData"></router-view>

But I want to make it fixed, and not overlap with the vuerouter contents. How can I do that? I tried putting fixed but it still overlaps.

Thanks

In vuetify I use a toolbar

    <v-toolbar dark color="primary">
        <v-toolbar-side-icon @click.stop="drawer.drawer = !drawer.drawer"></v-toolbar-side-icon>
        <v-toolbar-title>{{drawer.title}}</v-toolbar-title>
    </v-toolbar>
    <router-view v-bind:page="pageData"></router-view>

But I want to make it fixed, and not overlap with the vuerouter contents. How can I do that? I tried putting fixed but it still overlaps.

Thanks

Share Improve this question asked Nov 8, 2018 at 23:31 omegaomega 43.8k89 gold badges282 silver badges520 bronze badges 3
  • 1 could you provide a screenshot of what you're getting? – Boussadjra Brahim Commented Nov 9, 2018 at 0:13
  • 1 fixed it with this codepen.io/anon/pen/boxqwY – omega Commented Nov 9, 2018 at 0:14
  • The codepen code is not loading properly. It must be a mistake with the code @omega – largoWinch Commented Jun 2, 2022 at 17:42
Add a comment  | 

4 Answers 4

Reset to default 8

Since version 2.0.0 v-toolbar isn't fixable use v-app-bar https://vuetifyjs.com/en/components/app-bars

Use css arguments in style tags. Cf.) https://journal.simondepelchin.be/2019/03/04/how-to-make-a-sticky-tabs-bar-with-vuetify/

<template>
  <v-toolbar class="fixed-bar">
    <!-- ... -->
  </v-toolbar>
</template>


<style scoped>
.fixed-bar {
  position: sticky;
  position: -webkit-sticky; /* for Safari */
  top: 6em;
  z-index: 2;
}
</style>
  1. Add the app attribute to the toolbar
  2. Put your router outlet content inside a v-content element.
  3. Finally, make sure the whole shebang is inside a v-app element.

Use app-bar outside from router-view Use this example https://vuetifyjs.com/en/components/application/#application

<!-- App.vue -->

<v-app>
  <v-navigation-drawer app>
    <!-- -->
  </v-navigation-drawer>

  <v-app-bar app>
    <!-- -->
  </v-app-bar>

  <!-- Sizes your content based upon application components -->
  <v-content>

    <!-- Provides the application the proper gutter -->
    <v-container fluid>

      <!-- If using vue-router -->
      <router-view></router-view>
    </v-container>
  </v-content>

  <v-footer app>
    <!-- -->
  </v-footer>
</v-app>

发布评论

评论列表(0)

  1. 暂无评论