带有带有“ position:fixed”属性的自定义按钮的问题

问题描述 投票:0回答:1

我想设计一个简单的页面,其中按钮将在顶部固定位置显示,并带有一些hoverbox-shadowcursor属性,一旦其中一个悬停,它们周围就会有阴影。为此,为了方便起见,我将position: fixed标记中的div属性用作按钮框架,以便在通过CSS样式进行设置时可以一次更改所有按钮的位置。但是,仅当我不向下滚动页面时,此方法才有效。当我向下滚动时,它将丢失这三个(hoverbox-shadowcursor)属性。我无法解决这个问题。我该如何解决?

这里是我到目前为止获得的代码块:

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="author" content="User">
        <title>Home Page</title>
        <style>
            body {
                background-color: rgb(255, 255, 255);
                margin: 0px;
                padding: 0px;
                border-style: none;
            }
            .mainFrame {
                position: absolute;
                top: 0px;
                left: 131px;
                width: 700px;
                height: 800px;
                margin: 0px 0px 31px 0px;
                padding: 0px;
                border-style: solid;
                border-color: rgb(0, 0, 0);
                border-width: 0px 2px 2px 2px;
                border-radius: 0px 0px 131px 0px;
            }
            .buttonFrame {
                position: fixed;
                top: 0px;
                left: 133px;
                width: 500px;
                height: 39px;
                margin: 0px;
                padding: 0px;
                border-style: none;
            }
            .button {
                height: 29px;
                margin: 0px;
                padding: 4px 7px 4px 7px;
                background-color: rgb(255, 99, 71);
                border-style: solid;
                border-color: rgb(0, 0, 0);
                border-width: 0px 2px 2px 2px;
                border-radius: 0px 0px 131px 0px;
                font-family: Arial, Helvetica, sans-serif;
                font-weight: bold;
                font-size: 23px;
                text-align: left;
                cursor: pointer;
                outline: none;
            }
            .buttonEffect:hover {
                box-shadow: 0 13px 17px 0 rgba(0,0,0,0.25), 0 13px 17px 0 rgba(0,0,0,0.25);
                outline: none;
            }
            .Home {
                position: absolute;
                top: 0px;
                left: 31px;
                width: 64px;
            }
            .Notes {
                position: absolute;
                top:0 px;
                left: 144px;
                width: 64px;
            }
            .AboutMe {
                position: absolute;
                top: 0px;
                left: 257px;
                width: 105px;
            }
            .contentFrame {
                position: absolute;
                top: 40px;
                left: 0px;
                width: 500px;
                height: 400px;
                margin: 0px;
                padding: 0px;
                border-style: none;
            }
        </style>
    </head>
    <body>
        <div class="mainFrame">
            <div class="buttonFrame">
                <a class="button Home buttonEffect" title="Home">Home</a>
                <a class="button Notes buttonEffect" title="Notes">Notes</a>
                <a class="button AboutMe buttonEffect" title="About Me">About Me</a>
            </div>
            <div class="contentFrame">

            </div>
        </div>
    </body>
</html>
html css hover css-position box-shadow
1个回答
0
投票

从类.contentFrame中删除绝对位置

© www.soinside.com 2019 - 2024. All rights reserved.