已移至页脚的侧边。

huangapple go评论93阅读模式
英文:

<v-navigation-drawer> has come to the side of the footer

问题

我想动态设置我给一个元素设置的样式的高度值具体来说当滚动到底部时高度为77.5%当页脚元素完全不可见时高度为100%当页脚可见时我想从100%中减去高度

我尝试了各种方法但在handleScroll中无法很好地调整高度请让我知道是否有一种方法可以调整

.v-navigation-drawer {
  height: 77.5% !important;
}
当我将页脚放在v-main中时,它变成了如下所示。

<v-main>
  <v-container>
    <slot></slot>
    <NavigationLink />
    <v-footer
      border="t"
      style="position: absolute; left: 0; right: 0; z-index: 9999"
    >
      <v-row justify="center" no-gutters>
        <AppThemeToggle />
        <v-col
          class="primary lighten-2 py-4 text-center white--text"
          cols="12"
        >
          <strong>
            Copyright {{ new Date().getFullYear() }} vuetify Corporation
          </strong>
        </v-col>
      </v-row>
    </v-footer>
  </v-container>
</v-main>
如果导航内容覆盖了页脚,我想像下面的图片一样滚动它。
英文:

I would like to dynamically set the height value of a style that I set to an element. Specifically, when scrolling to the bottom, the height of the height is 77.5%, when the footer element is not visible at all, it is 100%, and when the footer is visible, it is the visible value I want to subtract the height from 100%.
I tried various things with handleScroll below, but I can't adjust the height well. Please let me know if there is a way to adjust

.v-navigation-drawer {
  height: 77.5% !important;
}

Below is the full code.

&lt;template&gt;
  &lt;v-app&gt;
    &lt;Header /&gt;
    &lt;!-- &lt;TableofContents /&gt; --&gt;
    &lt;v-navigation-drawer width=&quot;300&quot; border=&quot;r&quot; app&gt; test &lt;/v-navigation-drawer&gt;
    &lt;v-main&gt;
      &lt;v-container&gt;
        &lt;slot /&gt;
      &lt;/v-container&gt;
      &lt;NavigationLink /&gt;
    &lt;/v-main&gt;
    &lt;v-footer border=&quot;t&quot;&gt;
      &lt;v-row justify=&quot;center&quot; no-gutters&gt;
        &lt;AppThemeToggle /&gt;
        &lt;v-col class=&quot;primary lighten-2 py-4 text-center white--text&quot; cols=&quot;12&quot;&gt;
          &lt;strong
            &gt;Copyright {{ new Date().getFullYear() }} vuetify
            Corporation&lt;/strong
          &gt;
        &lt;/v-col&gt;
      &lt;/v-row&gt;
    &lt;/v-footer&gt;
  &lt;/v-app&gt;
&lt;/template&gt;

<v-navigation-drawer> 已移至页脚的侧边。

When I put the footer in v-main, it became as follows.

&lt;v-main&gt;
      &lt;v-container&gt;
        &lt;slot /&gt;
        &lt;NavigationLink /&gt;
        &lt;v-footer
          border=&quot;t&quot;
          style=&quot;position: absolute; left: 0; right: 0; z-index: 9999&quot;
        &gt;
          &lt;v-row justify=&quot;center&quot; no-gutters&gt;
            &lt;AppThemeToggle /&gt;
            &lt;v-col
              class=&quot;primary lighten-2 py-4 text-center white--text&quot;
              cols=&quot;12&quot;
            &gt;
              &lt;strong
                &gt;Copyright {{ new Date().getFullYear() }} vuetify
                Corporation&lt;/strong
              &gt;
            &lt;/v-col&gt;
          &lt;/v-row&gt;
        &lt;/v-footer&gt;
      &lt;/v-container&gt;
    &lt;/v-main&gt;

<v-navigation-drawer> 已移至页脚的侧边。

If the content of the navigation covers the footer, I would like to scroll it like the image below

<v-navigation-drawer> 已移至页脚的侧边。

答案1

得分: 2

如果我理解正确,您希望将导航栏放在页眉和页脚之间:

------------                ------------
|  header  |                |  header  |
------------                ------------ 
| n |      |                | n |      |
| a | main |    而不是       | a | main |
| v |      |                | v |      |
------------                |   |-------
|  footer  |                |   | foot |
------------                ------------

布局组件,如 VAppBar、VNavigationDrawer 或带有 :app 属性的 VFooter,根据它们声明的顺序来占用空间,除了 VMain,它总是占用剩余的空间。所以在上面的示例中,左边的顺序是 header-footer-nav,而右边的顺序是 header-nav-footer(与您的示例相同)。

所以,不要手动调整高度,只需更改元素的顺序:

<template>
  <v-app>
    <v-app-bar />
    <v-footer app> ... </v-footer>
    <v-navigation-drawer> ... </v-navigation-drawer>
    <v-main> ... </v-main>
  </v-app>
</template>

如果您希望页脚与主内容一起滚动,您不能使用 app 页脚,因为它固定在页面上。我认为还没有一种优雅的解决方案可以将页脚放在导航栏上方,但您可以将页脚放入 v-main 中并对其设置绝对位置:

<v-app>
  <v-app-bar>...</v-app-bar>
  <v-navigation-drawer>...</v-navigation-drawer>
  <v-main>
    ...
    <v-footer style="position: absolute; left: 0; right: 0; z-index: 9999;">...</v-footer>
  </v-main>
</v-app>

查看 playground

英文:

If I understand correctly, you want the navbar between header and footer:

------------                ------------
|  header  |                |  header  |
------------                ------------ 
| n |      |                | n |      |
| a | main |    instead of  | a | main |
| v |      |                | v |      |
------------                |   |-------
|  footer  |                |   | foot |
------------                ------------

Layout components like VAppBar, VNavigationDrawer or VFooter (with :app prop) work by claiming space in order they are declared, except for VMain, which will always claim the leftover space. So in above example, the left one has order header-footer-nav, while the right one has order header-nav-footer (same as your example).

So instead of manually adjusting height, just change the order of the elements:

&lt;template&gt;
  &lt;v-app&gt;
    &lt;v-app-bar /&gt;
    &lt;v-footer app&gt; ... &lt;/v-footer&gt;
    &lt;v-navigation-drawer&gt; ... &lt;/v-navigation-drawer&gt;
    &lt;v-main&gt; ... &lt;/v-main&gt;
  &lt;/v-app&gt;
&lt;/template&gt;

<!-- begin snippet: js hide: true console: false babel: false -->

<!-- language: lang-js -->

Vue.createApp({}).use(Vuetify.createVuetify()).mount(&#39;#app&#39;)

<!-- language: lang-html -->

&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;https://cdn.jsdelivr.net/npm/vuetify@3/dist/vuetify.min.css&quot; /&gt;
&lt;link href=&quot;https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css&quot; rel=&quot;stylesheet&quot;&gt;
&lt;div id=&quot;app&quot;&gt;
  &lt;v-app&gt;
    &lt;v-app-bar&gt;header&lt;/v-app-bar&gt;
    &lt;v-footer app border=&quot;t&quot;&gt; footer &lt;/v-footer&gt;
    &lt;v-navigation-drawer border=&quot;r&quot; permanent&gt;drawer&lt;/v-navigation-drawer&gt;
    &lt;v-main class=&quot;bg-grey&quot;&gt; Main content &lt;/v-main&gt;
  &lt;/v-app&gt;
&lt;/div&gt;
&lt;script src=&quot;https://unpkg.com/vue@3/dist/vue.global.prod.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;https://cdn.jsdelivr.net/npm/vuetify@3/dist/vuetify.min.js&quot;&gt;&lt;/script&gt;

<!-- end snippet -->


If you want the footer to scroll with the main content, you cannot use the app footer, as it is fixed on the page. I don't think there is an elegant solution to get the footer inside main yet over the nav bar. But you can put the footer into v-main and set absolute position on it:

&lt;v-app&gt;
  &lt;v-app-bar&gt;...&lt;/v-app-bar&gt;
  &lt;v-navigation-drawer&gt;...&lt;/v-navigation-drawer&gt;
  &lt;v-main&gt;
    ...
    &lt;v-footer style=&quot;position: absolute; left: 0; right: 0; z-index: 9999;&quot;
    &gt;...&lt;/v-footer&gt;
  &lt;/v-main&gt;
&lt;/v-app&gt;

see playground

huangapple
  • 本文由 发表于 2023年8月10日 10:40:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76872338.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定