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 trialJanek Rezner
12,973 PointsDesigning a graph legend
I'm designing a legend for a graph I made and want to style the text to be aligned next to the color boxes (not underneath). Can't get this right.
I'm using Sass and Zurb Foundation 5.
Here is my code:
<ul class='legend-labels'>
<li class="columns small-6 medium-3 large-3"><span style='background:#DC863B;'></span>Photoshop and Illustrator</li>
<li class="columns small-6 medium-3 large-3"><span style='background:#FAEFD4;'></span>HTML and CSS</li>
<li class="columns small-6 medium-3 large-3"><span style='background:#889DA3;'></span>Wordpress and PHP</li>
<li class="columns small-6 medium-3 large-3"><span style='background:#CB2D1C;'></span>Javascript and jQuery</li>
</ul>
and Scss
.legend-labels {
margin: 0;
padding: 0;
list-style: none;
li {
list-style: none;
display:inline;
span {
display: block;
height: 30px;
width: 30px;
border: solid 2px black;
}
}
}
the result is this:
any help much appreciated !!
1 Answer
Jason Anello
Courses Plus Student 94,610 PointsHi Yann,
Using display:inline-block;
on the span
should get you where you want. This way it behaves as a block element where you can assign a width and height but also behaves as an inline element keeping it inline with the text after it.
Janek Rezner
12,973 PointsJanek Rezner
12,973 Pointsaghhhhggh of course! It worked like a charm! thanks a million!