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 trialDaniel Campbell
10,148 PointsAlignment using .collapse (and img-float)
This is my first question. Can anyone see my workspace and code? Should I refer to the code (by line) or copy the relevant code it into this space?
Here is my workspace link : http://port-80-9oggciq6aj.treehouse-app.com/ (go to 'schedule')
And the code in question :
<h1 id="schedule" class="display-4 text-xs-center m-y-3 text-muted">Schedule</h1>
<ul class="list-group">
<li class="list-group-item">
<img src="img/angie.png" class="img-fluid img-circle pull-xs-left m-r-1" width="100px" height="200px">
<a data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
<h4 class="list-group-item-heading">Internet of things<span class="tag tag-info tag-pill pull-xs-right">9:00am</span></h4>
Nodestradamus
</a>
<div class="collapse" id="collapseExample">
<hr>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</li>
I'd like this div (the text)
<div class="collapse" id="collapseExample">
<hr>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
to align with the text above (to replicate the exact spacing of the example in the video at the end)
<a data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
<h4 class="list-group-item-heading">Internet of things<span class="tag tag-info tag-pill pull-xs-right">9:00am</span></h4>
Nodestradamus
</a>
It's possible with a grid layout, but is this necessary or is there a property I can add to the "collapseExample" div to have it align with the above text (like the example in the video at 6:00)?
During the expansion animation the text aligns with the above text but then snaps left after the expansion animation is finished.
Question : What's the best way to make the example in the video at 6:00?
Thanks!
1 Answer
Pawel Cebula
4,281 PointsI struggled for quite some time with this one too. Here's what worked for me in the end:
<h1 id="schedule" class="display-4 text-xs-center my-3 text-muted">Schedule</h1>
<ul class="list-group">
<li class="list-group-item">
<div class="media">
<div class="container px-0">
<div class="row">
<div class="col-xs-1">
<a class="media-left" href="#">
<img class="media-object rounded-circle pull-xs-left" src="img/avatar-nodestradamus.png" width="50px">
</a>
</div>
<div class="col-xs-11">
<a class="schedule-link" data-toggle="collapse" href="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
<div class="media-body">
<h4 class="list-group-item-heading">Keynote: Internet of Things <span class="tag tag-info tag-pill float-xs-right">9:00am</span></h4>
NodeStradamus
</div>
</a>
<div class="collapse" id="collapseExample">
<hr>
Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
</div>
</div>
</div>
</div>
</div>
</li>
I also had to create a little bit of custom css to remove link styling:
.schedule-link,
.schedule-link:hover,
.schedule-link:focus {
text-decoration: none;
color: inherit;
}
While it works, I'm not sure whether this is the most efficient solution. I'd be keen to see how others managed to solve this one.