Problem:
When clicking on a label (for a radio button that has been intentionally hidden by positioning it off-screen), the browser undesirably jumps to the top of the page.
Note: This issue is inconsistent across different browsers -- It occurs in safari and chrome, and it does not occur in firefox or opera
Question:
How can I prevent the browser from jumping the scroll to the top of the page when clicking the radio button's label?
Example code:
• JS Fiddle
• HTML
<div class="rdbut">
<label class="colour">
<input id="option-AVGANT1Y2PC" type="radio" name="Multi-licence" value="1 Year 2 PC|+23.99|0" checked="checked" />
<span>£24.99</span></label>
</div>
<div class="rdbut">
<label class="colour">
<input id="option-AVGANT2Y2PC" type="radio" name="Multi-licence" value="2 Year 2 PC|+34.00|0" checked="checked" />
<span>£35.00</span></label>
</div>
• CSS
.rdbut {
margin: 0px;
}
.rdbut label {
float: left;
width: 65px;
margin: 4px;
background-color: #EFEFEF;
box-shadow: 0px 1px 3px rgba(50, 50, 50, 0.25);
border: none;
overflow: auto;
display: inline;
}
.rdbut label span {
text-align: center;
font-size: 12px;
padding: 3px 8px;
display: block;
}
.rdbut label input {
position: absolute;
top: -9999px;
left: -9999px;
}
.rdbut input:checked+span {
background-color: #404040;
color: #F7F7F7;
}
.rdbut .colour {
background-color: #FF8E22;
color: #ffffff;
}