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 trial

CSS

Flexbox

I'm attempting to align text vertically in a Flex-item , next to an image.

<body>
<div class="flex-container">
    <header class="main-head">Explore...
        <a href="https://twitter.com/REwing9" class="twitter-follow-button" data-show-count="false">Follow @REwing9</a> 
        <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';
            if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js'
            ;fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');
        </script>
    </header>


            <div class="flex-item1">
                <h1 class="name">The Lowdown...</h1>
                        <p>This page is dedicated to my personal journey through the world of Web Development.
                        If you join me on my journey you will see the skills and passion in my work.  This site is 
                        soley dedicated to show you what I've learned in this ever so changing industry.</p>
                        <p>One of the things that I really love about technology is that it's always changing.
                        It's the same for the world of Web Development.  New techniques and tricks are being 
                        shared at such a rapid rate there is always something new to learn.</p>
            </div>

            <div class="flex-item2">    
                <h1 class="name">Keystone</h1>
                    <div>
                        <img src="..//../Images/IMG_2212.jpg">
                        <p>This section is going to be dedicated to my furry little friend.laslflasjflasjlfjasl;jfsa 
                        aljajfjsalfjlsjlfjsljflsjlfjsljfljslfslajlsjfjlaksfljsfjlsajflsjalfjsaj;fjaslflksajlfjlasjflj
                        alsflsajlfjlasjfljslfjsjdjflskdjflajsljflsajfjlsjfjsjfsjdljflasjfjlsjdkfjlsjfljlsflsjfajslfdk
                        aljdfjalsjfljslfjsdkklsjlfjlsdjfjldjjsldjflskdjflkdsnfksdnfnsdkdnlanlnfnkkdladskfnndlasdda.</p>  
                    </div>  
            </div>

            <div class="flex-item3">
                <h1>Info</h1>   
                        <p>It's always fun to try new things and experiment.  Web Development is all about
                        the experience and creativity.  Hopefully you enjoy the site and see something that
                        you might like to see on a site of your own.</p>    
            </div>



    <footer class="main-footer">
        <div class="inner-footer">
            <a href="mailto:rewing9@gmail.com">REwing9@gmail.com</a>
        </div>
    </footer>
</div>
</body>

</html>
*{
    box-sizing:border-box;
}


body {
    font: 1em/1.5 , "Open Sans" , "sans-serif";
    margin: 0 0;
    color: #373737;
    background: #eaeaea;
}
/***Flex Styles*****/


.flex-container{
    display:flex;
    flex-direction:column;

}

.flex-item1, .flex-item2, .flex-item3{
    color: #fff;
    border-radius: 15px;
    background:#06303A ;
    border-radius: 15px;
    box-shadow:2px 2px 4px black;
    margin: 30px;
    padding: 15px;
}



h1{
    text-align:center;
}

2 Answers

Rashaun,

You may need to make both the text and the image flex items inside of a flex container and then align the text vertically.

I hope that helps.

John

Thanks, I appreciate it!!

Steven Parker
Steven Parker
243,656 Points

I think John has the right idea.

:point_right: Make the surrounding div a flex container with vertical alignment:

.flex-item2 div {
  display: flex;
  align-items: center;
}