在本文中,我们将带你了解css–样式单选按钮在这篇文章中,我们将为您详细介绍css–样式单选按钮的方方面面,并解答css单选按钮设置常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的andro
在本文中,我们将带你了解css – 样式单选按钮在这篇文章中,我们将为您详细介绍css – 样式单选按钮的方方面面,并解答css单选按钮设置常见的疑惑,同时我们还将给您一些技巧,以帮助您实现更有效的android – 如何从动态创建的单选按钮中选择一个单选按钮?、css – 单选按钮背景图片、css – 如何在引导表中设置单选按钮或复选框的样式?、css – 如何更改单选按钮的颜色?。
本文目录一览:- css – 样式单选按钮(css单选按钮设置)
- android – 如何从动态创建的单选按钮中选择一个单选按钮?
- css – 单选按钮背景图片
- css – 如何在引导表中设置单选按钮或复选框的样式?
- css – 如何更改单选按钮的颜色?
css – 样式单选按钮(css单选按钮设置)
我正试图制作更大的单选按钮,没有任何运气.
这是一个自定义WP插件,所有者不支持用户提出这类问题.
我试图遵循许多教程,如one,但代码结构通常是不同的:
我的代码是
<lidata-pos="1"> <spanhttps://www.jb51.cc/tag/dis/" target="_blank">display:none;">1. </span> <label> <inputtype="radio" name="question_1" value="323"/> Answer 1 </label> </li>
在教程中代码显示为
<td> <input type="radio" name="radiog_dark" id="radio1"https://www.jb51.cc/tag/css/" target="_blank">css-checkBox" /> <label for="radio1"https://www.jb51.cc/tag/css/" target="_blank">css-label radGroup2">Option 1</label> </td>
有人能帮我吗?
里卡多
解决方法
<ul> <li> <label> <inputtype="radio" name="question_1_2" value="3" /> <spanhttps://www.jb51.cc/tag/dio/" target="_blank">dio"></span> Non riesco a lasciarlo solo </label> </li> </ul>
CSS:
input[type="radio"] { display: none; } .graphical-radio { background: gray; display: inline-block; width: 30px; height: 30px; border-radius: 100%; } input[type="radio"]:checked + .graphical-radio { background: red; }
神奇之处在于:选中选择器,因此您可以根据需要设置图形收音机的样式.
jsFiddle Demo.
android – 如何从动态创建的单选按钮中选择一个单选按钮?
我有一个问题,如“最近的调查发现,在英国的中学”有4个选项,如
一个.
B.
C.
D.
所有数据都以json形式来自服务器.我用一个问题动态创建了视图,使用单选按钮创建了四个选项.但我所理解的是每一行都是新行,我无法从所有单选按钮中只选择一个单选按钮.每个按钮都单独选择,但我只想选择一个单击的单选按钮.
任何帮助,将不胜感激.
你可以在下面看到我的观点:
我的代码是:
LinearLayout linearLayoutForQuestions = (LinearLayout) view.findViewById(R.id.questionsLinearLayout); linearLayoutForQuestions.removeAllViews(); //set the questions for the user for (int ss = 0; ss < totalNoOfQuestions.size(); ss++) { final List<String> list = new ArrayList(); list.add("SELECT"); TextView textView = new TextView(activity); textView.setTextSize(15); textView.setTextColor(view.getResources().getColor(R.color.black)); textView.setTypeface(typeface1); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT); params.setMargins(0,20,0); textView.setLayoutParams(params); String question = totalNoOfQuestions.get(ss).getQuestions(); String questionNo = totalNoOfQuestions.get(ss).QuestionNo; textView.setText("Question " + questionNo + " " + question); //linearlayout and set data inside it LinearLayout parent = new LinearLayout(activity); parent.removeAllViews(); parent.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT)); parent.setorientation(LinearLayout.VERTICAL); int optionSize = totalNoOfQuestions.get(ss).getoptions().size(); for (int s = 0; s < optionSize; s++) { //children of parent linearlayout LinearLayout layout2 = new LinearLayout(activity); layout2.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT)); layout2.setorientation(LinearLayout.HORIZONTAL); layout2.setGravity(Gravity.CENTER); String optionNo = totalNoOfQuestions.get(ss).getoptions().get(s).getQuestionoptionNo(); TextView textView1 = new TextView(activity); textView1.setText(optionNo); textView.setTextSize(15); final RadioButton radioButton = new RadioButton(activity.getApplicationContext()); radioButton.setId(s); radioButton.setBackgroundResource(R.drawable.settings_background_ripple); LinearLayout.LayoutParams pa = new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT)); pa.setMargins(10,10,10); radioButton.setLayoutParams(pa); radioButton.setonCheckedchangelistener(new CompoundButton.OnCheckedchangelistener() { @Override public void onCheckedChanged(CompoundButton buttonView,boolean isChecked) { int checkedRadioButtonId = buttonView.getId(); Toast.makeText(activity,"hit it",Toast.LENGTH_SHORT).show(); } }); String questionoption = totalNoOfQuestions.get(ss).getoptions().get(s).getQuestionoption(); TextView textView2 = new TextView(activity); textView2.setTextSize(15); textView2.setText(questionoption); layout2.addView(textView1); layout2.addView(radioButton); layout2.addView(textView2); parent.addView(layout2); } linearLayoutForQuestions.addView(textView); linearLayoutForQuestions.addView(parent); }
解决方法
谢谢大家的帮助.快乐编码:)
LinearLayout linearLayoutForQuestions = (LinearLayout) view.findViewById(R.id.questionsLinearLayout); linearLayoutForQuestions.removeAllViews(); totalNoOfQuestions = readingTests[countReadingTest].getQuestion(); //set the questions for the user for (int ss = 0; ss < totalNoOfQuestions.size(); ss++) { groupNo = ss; final List<String> list = new ArrayList(); list.add("SELECT"); TextView textView = new TextView(activity); textView.setTextSize(15); textView.setTextColor(view.getResources().getColor(R.color.black)); textView.setTypeface(typeface1); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,0); textView.setLayoutParams(params); String question = totalNoOfQuestions.get(ss).getQuestions(); String questionNum = totalNoOfQuestions.get(ss).QuestionNo; textView.setText("Question " + questionNum + " " + question); //linearlayout and set data inside it LinearLayout parent = new LinearLayout(activity); parent.removeAllViews(); parent.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT)); parent.setorientation(LinearLayout.VERTICAL); final int optionSize = totalNoOfQuestions.get(ss).getoptions().size(); final RadioButton[] radioButton = new RadioButton[optionSize]; int size = totalNoOfQuestions.size(); final RadioGroup[] radioGroup = new RadioGroup[size]; //you can also create in xml radioGroup[ss] = new RadioGroup(activity); radioGroup[ss].setId(ss + 100); radioGroup[ss].setorientation(RadioGroup.VERTICAL)ø; //this textview is for the optionsNo like A,B,C,D final TextView[] textView1 = new TextView[optionSize]; LinearLayout layoutoptionsNo = new LinearLayout(activity); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.MATCH_PARENT); layoutoptionsNo.setorientation(LinearLayout.VERTICAL); layoutoptionsNo.setWeightSum(optionSize); layoutoptionsNo.setGravity(Gravity.CENTER); layoutoptionsNo.setPadding(10,0); layoutoptionsNo.setLayoutParams(layoutParams); LinearLayout layoutoptions = new LinearLayout(activity); layoutoptions.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT,1.0f)); layoutoptions.setorientation(LinearLayout.HORIZONTAL); layoutoptions.setWeightSum(4); layoutoptions.setGravity(Gravity.CENTER); //inner loop for the options for every single question for (int s = 0; s < optionSize; s++) { String optionNo = totalNoOfQuestions.get(ss).getoptions().get(s).getQuestionoptionNo(); textView1[s] = new TextView(activity); textView1[s].setText(optionNo); textView1[s].setTextSize(15); textView1[s].setGravity(Gravity.CENTER); LinearLayout.LayoutParams pa = new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT)); pa.setMargins(10,10); pa.weight = 1; textView1[s].setLayoutParams(pa); String questionoption = totalNoOfQuestions.get(ss).getoptions().get(s).getQuestionoption(); radioButton[s] = new RadioButton(activity); radioButton[s].setId(s); radioButton[s].setText(questionoption); radioButton[s].setTextSize(15); radioButton[s].setPadding(2,2,2); radioButton[s].setBackgroundResource(R.drawable.settings_background_ripple); LinearLayout.LayoutParams pa2 = new LinearLayout.LayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT,1.0f)); pa2.setMargins(10,10); pa2.weight = 1; radioGroup[ss].setLayoutParams(pa2); radioGroup[ss].addView(radioButton[s]); layoutoptionsNo.addView(textView1[s]); } radioGroup[ss].setonCheckedchangelistener(new RadioGroup.OnCheckedchangelistener() { @Override public void onCheckedChanged(RadioGroup group,int checkedId) { int originalId ; int id = group.getId();{ originalId = id-100; } questionNo = totalNoOfQuestions.get(originalId).getQuestionNo(); optionNo = totalNoOfQuestions.get(0).getoptions().get(checkedId).getQuestionoptionNo(); } }); layoutoptions.addView(layoutoptionsNo); layoutoptions.addView(radioGroup[ss]); parent.addView(layoutoptions); linearLayoutForQuestions.addView(textView); linearLayoutForQuestions.addView(parent); } boolean showOptionHint = totalNoOfQuestions.get(0).OptionList; LinearLayout linearLayoutForOptions = (LinearLayout) view.findViewById(R.id.optionsLinearLayout); linearLayoutForOptions.removeAllViews(); if (showOptionHint == true) { //dynamic creation of options under the quesiton layout List<ReadingTest.QuestionBean.OptionsBean> questionoptions = readingTests[countReadingTest].getQuestion().get(0).getoptions(); for (int ss = 0; ss < questionoptions.size(); ss++) { String options = questionoptions.get(ss).getQuestionoption(); String optionsNo = questionoptions.get(ss).getQuestionoptionNo(); TextView textView = new TextView(activity); textView.setTextSize(18); textView.setTypeface(typeface); textView.setTextColor(view.getResources().getColor(R.color.black)); textView.setText(optionsNo + ". " + options); linearLayoutForOptions.addView(textView); } }
css – 单选按钮背景图片
这是我的代码
<div> <label for="shipadd2"> <input type="radio" id="shipadd2" name="address" /> <div> Lorem ipsum </div> </label> </div>
CSS是
.fieldlist input[type="radio"] { float: right; -webkit-appearance: none; border: none; width: 25px; height: 25px; background: url(images/radio.png) left center no-repeat; background-size: 20px; } .fieldlist input[type="radio"]:checked { background: url(images/radio_checked.png) left center no-repeat; }
解决方法
CSS:
input[type="radio"]{ display:none; } input[type="radio"] + label { background: #999; height: 16px; width: 16px; display:inline-block; padding: 0 0 0 0px; } input[type="radio"]:checked + label { background: #0080FF; height: 16px; width: 16px; display:inline-block; padding: 0 0 0 0px; }
HTML
<input type="radio" id="shipadd2" name="address" /> <label for="shipadd2"></label>
阅读这篇文章了解更多http://css-tricks.com/the-checkbox-hack/
css – 如何在引导表中设置单选按钮或复选框的样式?
解决方法
Font Awesome用于收音机按钮,所以一定要包含它.
input[type=radio] { display: none; } label { cursor: pointer; } input[type=radio] + label:before { font-family:'FontAwesome'; display: inline-block; } input[type=radio] + label:before { content:"\f10c"; color: #f00; cursor: pointer; } input[type=radio] + label:before { letter-spacing: 10px; } input[type=radio]:checked + label:before { content:"\f111"; color: #fff; /* Remove this if you remove the 3 Last Rules of the CSS */ }
片段
/* Delete the JS Below to Remove the Hover Effect and to Make the Buttons + Label the only Active Area */ $('.table tr').click(function(event) { if (event.target.type !== 'radio') { $(':radio',this).trigger('click'); } }); $(":radio[name=radios]").change(function() { $(".table tr.active").removeClass("active"); $(this).closest("tr").addClass("active"); });
.wrapper { margin-top: 40px; } .table-striped { background-color: rgba(77,162,179,0.35); color: #4DA2B3; } .table-responsive { border-color: transparent; font-size: 20px; cursor: pointer; /* Remove this if you remove the 3 Last Rules Rules of the CSS */ } .table tbody tr td { line-height: 24px; padding-top: 12px; } input[type=radio] { display: none; } label { cursor: pointer; } input[type=radio] + label:before { font-family: 'FontAwesome'; display: inline-block; font-size: 20px; font-weight: 200; } input[type=radio] + label:before { content: "\f10c"; /* The Open Circle Can be replaced with another Font Awesome Icon */ color: #4DA2B3; cursor: pointer; } input[type=radio] + label:before { letter-spacing: 10px; } input[type=radio]:checked + label:before { content: "\f05d"; /* Replace with f111 for a Solid Circle (or any other Font Awesome Icon */ color: #fff; /* Remove this if you remove the 3 Last Rules of the CSS */ } /* Delete the Rules Below (and 2 above with Comments) to Remove the Hover Effect and to Make the Buttons + Label the only Active Area */ .table tbody tr:hover td { background-color: rgba(77,0.55); color: #fff; border-bottom: 10px solid rgba(7,101,120,0.85); } .table tbody tr.active td { background-color: rgba(77,0.55); color: #fff; } .table tbody tr.active td label { color: #fff; }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> <div> <div> <div> <table> <tbody> <tr> <td>Series A</td> <td>Product A</td> <td> <input type="radio" name="radios" id="radio1" /> <label for="radio1">Yes</label> </td> </tr> <tr> <td>Series B</td> <td>Product B</td> <td> <input type="radio" name="radios" id="radio2" /> <label for="radio2">No</label> </td> </tr> <tr> <td>Series C</td> <td>Product C</td> <td> <input type="radio" name="radios" id="radio3" /> <label for="radio3">Maybe</label> </td> </tr> </tbody> </table> </div> </div> </div>
css – 如何更改单选按钮的颜色?
解决方法
我们今天的关于css – 样式单选按钮和css单选按钮设置的分享已经告一段落,感谢您的关注,如果您想了解更多关于android – 如何从动态创建的单选按钮中选择一个单选按钮?、css – 单选按钮背景图片、css – 如何在引导表中设置单选按钮或复选框的样式?、css – 如何更改单选按钮的颜色?的相关信息,请在本站查询。
本文标签: