开发者

Need Advice On Simple CSS Tooltip

I need some advice on a simple CSS tooltip. I have a calendar on a site that is rendered within a table. People can add events to this calendar. I have added CSS so that when you hover over a date, it will display the event, or events for that date. Within the table, I have this for each date cell with an "event":

<td class="eventDate" id="2011-08-24" title="2011-08-24">
    24
    <span class="tooltip">
        <img class="infoImg" src="./images/info.png" width="16" height="16">
        <i>Today's Events</i>:
        <br>
        &#149; This is an event.
        <span class="noOf开发者_如何学GoDays">[ 3 days ]</span>
    </span>
</td>

And, this is what I have for my CSS (found the technique via a Google search):

td.eventDate {
    position: relative;
    z-index: 24;
    background-color: #afafaf;
    color: #000;
    padding: 2px 4px 2px 4px;
    text-align: right;
    font-size: 36px;
    font-family: Georgia;
}

td.eventDate:hover {
    z-index: 25;
    cursor: default;
}

td.eventDate span.tooltip {
    display: none;
}

td.eventDate:hover span.tooltip {
    display: block;
    position: absolute;
    top: 5.3em;
    left: 28.5em;
    width: auto;
    color:#3e3e3e;
    border:1px solid #3e3e3e;
    background-color: #efefef;
    padding: 4px 8px 4px 8px;
    font-family: Candara, Tahoma, Geneva, sans-serif;
    font-size: .4em;
    font-weight: 700;
    text-align: left;
    z-index: 100;
}

span.noOfDays {
    font-size: 11px;
    padding: 0px 0px 0px 6px;
}

This works perfectly for any Mozilla based web browser; however, when I move to Safari, Chrome or IE (I haven't tried it in Opera yet), it is all wonky. For one thing. the size of the tooltip box seems constrained to the size of the table cell, making my events wrap all over the place. Also, the positioning of the tooltip box when it is "revealed" seems relative to the table cell in which the event span is placed, and not aligned with the top-right of the calendar table.

Can anybody see what I am doing wrong? Should this not be working in Mozilla either? Are there any other very simple, and lightweight tooltip techniques I can use that you would suggest? I was trying to stay away from JavaScript/JQuery/etc. as I wanted to keep this pretty light, but I may have to switch over if I cannot get this to work with CSS. Any, and all advice is appreciated.

Thanks for taking the time to read, and have a great day. :-)


Why not use a simple jquery tooltip script. easy to implement and will be set up under 1 minute. try Tiptip or Qtip in google. Will safe you some time

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜