SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict mari's Avatar
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation targetting specific anchor within div

    Hi Guys,

    I have a div with a background image and some text in it, i also have some hyperlinks in it

    i want to make part of the background image a link
    This is my css so far, however this applys the style to all hyperlinks

    #box1{
    width: 295px;
    min-height: 305px;
    float: left;
    background: url('bg.jpg') no-repeat;
    }

    #box1 a{
    display:block;
    width: 295px;
    height: 30px;
    }

    here is my html

    HTML Code:
    <div id="box1"><a href="link1"></a>
    <span class="font"><br /><br /><br /><br />some font goes here:<br/>
    <br/>
    <a href="link2"></a><br>
    <a href="link3"></a></span>
    </div>

  2. #2
    SitePoint Wizard bronze trophy PicnicTutorials's Avatar
    Join Date
    Dec 2007
    Location
    Carlsbad, California, United States
    Posts
    3,656
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    Instead of saying #box a {} say #box a.one - so give the different anchor a class. Or you you can say # box a+a. Given there will be no more anchors in the box.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2011
    Posts
    55
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi mari,

    What EricWatson is saying is right. One more option is:

    Create 2 diff classes let say..(.one and .two). Those anchor which do not belong to background add .two class to them and the one who belongs to background add .one class to it.

    Because, If you are writing a common class for all anchor inside a div and then again making a separate class for specific anchor, then that specific anchor will have properties of both class.

    My solution mentioned above will solve this problem.
    PHP Programming Itís more than just writing code

  4. #4
    SitePoint Addict mari's Avatar
    Join Date
    Nov 2007
    Location
    London, UK
    Posts
    218
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    problem solved,

    thanks guys


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •