html - 在 VueJS 中使用 CSS 位置粘性

标签 html css vue.js

我在这个问题上花了很多时间我无法弄清楚为什么我的 CSS position: sticky 在我的模板中不起作用。

我的大部分应用程序都是使用 vuetify 构建的。我不知道这是否会干扰 CSS position: sticky ,但即使组件到达该位置,我也不会粘住。

<template>
    <v-sheet>
        <v-row>
            <v-col cols="2">
                <div class="side-panel">
                    <list_component class="side-panel-list"/>
                </div>
            </v-col>
            <v-col cols="10" class="pt-0 pb-0">
                <recipe_create_component/>
            </v-col>
        </v-row>
    </v-sheet>
</template>

<script>
    import {mapState} from "vuex";

    export default {
        name: "production_tool_dashboard",
        extends: abstract,
        computed: {
            ...mapState({
                ...
            })
        },
        components: {
            ...
        },
        data() {
           ...
        }
    }
</script>

<style scoped>
    .side-panel-list {
        height: 100%;
    }
    .side-panel {
        top: 0;
        position: sticky;
        position: -webkit-sticky;
        z-index: 1;
        min-width: 240px;
        max-width: 240px;
        padding: 16px;
        border-right: solid 0.5px rgba(0,0,0,0.2);
    }
</style>

知道这不起作用吗?

最佳答案

我遇到过这样的问题。其中一个父元素有一个属性 overflow:hidden。

css-tricks.com/dealing-with-overflow-and-position-sticky/

关于html - 在 VueJS 中使用 CSS 位置粘性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59690009/

相关文章:

vue.js - 在 VueJS 中总是得到 "Trailing Spaces not Allowed"的错误

vue.js - Vuetify/离线图标

html - 如何在 UIWebView 中播放视频,但它不会在原生电影播放器​​中打开?

javascript - 如何轻松地将图像置于 DIV 中心?

html - 在 Bootstrap 4 中制作可折叠的侧边栏导航?

javascript - jQuery 函数无法正确加载 Bootstrap 页脚

javascript - 当所有标签平衡时,Vue 组件中的结束标签无效

php - 来自数据库的信息应该显示在网站上,但没有

javascript - 使 javascript 在 Firefox 中的附加组件的 javascript 之后执行?

javascript - 当你的模板有空格/文本节点时,WebKit 会导致 DOM 插入变慢吗?