Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Input width: 0 not being applied

Hi folks,

I need to animate an input field with an on click event and I am setting the default width of the input element to 0, so that when I toggle the active class to show it the width will be what I need it to be, however when I set the width to 0 the input is actually 15px wide, why does this happen?

Would be great if someone could help,

Thanks.

2 Answers

Steven Parker
Steven Parker
242,191 Points

Without seeing your code it's just a guess, but do you also have padding applied to the element?

If that's not it, try sharing your code, or even better, make a snapshot of your workspace and post the link to it here.

In addition to padding, as Steven mentioned above, the input also might have a default border on it, which would add to the width.