简体   繁体   English

我在标签旁边有一个图标,当您单击该图标时,它不应单击该标签所附的标签/单选按钮

[英]I have an icon next to a label and when you click the icon, it should not click the label/radio button that the label is attached to

I have an issue. 我有一个问题。 I am trying to create a single line that contains a radio, a label, and a clickable icon and I want all of these elements to be inline. 我正在尝试创建一个包含收音机,标签和可点击图标的单行,并且我希望所有这些元素都是内联的。 I want it to be set up like: 我希望将其设置为:

Radio Label Icon

in that order. 以该顺序。 My code HTML looks like this: 我的代码HTML如下所示:

    <div class="wrapper class>
        <div class="radio" label="this is my label">
            <input type="radio" value="1" required>
            <i class="material-icons" ng-click="some-action">info_outline</i>
        </div>
    </div>

I have tried to place the icon outside of the label class, but it does not display inline and I have also tried to use display:inline; 我试图将图标放置在label类之外,但是它不显示内联,并且我也尝试使用display:inline;。 in my CSS code, to no avail. 在我的CSS代码中,无济于事。 I am trying to just separate the icon and the label, but I cannot seem to get this to work. 我试图仅将图标和标签分开,但似乎无法使它正常工作。

Any and all help would be greatly appreciated! 任何和所有帮助将不胜感激!

Thank you in advance! 先感谢您!

Change the div class="radio" to an span: 将div class =“ radio”更改为span:

<div class="wrapper">
    <span class="radio" label="this is my label">
        <input type="radio" value="1" required>
        <i class="material-icons" ng-click="some-action">info_outline</i>
    </span>
</div>

https://jsfiddle.net/qq3nLwp3/ https://jsfiddle.net/qq3nLwp3/

And improved with some css: 并通过一些CSS进行了改进:

div.wrapper input, div.wrapper i { {
    vertical-align: middle;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM