Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

input checkbox in div jumps to top of page on firefox [closed]

Tags:

html

css

firefox

I use div over label and input type="checkbox". I do this in order to have the checkbox look like a button.

Here is my example: http://jsfiddle.net/Je87Q/

What should I do with a checkbox or label/input that will stop jumping to the top of my page?

This happens ONLY on Firefox. Any idea how to fix this?

like image 205
user3202805 Avatar asked Feb 04 '14 20:02

user3202805


3 Answers

DEMO

Just need a minor CSS change

#modbutton label input {
    /* position:absolute; */
    /* top:-20px; */
    display:none; /* ADD */
}
like image 183
kei Avatar answered Oct 20 '22 05:10

kei


This is happening because you are positioning the checkbox absolutely and -20px above the viewport. When you click on the span, you're triggering the label to change the checkbox which causes the jump to the top. There are a variety of ways to fix this, but an easy one would be to change:

#modbutton label input {
    position:absolute;
    top:-20px;
}

to something like:

#modbutton label input {
    position:absolute;
    left:-20px;
}

jsFiddle example

like image 33
j08691 Avatar answered Oct 20 '22 05:10

j08691


I got your point

Please change this code for your input field

<input id="status" type="checkbox" name="displaystaffstatus" style="position: relative;">

or do this thing

#modbutton label input {
    display:none;
}
like image 25
Muaaz Khalid Avatar answered Oct 20 '22 04:10

Muaaz Khalid