The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › CSS › Height auto should be whole number
If I give height as Auto to div, how can I prevent that value not to be decimal.
Sorry, I don’t understand the question/issues. Can you provide a demo and more clearly state/describe the problem?
To display div in center we set margin as margin: 0 auto Here Top & bottom is 0 but left & right is auto that may be decimal (fractional) value. so can we restrict value must be whole number.
Basically, you can’t but I’m not sure why this is an issue.
If there is a fractional pixel, most browsers will round this automatically.
Other than that you would need Javascript.