边距顶部菜单移动内容


'

.fullpage'块上的滚动条和内容有问题。由于顶部菜单的缩进为 30px,底部内容也会在相同的 30 像素上留下视图。怎么做?

附言:在外部,页面看起来应该完全一样。顶部菜单应与常规内容分开。

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<style>
    html {
    height: 100%;
    margin: 0;
}
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, 0.35);
}
::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.25);
}
body {
    overflow: hidden;
    height: 100%;
    width: 100%;
    margin: 0;
    background-color: #141320;
    color: white;
}
.draggable {
    -webkit-app-region: drag;
}
.center {
    display: flex;
    justify-content: center;
    align-items: center;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
    position: absolute;
}
.center .btn {
    border-radius: 4px; 
    margin: 7px;
}
button {
    -webkit-app-region: no-drag;
}
.fullpage {
    position: absolute;
    overflow: auto;
    width: 100%;
    height: 100%;
    margin-top: 30px;
}
.topmenu {
    top: 0;
    overflow: hidden;
    width: 100%;
    height: 30px;
    position: fixed;
    background-color: rgba(255, 255, 255, 0.05);
    z-index: 99999;
}
</style>
</head>
<body>
    <div class="topmenu draggable"></div>
    <div class="fullpage">
        123123123
        <div class="center">
            <button class="btn btn-info">Test</button>
            <button class="btn btn-primary">Test 2</button>
            <button class="btn btn-success test">Test 3</button>
        </div>
        <div style="margin-top: 1400px; width: 30px; height: 31px; background-color: aqua;"></div>
    </div>
</body>
</html>

补充:由于某种原因,顶部菜单已不再透明。内容在其下方完全消失,就好像 rgba 无法透明地工作(

问题解决了!

html {
    height: 100%;
    margin: 0;
}
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background-color: rgba(0, 0, 0, 0.35);
}
::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.25);
}
body {
    height: 100%;
    width: 100%;
    margin: 0;
    background-color: #141320;
    color: white;
    z-index: 99998;
}
.draggable {
    -webkit-app-region: drag;
}
button {
    -webkit-app-region: no-drag;
}
.fullpage {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    overflow-y: scroll;
}
.topmenu {
    top: 0;
    overflow: hidden;
    width: 100%;
    height: 30px;
    position: fixed;
    background-color: rgba(255, 255, 255, 0.05);
    z-index: 99999;
}
.content {
    margin-top: 30px;
}
.center {
    display: flex;
    justify-content: center;
    align-items: center;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    margin: auto;
    position: absolute;
}
    .center .btn {
        border-radius: 4px;
        margin: 7px;
    }
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
    <div class="fullpage">
        <div class="topmenu draggable"></div>
        <div class="content">
            123123123
            <div class="center">
                <button class="btn btn-info">Test</button>
                <button class="btn btn-primary">Test 2</button>
                <button class="btn btn-success test">Test 3</button>
            </div>
            <div style="margin-top: 1400px; width: 50px; height: 60px; background-color: aqua;"></div>
        </div>
    </div>
</body>
</html>

最新更新