一键激活标签和链接 [英] Activate Label and Link with one click

查看:19
本文介绍了一键激活标签和链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一键激活标签和链接,因为我的菜单与链接一起工作并移动到页面的正确位置,但标签必须激活使内容放大并关闭菜单的按钮.我试过:

I want to make one click activate both, label and link, because my menu works with links and moves to the correct point of the page, but the label has to activate the button which makes the content enlarge and close the menu. I tried it with:

<label for="thebutton"><a href="#boxwithcontent">Click me</a></label>

但这只会激活链接或标签(如果标签区域更大).明白我的意思这里.

But that only activates the link or the label (if the label area is bigger). See what i mean here.

可能最难的问题是我不想使用 jquery.

Probably the hardest problem will be that I don´t want to use jquery.

我认为一种可能性是通过单选按钮控制滚动或通过链接控制单选按钮,但我找不到任何方法来做到这一点.

I think a possibility would either be to control the scroll via radio buttons or control the radio button via the link, but I can´t find any way to do that.

感谢您的努力

蒂姆

推荐答案

我可能误解了你的意图,但你可以试试这样的方法.

I may be misunderstanding your intention but you might just try something like this instead.

使用 HTML 进行快速编辑;

Using your HTML with a quickie edit;

<label for="magicbutton">Click Me</label>
<input id="magicbutton" type="checkbox" onclick='window.location.assign("#field")'/>

<div id="field"><p>
magic text
</p></div>

和您的 CSS 进行快速编辑;

and your CSS with a quickie edit;

#field{
    display:none;
    position:absolute;
    top:100%;
}

input {float: left;}

input#magicbutton:checked ~ #field{
    display:block;
}

...和小提琴 https://jsfiddle.net/L2ywu2ta/

我没有太大变化,希望它有所帮助.干杯.

I didn't change much, hope it helps. Cheers.

这篇关于一键激活标签和链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆