For my buttons towards my code, it's not allowing the button to turn the cursor into a pointer when moving onto the button, and after a while my hover pseudo class selector is no longer working for the button. I used ChatGPT to figure out where I may have gone wrong, and it showed that putting the buttons in position relative may have screwed the accessibility of the button.
Can you show me where I may have gone wrong with this code?
.hero-btn {
/*
position: relative;
top: 200px;
left: 30px; */
margin-left: 10px;
padding: 10px 20px;
font-size: 1rem;
border: none;
cursor: pointer;
border-radius: 25px;
font-family: 'Open-Sans', sans-serif;
transition: .3s ease-in-out;
}
.blog-btn {
background-color: #000;
color: #fff;
}
.blog-btn:hover {
background-color: var(--secondary-color);
color: #fff;
}
.sub-btn {
background-color: #000;
color: #fff;
}
.sub-btn:hover {
background-color: var(--primary-color);
color: #fff;
}
<button type="submit" value="Read The Blog" class="blog-btn hero-btn">
Read The Blog
</button>
<button type="submit" value="Subscribe" class="sub-btn hero-btn">
Subscribe
</button>
The input element was used first before being changed over to the button element. The button was once hovering and the cursor: pointer; worked towards the checking the accessibility. After a while the button began to not work when trying to check for accessibility, I tried changing over the class attributes, was a bust there. I tried changing the position or commenting out the position all together still not working. I also redid the code once more to make sure it wasn't a spelling error towards the code.
The problem is caused by the
yoga-sectionelement overlaying the buttons, so that when you attempt to click the buttons, you are actually clicking the hitbox of theyoga-sectionelement.The simplest fix is to apply a positive
z-indexto the buttons such that they are stacked on top of theyoga-sectionelement:An arguably more maintainable fix is to rework the non-sensical use of
position: relativeandtop/leftto instead use more sensible CSS properties to more predictably layout elements, such that there is less overlaying of elements. For example as a rough rework: