I have a simple html page with pretty simple css , and it drives me crazy - I donβt understand what is going on here (the original task is to create a simple contact form using modernizr, but I lost everything):
<html> <head> <style> body { font-size: 16px; line-height: 26px; } label { float: left; margin-top: 4px; } input { border: 1px solid #ccc; margin: 4px; } input:focus { border: 2px solid #900; } </style> </head> <body> <label>1:</label><input id="1" /><br /> <label>2:</label><input id="2" /><br /> <label>3:</label><input id="3" /><br /> </body> </html>
Three lines with labels and input fields increase the left margins, and if I set the focus to any input, those below will go back (at least in Chrome and FF). Why?
Now, if I remove almost any css property, things get weirder:
- The original above can be found here .
- If I delete the body line (or even just the line height: 26px; part !! ), the left margin disappears (why?), Check here .
- If I remove the input: the focus line, the transition will no longer occur (why?), Check here .
- If I remove the border: 1px solid #ccc; from the input, the fields are gone (why ???), check here .
And there are other interdependencies. This does not happen in jsfiddle and other online tools, but can be easily played locally.
Bottom line: all the behavior seems completely alien to me, and I hope that Sherlock Holmes CSS can shed light on what is happening here.
source share