positioning an image link in a div

Discussion in 'CSS' started by RexRon, Aug 1, 2010.

  1. #1
    Hello.

    I´m new to css and is this my second topic on this forum. I´m currently redesigning a site using css instead of tables. On this site I now have several Divs defined in a style sheet and linking to them from my php document. So far so good but the image below explains what I want:
    [​IMG]

    Here´s the div:
    
    #MainTop_b {
       position: relativ;
       width: 320px;
       height:183px;
       margin-left: 0px;
       margin-top: 0px;
       font-weight: normal;
       padding-top:15px;
       padding-left:15px;
       padding-right:15px;
       float:left
    }
    
    Code (markup):
    And here´s the document:
    
    <DIV id="MainTop_b"><span class="Heading">Top Stories</span>
                      <ul id="listimage">
                      <li id="active"><a href="#"><em>An ancient legacy</em></a></li>
                     
                      <li><span class="style1"><a href="#">The signs are everywhere</a></span></li>
                        
                      <li><em><a href="#">What lies within our DNA?</a></em></li>
                      
                      <li><em><a href="#">The alien technology</a></em></li>
                      
                      <li><em><a href="#">The nascan conundrum</a></em></li>
                      
                      </DIV>
    
    Code (markup):
    And last here´s the code generating the facobook icon wich I´d like to display in top right corner of the div.
    
    <a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a>
    
    Code (markup):
    I´ve been trying different things but my innexperience is just messing it up.
    Can someone please help me with this?

    I´m not allowed to post live links yet since I´m a new member.

    Sincerely
    Ronny
     
    RexRon, Aug 1, 2010 IP
  2. Zeh.

    Zeh. Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Set #MainTop_b to position: relative;
    Then, set your facebook button to position: absolute; top: 0; right: 0;

    That should work.
     
    Zeh., Aug 1, 2010 IP
  3. RexRon

    RexRon Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I see... Thanks. Do I nead to create a new specific div for this in the style sheet or is there a way I could define this in the document?

    Tryed with a div definition in the style sheet... Didn´t work. It ligned up next to the Heading. Allso the icon didnt show. Only the "share" link.
     
    Last edited: Aug 1, 2010
    RexRon, Aug 1, 2010 IP
  4. Zeh.

    Zeh. Peon

    Messages:
    57
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Your facebook icon has to be inside #MainTop_b
     
    Zeh., Aug 1, 2010 IP
  5. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I assume it's ok to put a class in the anchor without messing up facebook script.

    
    <a class="facebook" name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a>
    
    .facebook {
       float: right;
    }
    
    Code (markup):
    BTW, you have left an "e" off the end of position: relativ; :eek:
     
    Cash Nebula, Aug 1, 2010 IP
  6. RexRon

    RexRon Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks guys... I did put the facebook icon within the TopMain_b. However the solutin with the class before the facebook code worked. Still no image though. Just the "share" link. But I´m getting there :)
     
    RexRon, Aug 2, 2010 IP
  7. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Do you have the share script right after it?
    <a class="facebook" name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a>
    <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>
    Code (markup):
     
    Cash Nebula, Aug 2, 2010 IP
  8. RexRon

    RexRon Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Aparently I did not :) Well, it´s in there now and working fine.

    Thanks :)
     
    RexRon, Aug 2, 2010 IP