Issue
I have a code where I am setting the width of <input>
and <select>
dynamically so that they look same (width-wise). I know there is ~5px width discrepancy between the two so if I set the width of <input>
to 100px then I set <select>
width to 105px; and this seems to work fine everywhere (chrome tends to be off by a pixel, but that is fine with me.) But I recently find out that 100px width is not equal to 105px width in Safari. In fact it is outrageously off. You can see it on following link:
Check it on chrome/firefox and then on Safari to see the difference.
Then I thought using the CSS to fix it using this
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
to maintain consistency. This works but not if I set width dynamically like seen here.
Any idea?
Solution
You can get the width of a tag by running the width() function for that:
var foo = $("#example").width();
You can get the width of your inputs and your selects and then, if the desired value is 200 (for example), then you can run something like this:
$("#example").width(200);
Answered By - Lajos Arpad
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.