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 trialTodd Bennett
5,122 PointsWhy doesn't my div class center the input section?
<body class="bg-info text-white"> <div class="container text-center"> <h1 class="display-1 mt-5">Full Stack Conf</h1> <p class="lead pb-3">Coming Soon, a One-day Confernce About All Things JavaScript!</p> <div class="col-lg-6 col-lg-offset-3"> <!--this section wont center --> <div class="input-group"> <input type="text" class="form-control" placeholder="Enter Your Email for info..."> <span class="input-group-btn"> <button class="btn btn-primary" type="button">Sign Up!</button> </span> </div> </div> </div> </body>
1 Answer
Flor Antara
12,372 PointsHi Todd,
So the input
tag has an initial value (set by the browser) of text-align: start;
meaning that it will be left aligned if the direction of the text is ltr
(left to right) - which is the default.
By having the class text-center
on your div
is not enough in this case. The browser CSS specificity on the input
wins over the class on your div
.
To solve it, you'll need to add the class text-center
to the input
itself.