I’ve been going absolutely insane for the lat 4h trying to learn. I’m so new to this pls help / be kind.
I’m making a website with VSCode. So, I want to make a button that when you click two more buttons appear – then each of them lead to diferent pages when clicked! I just can’t figure out how.
It should be a button with this text:
Do you enter?
(click button. then these 2 buttons appear:)
YES NO
I’ve tried to tinker with this one that I found online:
https://www.quora.com/How-can-a-button-reveal-another-button-when-hovered-over-using-CSS
<div class="button-container">
<button class="main-button">Hover Me</button>
<button class="reveal-button">Revealed Button</button>
</div>
CSS:
.reveal-button {display: none; /* Initially hide the revealed button */ }.main-button:hover + .reveal-button { display: inline block; /* Display the revealed button when main button is hovered */ }
But I can’t find a way to make it be "click" instead of "hover" even when I change to ":focus". And with this method I can only make 1 button appear after the first, instead of 2.
Is my request impossible to make? Or am I just unware of the answer?
3
Answers
You can achieve something similar to this, but I definitely think you need to use JavaScript for a more logical and efficient solution.
Try this method. Use JavaScript to change CSS:display of buttons.
There are a couple of approaches using only HTML and CSS as follows, with explanatory comments in the code:
References:
CSS:
backdrop-filter
.background
.block-size
.border
.border-radius
.box-sizing
.display
.gap
.:has()
.inset
.margin
.opacity
.padding
.:popover-open
.transition
.visibility
.HTML:
popover
attribute.popovertarget
attribute.