tricky CSS problem - a href and with multiple font-colors

Discussion in 'CSS' started by dp1, Aug 18, 2007.

  1. #1
    hi there, thanks for taking your precious time to help me by reading this :)

    here a picture:
    [​IMG]

    so I have an area, which I want to act as an link.
    On mouseover in any part of the area the cursor should change and it should become a link.
    AND there are two different font colors in this area. however both should belong to the same link.

    here my approach until now:

    HTML-code:

    <div id="area">
    <a href="http://www.digitalpoint.com">Main Title<br /></a>
    <span class="subtitle">Subtitle</span>
    </div>
    HTML:
    and

    CSS-code:

    #area a {
    	font-color: white;
    	margin: 0;
    	padding-left: 5px;
    	padding-bottom: 12px;
    	display: block;
    	background-color: #000;
    }
    
    #area a:hover {
    	background-color: #ff0000;
    }
    .subtitle {
    	font-size: 10px;
    	font-color: yellow;
    	position: absolute;
    	margin-top: -17px;
    	height: 10px;
    	padding-left: 5px;
    }
    
    Code (markup):

    I also tried putting the span inside the <a> </a>.. but then the subtitle font color gets white, even if a make a ".subtitle a"-tag.

    any better ideas?


    thanks !!
     
    dp1, Aug 18, 2007 IP
  2. VimF

    VimF Well-Known Member

    Messages:
    307
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    118
    #2
    It would take you time to make a picture like that, so:

    
    <a href="#">Main Title<br /><span>Subtitle</span></a>
    
    Code (markup):
    is all the html you need.

    
    a {
    	display: block;
    	width: 130px;
    	padding: 5px 10px;
    	font: bold 16px/18px arial, helvetica, sans-serif;
    	color: #FFF;
    	text-decoration: none;
    	background: #000;
    }
    a:hover {
    	background: #F00;
    }
    a span {
    	font: normal 12px/14px arial, helvetica, sans-serif;
    	color: #FF0;
    }
    
    Code (markup):
     
    VimF, Aug 18, 2007 IP
  3. dp1

    dp1 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    wohooo it works :D

    2 questions, one small one, one bigger one:

    1.) what does 12px/14px mean ? - e.g. when is the first one used, when the other one?

    2.) now my thing looks like this:
    [​IMG]

    I've managed to change the height, through setting the "height" attribute, but I can't manage to shift the "Subtitle" higher up through setting the top-margin to a negative value :(.. is there a better way?


    thx for your advice. I hope this will be my last questions :) ..
    good night from europe.
     
    dp1, Aug 18, 2007 IP
  4. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #4
    font: 12px/14px means 12 pixel font size and 14 pixel line height (not height). The font shorthand requires only a size and 1 font family to work, just a size or font family won't work.. keep that in mind to avoid future errors
     
    soulscratch, Aug 18, 2007 IP
  5. dp1

    dp1 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thanks for the help. :)
     
    dp1, Aug 20, 2007 IP
  6. dp1

    dp1 Peon

    Messages:
    4
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    one last question:

    is it possible to have more than one background picture specified by a <a> tag?

    at the moment I have something like this:

    <div class="foo"><a href="#">My fancy link</a></div>
    HTML:
    .foo a {
    	display: block;
    	width: 100px;
    	background: #222 repeat-y left url(image.gif);
    }
    Code (markup):
    but i would like to have another background picture aswell above the other one, at a fixed position. (and it should change on mouseover).

    any ideas, how to do this in a clean way?
     
    dp1, Aug 20, 2007 IP
  7. GWiz

    GWiz Peon

    Messages:
    359
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Wouldn't it make sense to just include that into the existing background image? Why have two when they both change together anyway, just merge the images together.
     
    GWiz, Aug 24, 2007 IP