I'm attempting to create a website navigation bar using radio buttons, where the pages are displayed based on the selection.
So far, I've managed to achieve this using <a href='#div'></a>
and a :target
, by placing the .page
div directly after the <label>
.
However, I'm struggling to implement the same functionality with <input type='radio'>
and the specific markup structure provided below.
Is it possible to accomplish this task?
The markup structure is as follows:
.page {
display: none;
}
#pages > div:<the-missing-part> {
display: block;
}
<div class="toolbar">
<input type="radio" id="radio1" name="radios" value="div1">
<label for="radio1">Div #1</label>
<input type="radio" id="radio2" name="radios" value="div2">
<label for="radio2">Div #2</label>
<input type="radio" id="radio3" name="radios" value="div3">
<label for="radio3">Div #3</label>
</div>
<div id="pages">
<div id="div1" class="page">Page #1</div>
<div id="div2" class="page">Page #2</div>
<div id="div3" class="page">Page #3</div>
</div>