2011-08-08 53 views

回答

4

HTML:

<span class="tooltip_display">Tooltip</span> 
<div class="ttip"> 
    <div class="contents">Here goes contents...</div> 
    <span class="note">(click here to close the box)</span> 
</div> 

CSS:

.ttip { 
    position: absolute; 
    width: 350px; 
    height: 100px; 
    color: #fff; 
    padding: 20px; 
    -webkit-box-shadow: 0 1px 2px #303030; 
    -moz-box-shadow: 0 1px 2px #303030; 
    box-shadow: 0 1px 2px #303030; 
    border-radius: 8px 8px 8px 8px; 
    -moz-border-radius: 8px 8px 8px 8px; 
    -webkit-border-radius: 8px 8px 8px 8px; 
    -o-border-radius: 8px 8px 8px 8px; 
    background-image:-moz-linear-gradient(top, #F45000, #FF8000); 
    background-image: -webkit-gradient(linear, left top, left bottom, from(#F45000), to(#FF8000)); 
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#F45000', endColorstr='#FF8000', GradientType=0); 
    display: none 
} 
.contents { 
    font-size: 15px; 
    font-weight:bold 
} 
.note { 
    font-size: 13px; 
    text-align:center; 
    display:block; 
    width: 100% 
} 

JQUERY:

$('.tooltip_display').click(function() { 
    $('.ttip').css({ 
     left: '20px', 
     top: '50px' 
    }).show(500) 
}); 

$('.note').live('click', 
function() { 
    $('.ttip').hide(500); 
}); 

JSFIDDLE

+0

@French男孩,我舉一個簡單的演示。但是你可以從下面給出的源代碼中找到更好的。 – thecodeparadox

+0

不錯的工作。我爲你擺弄它[這裏](http://jsfiddle.net/kkL5B/) – anu

+0

編輯你的答案,添加隱藏工具提示的代碼 – anu

相關問題