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
Casey Siebels
783 PointsMaking an image and text align 50-50
Ok... I want an image and text to appear equal distance on this page under the stars image: http://port-80-2bbts8g40g.treehouse-app.com/webdesign.html
I tried adding an image but obviously missed a step
I want the image and text to appear like on this page: http://caseysiebels.com/web-design/
1 Answer
Stephan L
17,821 PointsHi there, there are a number of things you can do:
If the image and the text are contained in separate elements, set those elements to 50% (adjusting for any margins or padding you set). The padding adjustments can also be accounted for by setting each element to box-sizing: border-box.
Wrap the image element and the text element in a wrapper div. Set the image/text elements to display: inline-block, each with a width of 50%, and then set the margins of the image/text elements to margin: auto;
Wrap all of the image elements and text elements in a flex container, set to row wrap, and set flex basis at 50% (again adjusting for any padding unless you use the above border-box rule.) That can create a 2x2 wrapper container. You can then arrange each child element using the order property.
Hope that helps!