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 trialBrice Franks
1,488 PointsNeed help moving an image in media query
I'm trying to move an image that I have floated to the right next to a paragragh div in the desktop mode to just below the div in mobile phone mode. How do I do this in media query. Here is my code below.
HTML
<p class= "liv2"><img src= "/img/Clara-ma.jpg">Liv Your Truth is a program designed to educate the young generation in rebuilding and creating a strong foundation for their life. This foundation teaches the young generation how to think for oneself, and it gives them the opportunity and courage to create and live their own truth. LivYour Truth Program is categorized into three separate program lessons, (Three: Core Life Tools and Twenty-nine: Basic Life Tools). In addition, there are thought provoking activities and group discussions implemented into the program.</p>
CSS
.liv2 img { height: 120px; max-width: 30%; float: right; display: inline; margin: 15px; }
1 Answer
Steven Parker
231,269 PointsThe first thing that occurred to me was to just add another image after the paragraph, and make the original one vanish at your breakpoint, and make the new one visible at the same time.
<p class="liv2"><img src="/img/Clara-ma.jpg">[your paragrph here]</p>
<img class="afterimg" src="/img/Clara-ma.jpg">
.afterimg { display: none; }
@media screen and (max-width: 900px) {
.liv2 img { display: none; }
.afterimg { display: inline; }
}