Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

HTML & CSS Help Hover animation stop after 1 click one of the tabs

Ron12345

New Coder
html:
HTML:
<!DOCTYPE html>

<html>

<head>
    <title>Guide Collection</title>
    <p>Guide Collection</p>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <div class="games">
        <div class="tabs">
            <button id="dst" onclick="openDST()">DST</button>
            <button id="ds" onclick="openDS()">DS</button>
            <button id="oni" onclick="openONI()">ONI</button>
            <button id="cc" onclick="openCC()">Cookie Clicker</button>
            <button id="ba" onclick="openBA()">Big Ambitions</button>
        </div>
        <div class="contanier">
            <div id="contect1" class="contect">
                <div id="sqaure">
                    <h1>Find Base Location</h1>
                </div>
                <div id="sqaure">
                    <h1>Find Base Location</h1>
                </div>
                <div id="sqaure">
                    <h1>Find Base Location</h1>
                </div>
                <div id="sqaure">
                    <h1>Find Base Location</h1>
                </div>
                <div id="sqaure">
                    <h1>Find Base Location</h1>
                </div>
            </div>
            <div id="contect2" class="contect">
                <div id="sqaure">
                    <h1>Sun Cool Emote</h1>
                </div>
                <div id="sqaure">
                    <h1>Sun Cool Emote</h1>
                </div>
                <div id="sqaure">
                    <h1>Sun Cool Emote</h1>
                </div>
                <div id="sqaure">
                    <h1>Sun Cool Emote</h1>
                </div>
                <div id="sqaure">
                    <h1>Sun Cool Emote</h1>
                </div>
            </div>
            <div id="contect3" class="contect">
                <div id="sqaure">
                    <h1>Klei Blei Glei</h1>
                </div>
                <div id="sqaure">
                    <h1>Klei Blei Glei</h1>
                </div>
                <div id="sqaure">
                    <h1>Klei Blei Glei</h1>
                </div>
                <div id="sqaure">
                    <h1>Klei Blei Glei</h1>
                </div>
                <div id="sqaure">
                    <h1>Klei Blei Glei</h1>
                </div>
            </div>
            <div id="contect4" class="contect">
                <div id="sqaure">
                    <h1>Very Golden Cookie</h1>
                </div>
                <div id="sqaure">
                    <h1>Very Golden Cookie</h1>
                </div>
                <div id="sqaure">
                    <h1>Very Golden Cookie</h1>
                </div>
                <div id="sqaure">
                    <h1>Very Golden Cookie</h1>
                </div>
                <div id="sqaure">
                    <h1>Very Golden Cookie</h1>
                </div>
            </div>
            <div id="contect5" class="contect">
                <div id="sqaure">
                    <h1>Very Large Buinsess</h1>
                </div>
                <div id="sqaure">
                    <h1>Very Large Buinsess</h1>
                </div>
                <div id="sqaure">
                    <h1>Very Large Buinsess</h1>
                </div>
                <div id="sqaure">
                    <h1>Very Large Buinsess</h1>
                </div>
                <div id="sqaure">
                    <h1>Very Large Buinsess</h1>
                </div>
            </div>
        </div>

            
        </div>
    </div>

    <script>
        var contect1 = document.getElementById("contect1");
        var contect2 = document.getElementById("contect2");
        var contect3 = document.getElementById("contect3");
        var contect4 = document.getElementById("contect4");
        var contect5 = document.getElementById("contect5");

        var dst = document.getElementById("dst");
        var ds = document.getElementById("ds");
        var oni = document.getElementById("oni");
        var cc = document.getElementById("cc");
        var ba = document.getElementById("ba");



        function openDST(){
            contect1.style.display = "grid";
            contect2.style.display = "none";
            contect3.style.display = "none";
            contect4.style.display = "none";
            contect5.style.display = "none";
            dst.style.color = "#2eb05b";
            ds.style.color = "#000";
            oni.style.color = "#000";
            cc.style.color = "#000";
            ba.style.color = "#000";
        }

        function openDS(){
            contect1.style.display = "none";
            contect2.style.display = "grid";
            contect3.style.display = "none";
            contect4.style.display = "none";
            contect5.style.display = "none";
            dst.style.color = "#000";
            ds.style.color = "#2eb05b";
            oni.style.color = "#000";
            cc.style.color = "#000";
            ba.style.color = "#000";
        }

        function openONI(){
            contect1.style.display = "none";
            contect2.style.display = "none";
            contect3.style.display = "grid";
            contect4.style.display = "none";
            contect5.style.display = "none";
            dst.style.color = "#000";
            ds.style.color = "#000";
            oni.style.color = "#2eb05b";
            cc.style.color = "#000";
            ba.style.color = "#000";
        }

        function openCC(){
            contect1.style.display = "none";
            contect2.style.display = "none";
            contect3.style.display = "none";
            contect4.style.display = "grid";
            contect5.style.display = "none";
            dst.style.color = "#000";
            ds.style.color = "#000";
            oni.style.color = "#000";
            cc.style.color = "#2eb05b";
            ba.style.color = "#000";
        }

        function openBA(){
            contect1.style.display = "none";
            contect2.style.display = "none";
            contect3.style.display = "none";
            contect4.style.display = "none";
            contect5.style.display = "grid";
            dst.style.color = "#000";
            ds.style.color = "#000";
            oni.style.color = "#000";
            cc.style.color = "#000";
            ba.style.color = "#2eb05b";
        }


        
    </script>
</body>

css:
</html>
CSS:
 @import url('https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap');


*{
    font-family: "Roboto";
    margin: 0px;
    padding-bottom: 10px;
}

p {
  font-size: 70px;
  padding-left: 10px;
  text-shadow: -2px 5px 15px #C2C2C2;
  

}

.games{
    width: 100%;
    height: 1800px;
    position: relative;
    overflow: hidden;

}

.tabs {
    display: flex;
    border-bottom: 1px solid #ccc;
    
}

.tabs button{
    background: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    font-size: 25px;
    font-weight: bold;
    padding: 8px 12px;
    text-shadow: -2px 5px 15px #C2C2C2;
    transition: 0.2s;
    color = #000000;

}

.tabs button:hover {
    color: #2eb05b;
}

.tabs button:active {
    color:#00571e;
}

#sqaure {
    width: 350px;
      height: 450px;
      border-radius: 7%;
      box-shadow: rgba(100, 100, 111, 0.2) 0px 7px 29px 0px;
      align-content: center;

}

h1 {
    text-align: center;
    padding-top: 20px;
    text-shadow: 4px 3px 14px rgba(0,0,0,0.35);
}


.contect {
      grid-template-columns: 1fr 1fr 1fr 1fr 1fr;
      display: none;
      align-items: center;
      width: 100%;
      padding-top: 30px;
      margin-left: 6px;
      padding-left: 10px;
      padding-right: 10px;
      
      

}

#contect1 {
    display: grid;
}

#dst{
    color: #2eb05b;
}

.tabs button:focus {
  outline: none;
}
 
Sorry, Ron, the only hover I see in the CSS is the top menu words, and that just turns your color green. If they are clicked on - Where is the JS?
FYI In the CSS :
.tabs button{ ... color = #000000;} Notice the equal sign????
 
First, fix .tabs button color
Code:
color: #000000;
Second, setting the button color in js nukes the hover.
I am no fan of !important in css, but this seems to fix the problem
CSS:
.tabs button:hover {
    color: #2eb05b !important;
}
 
I am no fan of !important in css, but this seems to fix the problem
If you don't want to use !important, you could also add a class when clicked, and in the CSS, change the colour using the class name.
Make sure to put this CSS selector after .tabs button, but before .tabs button:hover.
 

Buy us a coffee!

Back
Top Bottom