如何对齐此引导单选按钮?(How to align this bootstrap radio button?)
我使用以下代码创建单选按钮,按钮和文本彼此相邻。 这很好,但它不是垂直中间对齐文本输入字段,它放在单选按钮上。
<div class="col-md-3"> <div id="edit-donation-frequent" class="form-radios form-group"> <div class="form-item form-type-radio form-item-donation-frequent"> <input type="radio" id="edit-donation-frequent-monthly" name="donation_frequent" value="monthly" class="form-radio" /> <label class="option font-size-sixteen" for="edit-donation-frequent-monthly">Monthly</label> </div> </div> </div> <div class="col-md-3"> <div class="form-item form-type-radio form-item-donation-frequent form-group"> <input type="radio" id="edit-donation-frequent-once" name="donation_frequent" value="once" class="form-radio" /> <label class="option font-size-sixteen" for="edit-donation-frequent-once">One time </label> </div> </div>
我把
.form-item label.option { vertical-align: middle; }
但仍然是相同的结果。 然后我尝试了margin-top和其他一些CSS样式,但无法得到我想要的东西。我想要两个单选按钮(每月,一次和固定电话)看起来像下面的截图。
和
如何像屏幕截图一样调整页面。
[UPDATE]
根据Rachel的请求的部分(行)代码(无论如何,通过访问此页面,您可以查看源代码):
<div class="row"> <div class="col-md-3"> <div class="form-item form-type-textfield form-item-donation-amount form-group"> <input type="text" id="edit-donation-amount" name="donation_amount" value="" maxlength="128" class="form-text form-control" placeholder="Amount"/> </div> </div> <div class="col-md-3"> <div class="form-item form-type-select form-item-donation-currency form-group"> <select id="edit-donation-currency" name="donation_currency" class="form-select form-control"> <option value="DKK">DKK</option> <option value="GBP">GBP</option> <option value="USD">USD</option> <option value="EUR">EUR</option> </select> </div> </div> <div class="col-md-3"> <div id="edit-donation-frequent" class="form-radios form-group"> <div class="form-item form-type-radio form-item-donation-frequent"> <input type="radio" id="edit-donation-frequent-monthly" name="donation_frequent" value="monthly" class="form-radio" /> <label class="option font-size-sixteen" for="edit-donation-frequent-monthly">Monthly</label> </div> </div> </div> <div class="col-md-3"> <div class="form-item form-type-radio form-item-donation-frequent form-group"> <input type="radio" id="edit-donation-frequent-once" name="donation_frequent" value="once" class="form-radio" /> <label class="option font-size-sixteen" for="edit-donation-frequent-once">One time </label> </div> </div> </div>
I created radio button using following code and the button & the text comes next to each other. That's fine but it is not VERTICALLY middle aligned to the text input field which is placed left to the radio button.
<div class="col-md-3"> <div id="edit-donation-frequent" class="form-radios form-group"> <div class="form-item form-type-radio form-item-donation-frequent"> <input type="radio" id="edit-donation-frequent-monthly" name="donation_frequent" value="monthly" class="form-radio" /> <label class="option font-size-sixteen" for="edit-donation-frequent-monthly">Monthly</label> </div> </div> </div> <div class="col-md-3"> <div class="form-item form-type-radio form-item-donation-frequent form-group"> <input type="radio" id="edit-donation-frequent-once" name="donation_frequent" value="once" class="form-radio" /> <label class="option font-size-sixteen" for="edit-donation-frequent-once">One time </label> </div> </div>
I put
.form-item label.option { vertical-align: middle; }
but still the same result. Then I tried margin-top and some other css styles but could not get what I want.I want the both radio buttons(monthly, onetime AND Landline) look like following screenshot.
and
how can I adjust the page like screen shots.
[UPDATE]
Code for the section (row) as per Rachel's request (Anyhow by visiting this page you can have a look at the source code):
<div class="row"> <div class="col-md-3"> <div class="form-item form-type-textfield form-item-donation-amount form-group"> <input type="text" id="edit-donation-amount" name="donation_amount" value="" maxlength="128" class="form-text form-control" placeholder="Amount"/> </div> </div> <div class="col-md-3"> <div class="form-item form-type-select form-item-donation-currency form-group"> <select id="edit-donation-currency" name="donation_currency" class="form-select form-control"> <option value="DKK">DKK</option> <option value="GBP">GBP</option> <option value="USD">USD</option> <option value="EUR">EUR</option> </select> </div> </div> <div class="col-md-3"> <div id="edit-donation-frequent" class="form-radios form-group"> <div class="form-item form-type-radio form-item-donation-frequent"> <input type="radio" id="edit-donation-frequent-monthly" name="donation_frequent" value="monthly" class="form-radio" /> <label class="option font-size-sixteen" for="edit-donation-frequent-monthly">Monthly</label> </div> </div> </div> <div class="col-md-3"> <div class="form-item form-type-radio form-item-donation-frequent form-group"> <input type="radio" id="edit-donation-frequent-once" name="donation_frequent" value="once" class="form-radio" /> <label class="option font-size-sixteen" for="edit-donation-frequent-once">One time </label> </div> </div> </div>
原文:https://stackoverflow.com/questions/36748380
最满意答案
您需要在对话框中设置
OnKeyListener
并检查是否按下了后退键。以下是适合您需要的示例代码,您需要修改代码,如下所示:
AlertDialog alertDialog = new AlertDialog.Builder(this,R.style.myBackgroundStyle).create(); alertDialog.setTitle("Exit Alert"); alertDialog.setMessage("Do you really want to exit the Game?"); alertDialog.setButton("Quit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //Best way is firstly use finish() and after that use System.exit(0) to clear static variables. It will give you some free space. // A lot of applications leave working processes and variables what makes me angry. After 30 minutes of using memory is full and i have to run Task Manager - Lvl 2 clear memory finish(); System.exit(0); return; } }); //New part regarding the back key when only dialog is shown. alertDialog.setOnKeyListener(new Dialog.OnKeyListener() { @Override public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { alertDialog.dismiss(); } return true; } });
这只有在显示对话框时才有效,因此,您可以返回到您的活动
You need to set an
OnKeyListener
to your dialog and check whether back key is pressed.Here is a sample code that suits your need, you need to modify your code as follows:
AlertDialog alertDialog = new AlertDialog.Builder(this,R.style.myBackgroundStyle).create(); alertDialog.setTitle("Exit Alert"); alertDialog.setMessage("Do you really want to exit the Game?"); alertDialog.setButton("Quit", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { //Best way is firstly use finish() and after that use System.exit(0) to clear static variables. It will give you some free space. // A lot of applications leave working processes and variables what makes me angry. After 30 minutes of using memory is full and i have to run Task Manager - Lvl 2 clear memory finish(); System.exit(0); return; } }); //New part regarding the back key when only dialog is shown. alertDialog.setOnKeyListener(new Dialog.OnKeyListener() { @Override public boolean onKey(DialogInterface arg0, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK) { alertDialog.dismiss(); } return true; } });
this will work only when the dialog is shown, therefore, you would be able to return to your activity
相关问答
更多-
你的OK按钮是Dialog视图的一部分,所以你必须使用你的对话框对象引用找到那个视图,比如,(我不熟悉xamarin但这个给你提示) 改变你的路线, // Problem starts here: Button saveNewFamily = FindViewById
-
myAlertBox.setCancelable(false); myAlertBox.setCancelable(false);
-
在正面按钮的onclick中创建另一个对话框,这样的事情 dialogBuilder = new AlertDialog.Builder(this); dialogBuilder.setTitle("Title"); dialogBuilder.setPositiveButton("Next", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int ...
-
使用InputMap和ActionMap来处理Swing中的关键动作。 要干净地关闭对话框,请向其发送一个关闭窗口事件。 从我的博客 : private static final KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); public static final String dispatchWindowClosingActionMapKey = "com.spodding.tackli ...
-
这应该与Dialog类一起工作: AudioManager man = (AudioManager)getSystemService(Context.AUDIO_SERVICE); dialog.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { switch (event.get ...
-
按下BackKey上的对话框(Dialog on BackKey pressed)[2023-02-09]
您需要在对话框中设置OnKeyListener并检查是否按下了后退键。 以下是适合您需要的示例代码,您需要修改代码,如下所示: AlertDialog alertDialog = new AlertDialog.Builder(this,R.style.myBackgroundStyle).create(); alertDialog.setTitle("Exit Alert"); alertDialog.setMessage("Do you really want to ex ... -
更新1 protected override void GoBack(object sender, RoutedEventArgs e) { base.GoBack(sender, e); //Your logic goes here } 我认为你正在使用LayoutAwarePage类。 它实现了GoBack事件。 您可以编辑实施。 LayoutAwarePage.cs将在项目的公共文件夹中。 UPDATE 1 protected override void GoBack(object ...
-
你正在寻找这个 getSupportFragmentManager().popBackStack(); 如果你不知道这是实际的android后退按钮的默认功能,那么除非你已经覆盖了它,它将做同样的事情。 you're looking for this getSupportFragmentManager().popBackStack(); also if you're unaware that's the default functionality for the actual android back ...
-
qt创建对话框(qt create dialog)[2024-03-21]
如果你使用dialog->show()那么我认为它是非模态对话框。 如果您已创建QDialogButtonBox并将其信号与对话框的accept()和reject()插槽连接,如文档所示 ,那么您的对话框将发出finished(int)和另外accepted()或rejected()信号,您可以通过这些信号确定如何它被关闭了。 如果您需要更多自定义行为,则可以重新实现closeEvent(QCloseEvent *event)或创建自己的singnals。 如果需要删除对话框,可以使用setAttribut ... -
在onCreateView ,您可以添加DialogFragment.getDialog().setCanceledOnTouchOutside(true); @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { ... getDialog().setCanceledOnTouchOutside(true); ... ...