radio-button 相关问题

单选按钮是表单中使用的元素。它们让用户只选择有限数量的选项中的一个。

无法正确对齐输入文本与单选按钮

HTML 你会推荐这个网站吗? HTML <fieldset> <label id="radio-buttons">Would you recommand this website? <input type="radio" name="radio" value="button" class="inline" checked>Yes</input> <input type="radio" name="radio" value="button" class="inline">No</input> <input type="radio" name="radio" value="button" class="inline">Maybe</input> </label> </fieldset> CSS input{ margin: 5px 0 0 0; width: 100%; min-height: 1.3em; } .inline{ width: unset; margin: 0 0.5em 0 0; vertical-align: middle; } 我尝试将单选按钮与文本本身对齐,但按钮最终比文本高出几个像素,我尝试了所有我能在网上找到的东西,但没有任何效果。 这可能是由 <label> 或 <fieldset> 元素上的默认填充或边距引起的。 尝试在您的 CSS 中为这些元素将 padding 和 margin 设置为 0,看看是否有帮助。 label, fieldset { padding: 0; margin: 0; } 如果没有,您可以尝试调整 .inline 类的 line-height 属性,直到文本和单选按钮按照您想要的方式对齐。 例如: .inline { line-height: 1.3em; /* rest of CSS */ } min-height 偏移你的对齐方式。你可以放下它,一切都很好。 你也可以摆脱垂直对齐。 在那种情况下,你需要重新做整个事情。这是一个快速修复。这里有更多关于如何在未来正确设置它的信息:https://developer.mozilla.org/en-US/docs/Web/HTML/Element/fieldset p { margin: 0; /* optional, for the sake of SO editing */ } <fieldset> <p>Would you recommand this website?</p> <input type="radio" name="radio" value="button" id="yes" checked> <label for="yes">Yes</label><br> <input type="radio" name="radio" value="button" id="no"> <label for="no">No</label><br> <input type="radio" name="radio" value="button" id="maybe"> <label for="maybe">Maybe</label><br> </fieldset> <Label> 和 <input> 这样不行。 这种方式点击Yes,No或Maybe将影响他们各自的单选框。 fieldset { width : fit-content; min-width : 20em; } label { display : inline-block; margin : .3em 2rem 0 0; } <fieldset> <legend> Would you recommand this website? </legend> <label> <input type="radio" name="radio" value="Yes" checked > Yes </label> <label> <input type="radio" name="radio" value="No" > No </label> <label> <input type="radio" name="radio" value="Maybe" > Maybe </label> </fieldset>

回答 3 投票 0

How to show/hide Input fields based on radiobutton/checkbox selection in sap ui5?

所以我正在做一个表格,我需要显示,如果选择了单选按钮,可以说两个输入。如果未选中,则什么也不会发生,用户将看不到这些输入。他们应该是

回答 0 投票 0

如何让单选按钮在表单上被选中?

我的单选按钮在单击时没有被选中,并且在浏览器的检查元素上没有发现错误。可能是什么问题呢?因为我使用了正确的名称并绑定了它们...

回答 2 投票 0

.NET Maui 单选按钮文本在黑暗模式下不可见?

还有其他人注意到 RadioButton 内容(至少在 iOS 上)忽略了 TextColor 属性吗?在深色模式下,无论我将其设置为什么,它都会将内容显示为白色文本。 还有人注意到 RadioButton Content(至少在 iOS 上)忽略了 TextColor 属性吗?在黑暗模式下,无论我将其设置为什么,它都会将内容显示为白色文本。 <RadioButton Content="Black Content Text" TextColor="{AppThemeBinding Light=Black, Dark=Black}" /> 这是毛伊岛的已知虫子吗?

回答 0 投票 0

C#虽然radiobuton checked=false,但是当我运行它的时候,它是勾选的

我正在尝试用 C# 制作简单的赛车游戏。我有 4 个单选按钮,它们的 checked 属性是错误的。当我查看我的代码时,我尝试了类似 radioButton1.checked=true 的东西但是当我运行 pr...

回答 0 投票 0

反应单选按钮和状态未按预期执行

我知道很多类似的问题已经被问过和回答过,但是我有一个 React 组件,它的单选按钮没有按预期执行...... const availableClasses = { 农民:{ 南...

回答 3 投票 0

Android:将单选组内的单选按钮对齐到水平中心

我有一个包含单选组的项目,它有 2 个水平方向的单选按钮。 这是 XML: 我有一个由 Radio Group 组成的项目,它有 2 个水平方向的单选按钮。 这是 XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/ll_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/bg_border" android:orientation="horizontal"> <RadioGroup android:id="@+id/rg_answer_truefalse" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.5" android:padding="0dp" android:layout_gravity="center" android:gravity="center" android:orientation="horizontal"> <RadioButton android:id="@+id/rb_answer_true" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.25" android:background="@drawable/bg_border" /> <RadioButton android:id="@+id/rb_answer_false" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="0.25" android:background="@drawable/bg_border" /> </RadioGroup> </LinearLayout> 问题是如何让每个单选按钮水平居中?我试过使用 layout_gravity 或 gravity 作为中心或 center_horizontal 但它似乎不起作用。谢谢 这是工作解决方案。不完美但有效。 <RadioGroup android:id="@+id/rg_answer_truefalse" android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="horizontal" android:weightSum="5"> <View android:layout_height="1dp" android:layout_weight="1" android:layout_width="0dp" /> <RadioButton android:id="@+id/rb_answer_true" android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="0dp" /> <View android:layout_height="1dp" android:layout_weight="1" android:layout_width="0dp" /> <RadioButton android:id="@+id/rb_answer_false" android:layout_height="wrap_content" android:layout_weight="1" android:layout_width="0dp" /> <View android:layout_height="1dp" android:layout_weight="1" android:layout_width="0dp" /> </RadioGroup>

回答 1 投票 0

从JSON数据渲染DataTables,如何在表上预选单选按钮?

我在我的数据集上渲染文本框和单选按钮。我能够在我的文本框内填充数据。但我如何根据JSON数据的值来选择单选按钮?$...

回答 1 投票 1

为什么检查的伪类没有响应?

我正在尝试对一些单选按钮进行样式设计,但选中的伪类并没有像预期的那样工作。我可以让悬停工作得很好。这只是一个大表单的一小部分,但我正在测试...。

回答 1 投票 0

在react中用动态生成的形式管理状态。

我有一个组件可以从api中获取一个json的问题列表。然后每个问题都有5个单选按钮供回答(从 "强烈不同意 "到 "强烈同意")。这些问题是...

回答 1 投票 1

在rails中点击单选按钮时,让文本字段显示出来+javascript。

你好,我想让日期文本字段在单选框 "自定义 "被点击时显示出来,而当另外两个单选框之一被点击时消失。到目前为止,我的表格是这样的:/Default radio ..: /Default radio ...

回答 1 投票 0

JavaScript创建一个单选按钮和一个标签

我试图用JavaScript创建一个单选按钮和一个标签,我让单选按钮工作了,但标签并没有出现在它旁边,我不知道我做错了什么。这是我的...

回答 1 投票 0

使用单选按钮更改网站 URL

这是一个简单的问题,但我遇到了问题。如果选中单选按钮,我想更改网站 url。这是我的引导程序单选按钮。 这是一个简单的问题,但我遇到了问题。如果选中单选按钮,我想更改网站 url。这是我的引导程序单选按钮。 <div class="btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-dark active"> <input type="radio" name="ai" id="option1" autocomplete="off" checked> Account Information </label> <label class="btn btn-dark"> <input type="radio" name="ps" id="option2" autocomplete="off"> Password And Security </label> <label class="btn btn-dark"> <input type="radio" name="c" id="option3" autocomplete="off"> Contact </label> </div> 也许像这样 <script> function change_loc(url){ document.location.href = url; } </script> <div class="btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-dark active"> <input type="radio" name="ai" id="option1" autocomplete="off" checked> Account Information </label> <label class="btn btn-dark"> <input type="radio" name="ps" id="option2" autocomplete="off" onclick="change_loc('https://www.google.com/')"> Password And Security </label> <label class="btn btn-dark"> <input type="radio" name="c" id="option3" autocomplete="off" onclick="change_loc('https://www.amazon.com/')"> Contact </label> </div> 不确定你想用 URL 做什么,也不知道为什么在收音机上有不同的名字,那么它们最好作为复选框 这将修改现有的 URL,您可以使用位置或历史 API 更改它 $(function() { $(".btn-group-toggle input[type=radio]").on("click",function() { let url = new URL(location.href); url.searchParams.set(this.id,this.name) console.log(url); // location = url; }) }) <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" /> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> <div class="btn-group btn-group-toggle" data-toggle="buttons"> <label class="btn btn-dark active"> <input type="radio" name="ai" id="option1" autocomplete="off" checked> Account Information </label> <label class="btn btn-dark"> <input type="radio" name="ps" id="option2" autocomplete="off"> Password And Security </label> <label class="btn btn-dark"> <input type="radio" name="c" id="option3" autocomplete="off"> Contact </label> </div> 我认为此解决方案不需要 JavaScript。 name="" 也必须相同才能使它们成为同一组。您可以选择添加 value=""。 <div class="btn-group btn-group-toggle" data-toggle="buttons"> <input type="radio" name="options" value="ai" id="option1" autocomplete="off" onclick="location.href='www.google.com/ai'" checked> Account Information<br /> <input type="radio" name="options" value="ps" id="option2" autocomplete="off" onclick="location.href='www.google.com/ps'"> Password And Security<br /> <input type="radio" name="options" value="c" id="option3" autocomplete="off" onclick="location.href='www.google.com/c'"> Contact<br /> </div>

回答 3 投票 0

如何使用div来为单选按钮设置样式,用javascript来实现

我想让单选按钮一个接一个地出现, 每个按钮都有自己的标签。我使用了一个循环,它通过一个json文件的内容,并创建单选按钮,其标签在......旁边。

回答 1 投票 0

安卓改变单选按钮的圆圈颜色和文字颜色。

当我点击单选按钮时,我想让文字的颜色和圆圈的颜色同时改变,如下图所示。注意 圆圈和文字的颜色选择是没有......

回答 1 投票 -1

我如何使用按钮制作一个单选按钮链接到一个页面

我如何做一个单选按钮,可以链接到一个页面,每个单选按钮被链接到一个网站,当我按下一个按钮,我希望它引导我到选定的单选按钮链接,我做......

回答 1 投票 0


我如何在我的网站上使用PHP或JavaScript将用户的分数存储在一个变量中?

现在我在我的页面上的模态中显示一个问题和它的可能答案(如下图所示)。提交答案 "按钮将发布表单,但我不能在我的情况下使用它(我在......解释了这个问题。

回答 2 投票 0

如何改变单选按钮的跨度文字?

我需要使用Javascript来改变一个radiobuttons列表旁边的span标签中的文字。我无法改变创建下面代码的代码。根据给定的条件,我需要修改 ...

回答 1 投票 0

如何在聊天机器人中提供单选按钮作为回复 我尝试了所有可能的解决方案,但没有成功。

def radio(): def sel(): selection = "你选择了选项" + str(var.get()) label.config(text = selection) var = IntVar() R1 = Radiobutton(base, text="选项1", ...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.