0

Javascript:

<script type="text/javascript">
  $(function() { $('.cat_name').tipsy({gravity: 's'}); });
</script>   

TPL聪明:

<div id="content_inside">
    <a href="#" title="Test" id="1" class="cat_name">
        <div class="box">
        </div>
    </a>
    <a href="#" title="Test2" id="2" class="cat_name">
        <div class="box">
        </div>
    </a>
</div><!-- content end -->

CSS:

#content_inside {
    height: 500px;
    width: 950px;
    padding:5px;
}

.box {
    width: 300px;
    height: 261px;
    padding: 5px;
    float: left;
}

.box {
    margin: auto;
    background: url(../images/box1.jpg) no-repeat top left;
}

我需要在每个 div 链接的上部中心放置醉酒,怎么做?现在醉酒总是显示在左侧。在 img 中如何以及如何需要的示例:http: //oi43.tinypic.com/adka3t.jpg

4

2 回答 2

0

在tipsy中有一个offset选项,它从元素中偏移。

$('.cat_name').tipsy({gravity: 's', offset: 20 });
于 2012-03-01T19:06:01.277 回答
-1

不幸的是,您的 float: left 导致无法正确计算偏移量。你能以不同的方式布局你的页面吗?例如,以下无聊的旧表格布局似乎在设计上复制了您正在寻找的内容,并且工具提示显示在您想要的位置。

HTML:

<div id="content_inside">
<table>
<tr>
    <td class="box"><a href="#" title="Test" id="1" class="cat_name">lkjoijkj lj lkj oij oi</a></td>
    <td class="box"><a href="#" title="Test 2" id="2" class="cat_name">lkjoijkj lj lkj oij oi</a></td>
</tr>
</table>
</div>

CSS:

#content_inside {
    height: 500px;
    width: 950px;
    padding:5px;
}

.box {
    width: 300px;
    height: 261px;
    padding: 5px;
}
a { 
    display:block; 
    height: 100%;
}
于 2012-03-01T19:28:13.737 回答