2013-12-10 74 views
1

我的页面由2个彼此相邻的div组成。链接到div内的更改位置

说左边的div是一本有不同章节的书。

我想我在正确的格链接到移动DIV中的内容有在顶部点击章(基本上向下滚动到这一章。

有可能是为了这个,我”一个简单的答案中号失踪,

任何帮助将是巨大的

+1

你必须证明你已经到目前为止已经试过你的工作,看到有巨大的事情处理这些类型的问题(HTTP [**是否应堆栈溢出奖励努力**?]://meta.stackexchange .COM /问题/ 210840 /应堆栈溢出待授牌,作为换工作?CB = 1)。所以不要归入这个类别。 – Praveen

+0

只是想快速回答,所以没有感到需要。它在我的问题中明确指出我想要什么,所以知道html/css的人可以在30秒内回答它。 – BigJayMalcolm

+0

但是如果没有代码,我们将无法看到您尝试过的内容,然后我们可能会回答您已经尝试过的内容。也许你在代码中有一些东西,然后我们不知道这些。 –

回答

1

试试这个:

<div id="text"> 
    <h1 id="chapterone">Chapter one</h1> 
    <p>The text of chapter 1</p> 
    <h1 id="chaptertwo">Chapter two</h1> 
    <p>The text of chapter 2</p> 
    <h1 id="chapterthree">Chapter three</h1> 
    <p>The text of chapter 3</p> 
</div> 
<div id="links"> 
    <a href="#chapterone">Chapter one</a> 
    <a href="#chaptertwo">Chapter two</a> 
    <a href="#chapterthree">Chapter three</a> 
</div> 

如果您使用ARW iFrame中看一看到jQuery ScrollTo

+0

完美的工作,谢谢! – BigJayMalcolm

+0

@BigJayMalcolm愉快,并记得勾选它。 –

+0

是啊,只是等待2分钟,直到我可以:) – BigJayMalcolm

0

最简单的方法就是使用href。这只有在你使用HTML构建“书”时才有用,它不是图像,PDF或其他内容。

给每个章节的标题,如“CH1”,“C”等一个唯一的ID

然后设置HREF链接章,如果1

<div id="left"> 
    <h1 id="ch1"> 
    <h2 id="ch2"> 
    #etc 
</div> 
<div id="right"> 
    <a href="#ch1">Chapter 1</a> 
    <a href = "#ch2">Chapter 2</a> 
    #etc 
</div> 

提醒你这只是作品“书“是HTML。如果它是iframed或是图像,然后查看jQuery插件Scrollto,它将允许您为要滚动到的每个元素设置滚动高度(以像素为单位)。

http://flesler.blogspot.com/2007/10/jqueryscrollto.html

0

您需要使用href,并使其发挥作用。章节标题的hrefid应该相同。这样它将导航到特定的标题。

<div> <!-- for links--> 
<a href="#firstChapter">FirstChapter </a> 
<a href="#secondChapter">Second Chapter </a> 
<a href="#lastChapter">Last Chapter </a> 
</div> 
<div> <!-- for Chapters --> 
<h1 id="firstChapter"> Chapter 1</h1> 
<p>Content of chapter </p> 
<h1 id="secondChapter"> Chapter 2</h1> 
<p>Content of chapter </p> 
<h1 id="lastChapter"> Chapter 10</h1> 
<p>Content of chapter </p> 
</div>