[英]how to make button go to the middle of another page
I will not add the code but I need to make my button not just go to another page, but go to the middle section of the page.我不会添加代码,但我需要让我的按钮不仅仅是 go 到另一个页面,而是 go 到页面的中间部分。 Like I want the button to lead to a scrolled down page.
就像我希望按钮指向向下滚动的页面一样。 Does anyone know what to do?
有谁知道该怎么办?
add id in the div of the page like <div id="hello">some thing here</div>
and on button you can use something like this <button><a href="#hello">scroll</a></button>
在页面的 div 中添加 id,例如
<div id="hello">some thing here</div>
,在按钮上您可以使用类似这样的东西<button><a href="#hello">scroll</a></button>
I'm assuming that just want your button to scroll down to section of the page.我假设只是希望您的按钮向下滚动到页面的一部分。 if i'm wrong then comment I'll edit the answer according to it.
如果我错了然后评论我会根据它编辑答案。
#hello{ margin-top:20px; margin-bottom:500px; }.height{ height:500px; } html{ scroll-behavior:smooth; }
<div> <button> <a class="scroll" href="#hello">scroll</a> </button> <div class="height"> </div> <div id="hello">Hello</div> </div>
I believe the simplest way to achieve this would be to create a pair of tags, one for the button and one that is invisible at the desired destination.我相信实现此目的的最简单方法是创建一对标签,一个用于按钮,另一个在所需目的地不可见。 A basic example would be as follows:
一个基本的例子如下:
<body>
<div id="header">
<h1>Title</h1>
</div>
<div class="outer">
<div class="inner">
<a href="#third"><button>Go To 3rd Section</button></a>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</div>
<div class="inner">
<h1>My Second Heading</h1>
<p>My second paragraph.</p>
</div>
<div class="inner">
<a id="third"></a>
<h1>My Third Heading</h1>
<p>My third paragraph.</p>
</div>
</div>
</body>
After applying the appropriate css for your application, this would be a very simple way to link to a particular part of the page.在为您的应用程序应用适当的 css 之后,这将是链接到页面特定部分的一种非常简单的方法。 The destination 'a' tag has a specified id
目标“a”标签具有指定的 ID
<a id="destination"></a>
while the corresponding button, which is wrapped inside an 'a' tag, has the href pointing to a particular id而包裹在“a”标签内的相应按钮具有指向特定 id 的 href
<a href="#destination"><button>Destination</button></a>
. <a href="#destination"><button>Destination</button></a>
。
Hope this answers your question!希望这能回答您的问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.