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 trialMaja B.
12,984 PointsHow to fix slider text to the right?
On this page www.ajp.cool I have a slider with 6 images. Each image has a label (text) over it.
It is a Woo Flexslider. Flexslider is an ul and each slide is a li within it. Like this:
<!--and excerpt from the slider, showing only the code for the first two slides -->
<li>
<a href="#"
<img src="http://lorempixel.com/800/500/" alt="Illustration">
<span class="image-text">Illustration</span>
</a>
</li>
<li>
<a href="#"
<img src="http://lorempixel.com/800/500/" alt="Pictorail Maps">
<span class="text">Pictorial Maps</span>
</a>
</li>
And here is the CSS:
.text {
position: relative;
left: 5%;
bottom: 75px;
padding: 10px;
color: white;
}
As you can see the left side of the label is fixed, while the right side spreads according to the text length. For example, when on Illustration the label has a certain length, but when the slider switches to Pictorial maps, the label's length is increased. Its because the text Pictorial Maps is longer than Illustration.
But I would like to have it the other way around. I would like the right side of the label to be fixed and the left one spreading according to the text length.
Is that possible with CSS?
P.S. I have created a JS Fiidle http://jsfiddle.net/M4j4/azzhwf4p/ to help me figure this out. Please use it if you need it.
1 Answer
Jesus Mendoza
23,289 PointsHi, try floating the text to the right and adding a position from right.
float:right;
right:95%;
I don't know if 95% is the right position thought
Maja B.
12,984 PointsMaja B.
12,984 PointsUau!!! That does the trick. Thank you so much!
P.S. You are right in this case I'll have:
right: 10%;