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

Image alignment in css

i wanted to align some images to my practice website but i couldn't do it with the usual width, margin and padding elements, so i used position element instead. Now i am having trouble writing the responsive code for the images. Could you suggest a way to align the images using the width,margin and padding elements.

/*************SECTION************/

.man{
    position: relative;
    right: 170px;
    width: 200%;
    margin: .5px;
}

.head {
    text-align: center;
    position: relative;
    right: 10px;
    font-size: 20px;
    font-family: 'Open-Sans' , sans-serif;
    font-weight: 300;
    margin-left: 10%;
    padding: 0;
    color: #83ae9b;
    display: inline-block;
}

#head2{
    text-align: center;
    margin-top: 75px;
    font-size: 22px;
    font-family: 'Open-Sans' , sans-serif;
    font-weight: 700;
    color: #355c7d;
}

.web{
    position: relative;
    right: 315px;
    width: 270%;
    margin-top: -25%;
    margin-bottom: 25%;
    padding-bottom: 25%;
}

#head3{
    text-align: center;
    font-style: normal;
    font-family: 'Open-Sans', sans-serif;
    margin-bottom: 100%;
    margin-top: -100%;
    color: #355c7d;
}

.graphic{
    position: relative;
    right: 315px;
    width: 270%;
    margin-top: -125%;
    margin-bottom: 25%;
    padding-bottom: 25%;
}

#head4{
    text-align: center;
    font-style: normal;
    font-family: 'Open-Sans', sans-serif;
    margin-bottom: 100%;
    margin-top: -100%;
    color: #355c7d;
}

.mograph{
    position: relative;
    right: 85px;
    width: 150%;
    margin-top: -100%;
    margin-bottom: 25%;
    padding-bottom: 25%;
}

#head5{
    text-align: center;
    font-style: normal;
    font-family: 'Open-Sans', sans-serif;
    margin-bottom: 100%;
    margin-top: -65%;
    color: #355c7d;
}

.man .web and .mograph are the images

1 Answer

At first glance, you have a very wide width. Try a smaller width & see if it responds. Also, work on one graphic only & get it working, then add on the others one at a time. Sometimes te size of the graphics are too big & will make it appear that the code isnt working.

thanks

width in pixels is more accurate than in percentage. thats where i was going wrong.