htmlcsshovercss-positionbox-shadow

Issue with a Custom Button with "position: fixed" Attribute


I wanted to design a simple page where buttons will be displayed on the top in a fixed position with some hover, box-shadow and cursor attributes whereby once one of them hovered there would be some shade around them. For that I utilized position: fixed attribute in a div tag as a button frame for convenience so that I could change the position of all buttons at once when all set by means of CSS styling. However, this works only if I do not scroll down the page. When I scroll down, it loses those three (hover, box-shadow and cursor) attributes. I could not get around this issue. How can I fix it?

Here is the block of code I got so far:

<!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>

Solution

  • remove position absolute from the class .contentFrame