We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,294 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

image is not inside the class

threeCols left, center, right{

width:296px;
height: 250px;
float:left;
background: url(img01.jpg) repeat-x left top;
text-align:left;
padding:10px;
border-radius:10px;

}

threeCols left, center{

margin-right: 25px;

}

threeCols right{

float: right;

}

    <div id = "threeCols">
        <left>
            <a href="#"><img src="images/1.png" alt="" />
        </left>
        <center>
            <a href="#"><img src="images/2.png" alt="" />
        </center>
        <right>
            <a href="#"><img src="images/3.png" alt="" />
        </right>
    </div>

anyone know why my 3.png is not inside the box i created? 1.png and 2.png are perfectly fitted into the boxes left and center.

thanks in advance for helping!

3
Contributors
4
Replies
11 Hours
Discussion Span
1 Year Ago
Last Updated
5
Views
Question
Answered
feblioz
Newbie Poster
13 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Your centre image needs a left and right margin and your right div needs to come before your center div in the html. Have you checked all your widths and padding aren't totalling to wider than the containing div?

simplypixie
Practically a Master Poster
642 posts since Oct 2010
Reputation Points: 157
Solved Threads: 118
Skill Endorsements: 5

Hi Feblioz

It's not immediately obvious what's wrong.

However, there are quite a few errors in you code that perhaps you need to correct first...

  • Your 'a' tags are not properly closed
  • Left and Right are not valid elements for HTML
  • The stylesheet might not be applied in quite the way you expect, e.g. consider "#threeCols left, #threeCols centre {", instead of "threeCols left, center {".

Did you create the code in notepad? You may find it easier to work in a dedicated HTML editor with support for HTML and CSS validation.

LaxLoafer
Junior Poster
114 posts since Aug 2011
Reputation Points: 43
Solved Threads: 15
Skill Endorsements: 12

I changed my code to this.

    <div id = "threeCols">
        <li>
            <a href="#"><img src="images/1.png"  alt="" />
        </li>
        <li>
            <a href="#"><img src="images/2.png"  alt="" />
        </li>
        <li class="last-item">
            <a href="#"><img src="images/3.png"  alt="" />
        </li>
    </div>

After some trial and error, it worked. but i still need to change my last li to not have margin right.
i tried using

threeCols li .last-item{

margin-right:0px;

}

and

threeCols li:last-child{

margin-right:0px;

}

but it doesnt work. not sure why. Do you know whats wrong?

@laxloafer yep, i use notepad++, just started learning css. Could you recommend me a good text editor? thanks!

and thanks guys for helping!

feblioz
Newbie Poster
13 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

oh oh.. now it works.

changed it to #threeCols li.last

my mistake was having a space between li and .last

:D

@laxloafer yep, i use notepad++, just started learning css. Could you recommend me a good text editor? thanks!

feblioz
Newbie Poster
13 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by simplypixie and LaxLoafer

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0708 seconds using 2.74MB