如果没有新的页面加载,Codeigniter无法链接到ID'd元素

时间:2012-04-01 22:01:37

标签: html anchor

我有一个在Codeigniter上运行的网站,我正在尝试通过链接链接到页面上的元素,但是当您单击链接时页面会重新加载而不是移动到该元素。

<li>
    <a href="#image-0001"> <img alt="image0001" src="/assets/images/portfolio/photography/thumbs/0001.jpg" />
<span>Pointe</span> </a>
    <div class="lb-overlay" id="image-0001">
        <img alt="image01" src="/assets/images/portfolio/photography/full/0001.jpg" />
            <div>
                <h3>pointe <span>/point/</span></h3>
                <p>Dance performed on the tips of the toes</p>
            </div>
        <a class="lb-close" href="#page">x Close</a>
     </div>
</li> 

不是触发我的CSS动画,而是将我带到Site Root(localhost /#image-0001)。

任何想法如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

要使用锚点移动页面,目标锚点必须具有名称,而不是href。例如:

<a name="top" /> <!-- this is the target -->
<p>Some really long content</p>
<a href="#top">Go To Top</a> <!-- this goes to the target -->

这不是CodeIgniter特有的东西,只是基本的HTML。