简体   繁体   English

如何使按钮go到另一页的中间

[英]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.

相关问题 有没有办法 go 到另一个页面,同时 go 到该页面中间的一个 id - Is there a way to go to another page and at the same time go to an id in the middle of that page 我试图让一个按钮转到另一个页面,但它不起作用 - I'm trying to make a button go to another page, but it's not working 如何使用提交按钮组合值添加多个下拉表单并将另一个 html 页面名称添加到 go - How to add multiple dropdown form with submit button combine value and make another html page name to go to it 我怎样才能让按钮向右移动,修复中间部分并使所有内容都可以调整大小 - How can I make button go right, fix middle section and make everything resizible 使按钮处于绝对居中和页面中间 - Make button in absolute centered and middle of page 如何将图像制作为按钮并将其重定向到另一个页面? - How to make an image as a button and redirect it to another page? 如何使添加的按钮转到页面上的不同部分? - How to make an added button go to a different section on the page? 如何让整个DIV可点击进入另一个页面? - How do you make the entire DIV clickable to go to another page? 如何将超链接转到另一个网站上的页面? - How do I make a hyperlink go to a page on another website? 如何选择表格到另一个页面? - How do I make a form selection go to another page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM