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

javascript - VuetifyJS toolbar overlays content as soon as fixed prop gets added - Stack Overflow

programmeradmin5浏览0评论

I need to use a fixed toolbar (with an extension). Problem is that The toolbar overlays the content as soon as the fixed prop gets added. How to place the content below the toolbar? CodePen example: ?&editors=101

<div id="app">
  <v-app id="inspire">
    <v-toolbar
      color="primary"
      dark
      fixed
      extended         
    >
      <v-toolbar-side-icon></v-toolbar-side-icon>
      <v-toolbar-title slot="extension">Title</v-toolbar-title>
      <v-spacer></v-spacer>

      <v-btn icon>
        <v-icon>search</v-icon>
      </v-btn>
    </v-toolbar>

    <v-layout>
    <v-flex xs1 >
      +++ FIRST LINE +++ 
      [lots of text...]
      </v-flex>
        </v-layout>
  </v-app>
</div>

I need to use a fixed toolbar (with an extension). Problem is that The toolbar overlays the content as soon as the fixed prop gets added. How to place the content below the toolbar? CodePen example: https://codepen.io/anon/pen/jpgjyd?&editors=101

<div id="app">
  <v-app id="inspire">
    <v-toolbar
      color="primary"
      dark
      fixed
      extended         
    >
      <v-toolbar-side-icon></v-toolbar-side-icon>
      <v-toolbar-title slot="extension">Title</v-toolbar-title>
      <v-spacer></v-spacer>

      <v-btn icon>
        <v-icon>search</v-icon>
      </v-btn>
    </v-toolbar>

    <v-layout>
    <v-flex xs1 >
      +++ FIRST LINE +++ 
      [lots of text...]
      </v-flex>
        </v-layout>
  </v-app>
</div>
Share Improve this question edited Aug 18, 2018 at 9:47 Tom asked Aug 17, 2018 at 21:11 TomTom 6,00421 gold badges85 silver badges134 bronze badges 1
  • Your only requirement is that the toolbar is always stuck to the top of the viewport? – sjahan Commented Aug 20, 2018 at 9:40
Add a ment  | 

3 Answers 3

Reset to default 15 +50

One solution is adding app to v-toolbar and wrap v-layout inside v-content

<v-toolbar
      app
      color="primary"
      dark
      fixed
      extended         
    >
...
</v-toolbar>
<v-content>
  <v-layout>
  </v-layout>
</v-content>

Demo https://codepen.io/ittus/pen/mGdbeN?editors=1010

References: Vuetify application layout tutorial

Add app to v-toolbar and wrap v-layout inside v-content

Couldn't get exactly your question, is this what you wanted to achieve:

new Vue({
  el: '#app',
  mounted(){
    var fixedElement = document.getElementsByClassName('v-toolbar--fixed')[0];
    var layout = document.getElementsByClassName('layout')[0];
    layout.style = "padding-top: "+ fixedElement.offsetHeight + 'px'; 
  }
});

https://codepen.io/Younes_k/pen/LJEjOL

发布评论

评论列表(0)

  1. 暂无评论