I'm using Bootstrap 3 and trying to center a radio button, an icon, and some text and am having no luck.
My form simply is simply stuffing everything inside a label tag which seems to be a lot.
The skeleton code I started with is below:
<form role="form">
<label class="radio-inline">
<input type="radio" name="optradio">
<br/>
<div class="iconOne"></div>
<br/>
Option 1
</label>
<label class="radio-inline">
<input type="radio" name="optradio">
<br/>
<div class="iconTwo"></div>
<br/>
Option 2
</label>
<label class="radio-inline">
<input type="radio" name="optradio">
<br/>
<div class="iconThree"></div>
<br/>
Icon Three
</label>
</form>
Here's the JS fiddle:
http://jsfiddle.net/4zh28rcn/4/
I'm tempted to try something like Flexbox but am wary of importing more third party libraries.
Thanks for any helpful pointers!
I'm not sure where it's coming from, but you appear to have a stray alignment pushing the <input> 20px to the left of where it ought to be.
If you add the CSS below to what you have in your fiddle already, you will see the radio buttons, the icon images and the text all centered and all lined up:
.radio-inline {
width: 100px;
padding: 0;
text-align: center;
}
input {
display: block;
position: relative;
left: 20px;
width: 100%;
}
Related
Is there a right way to stack radio buttons in Bulma?
Their example places each button on the same line:
<div class="control">
<label class="radio">
<input type="radio" name="foobar">
Foo
</label>
<label class="radio">
<input type="radio" name="foobar" checked>
Bar
</label>
</div>
I'm hoping to get something like this:
Would it be as straight forward as adding <br> tags, or does Bulma have a different better way for maintaining responsiveness?
A <br> tag between labels will work just fine.
While <br> works fine, it does not allow you to configure space between radio options flexible. For example, I can see a space between options in your example image.
In order to achieve that, I've added the following class to my SCSS:
.radio-list {
.radio {
display: block;
& + .radio {
margin-left: 0;
margin-top: .5em;
}
}
}
And now just add radio-list class to your control like this:
<div class="control radio-list">
<label class="radio">
<input type="radio" name="foobar">
Foo
</label>
<label class="radio">
<input type="radio" name="foobar" checked>
Bar
</label>
</div>
Now it looks like this:
I am trying to create a simple multiple-choice quiz. This is the layout I am trying to achieve:
However, I am having some difficulty implementing the CSS needed to control the spacing needed for that.
I changing the display for each input to "block" and while this put each radio button a separate line, it also put the text for that radio button on a separate line as well, so that it looked like this:
As that is clearly not what is wanted, how can I force each of the radio buttons to be on separate lines but also keep the text for each radio input on the same line? I also want to be able to reduce the space between the question number and the options for that question, and then increase the space between each question (each question is currently a div) and sometimes messing around with one thing screws up the other.
The full HTML and CSS for the page can be found here:
http://interlinked.x10host.com/projects/landlines/telcoquiz.html
The relevant HTML is:
<div id="quiz">
<div id="quiztext">
<p>Let's get started!</p>
<p>You will be taking the 10-question Telephone Quiz. All questions are multiple-choice, with one correct answer each. If you pass, you will recieve the Honorary Telephone Award!</p>
</div>
<div id="form">
<form id="telcoform">
<div class="quizItem"><p class="qNumber">1</p>
<input type="radio" name="question1" value="1a">Option A</input>
<input type="radio" name="question1" value="1b">Option B</input>
</div>
<div class="quizItem"><p class="qNumber">2</p>
<input type="radio" name="question2" value="2a">Option A</input>
<input type="radio" name="question2" value="2b">Option B</input>
<input type="radio" name="question2" value="2c">Option C</input>
</div>
</form>
</div>
</div>
The relevant CSS is:
#quiz {
display: none;
}
#beginButton, #quiztext {
text-align: center;
}
#form {
text-align: left;
margin-left: 115px;
margin-right: 115px;
}
#telcoform {
}
.quizItem {
}
.quizItem input {
}
.qNumber {
font-family: 'merriweatherregular';
font-weight: 700;
}
To have each input/text combo be on it's own line, just wrap them in a block element. Though your text should also be in a label that is associated with the input - isn't necessary, but is better, more accessible markup, and better UX because it allows you to click on the text to select the input.
#beginButton,
#quiztext {
text-align: center;
}
#form {
text-align: left;
margin-left: 115px;
margin-right: 115px;
}
#telcoform {}
.quizItem {}
.quizItem input {}
.qNumber {
font-family: 'merriweatherregular';
font-weight: 700;
}
<div id="quiz">
<div id="quiztext">
<p>Let's get started!</p>
<p>You will be taking the 10-question Telephone Quiz. All questions are multiple-choice, with one correct answer each. If you pass, you will recieve the Honorary Telephone Award!</p>
</div>
<div id="form">
<form id="telcoform">
<div class="quizItem">
<p class="qNumber">1</p>
<div><input type="radio" name="question1" value="1a" id="q-1a"><label for="q-1a">Option A</label></div>
<div><input type="radio" name="question1" value="1b" id="q-1b"><label for="q-1b">Option B</label></div>
</div>
<div class="quizItem">
<p class="qNumber">2</p>
<div><input type="radio" name="question2" value="2a" id="q-2a"><label for="q-2a">Option A</label></div>
<div><input type="radio" name="question2" value="2b" id="q-2b"><label for="q-2b">Option B</label></div>
<div><input type="radio" name="question2" value="2c" id="q-2c"><label for="q-2c">Option C</label></div>
</div>
</form>
</div>
</div>
Im crating a form with many fields and a checkboxes, the problem is that im trying to customize the checkbox(unsuccessfully) according with the style of my form.
As you can see in the picture, the tick of the checkbox is black, and i need it green. How can I change the color? How can I change the size of checkbox?
This is my HTML:
<div id="Cajamitad1">
<form role="form">
<div class="checkbox">
<label><input type="checkbox" value="" >
<a class="FontStyle">Vegano</a>
</label>
</div>
< div class="checkbox">
<label><input type="checkbox" value="">
<a class="FontStyle">Diabetico</a>
</label>
</div>
<div class="checkbox">
<label><input type="checkbox" value="">
<a class="FontStyle">Celiaco</a>
</label>
</div>
</form>
</div>
and this my CSS:
#ContForm{
display: inline;
box-sizing: border-box;
}
.checkbox{
margin: 10px;
padding: 10px;
}
.checkbox input[type="checkbox"]{
margin-left: 5px;
}
#Cajamitad1{
margin-top: 10px;
width: 40%;
float: left;
padding-left: 200px;
}
Correct me if I'm wrong, but as far as I know this is not possible.
Here is my reasoning: if you inspect the bootstrap checkbox then you see that the checkbox itself is drawn by an <input type="checkbox"> and you have very limited control over that. Some browsers let you change the size of the checkbox but not all of them.
So the only thing you can do is to make your own checkbox, e.g. by using two images and some css.
Or often more mobile friendly are just two buttons side by side "yes" and "no". Then if you click one it becomes active, like some kind of toggle button.
I'm putting together a simple form to deposit a set amount of money. The form has 4 radio buttons.
<form action="deposit.php" method="post">
<fieldset>
<div class="form-group">
<input type="radio" name="deposit" value="100"> $100
<br>
<input type="radio" name="deposit" value="250"> $250
<br>
<input type="radio" name="deposit" value="500"> $500
<br>
<input type="radio" name="deposit" value="1000"> $1,000
<br>
</div>
<div class="form-group">
<button type="submit" class="btn btn-default">Deposit</button>
</div>
</fieldset>
</form>
Here is the output:
You can see that the last radio button is not vertically aligned. I realize that there are 2 extra characters in the text after the button. I'm no CSS wizard and haven't really found the answer to making these buttons straight. Any ideas?
EDIT: CSS code here:
.container {
/* center contents */
margin-left: auto;
margin-right: auto;
text-align: center;
}
input[type='radio'] {
width: 20px;
}
The form is in the container
In your CSS file or within your HTML code you are using the "align centre" setting. Thats why is not aligned.
This is the output of your above code with the align centre setting:
And this is the output of your code without the align centre setting:
Somewhere in your code you are setting the below div class to align centre.
// Removing the align setting will solve the issue. If its not in-line CSS then check you external CSS file.
<div class="form-group" align="center">
Hope this helps.
Why not use tables to make the buttons align (its easier with dreamweaver as your editing tool)
I wrote the HTML below to display two radio buttons and some text.
<input id="radio1" type="radio" checked="checked"/>Create the application name <br/>
<input id="radio2" type="radio"/> Create the Source name
My issue is that the radio buttons and the text are not aligning properly. The radio buttons are displaying a little bit below the text. How do I align the radio buttons and the text on the same line with proper alignment?
Demo
vertical-align: middle:
Aligns the vertical midpoint of the box with the baseline of the parent box plus half the x-height of the parent.
The problem seems to be caused by the fact browsers commonly add some random uneven margins to radio buttons and checkboxes.
Use inline style, weird but true:
<input type="radio" style="vertical-align: middle; margin: 0px;"> Label
<br/>
<br/>
<input type="radio" style="vertical-align: middle; margin: 0px;"> Label
<br/>
<br/>
<input type="radio" style="vertical-align: middle; margin: 0px;"> Label
Edit
this short explanation by Gavin Kistner, which is useful. I tried out the final suggestion on that page, which seems to render respectably in Chrome, IE, Firefox, Opera, and Safari.
What I did was add td{ line-height:1.5em }
Not too clear what you're after specifically..but:
Demo Fiddle
Add:
input{
vertical-align:top;
}
You may also want to chage this to vertical-align:middle;margin:0; depending on your requirements.
Try it below code...
input {float: left;
margin-top: 3px;}
add style for input type as
input
{
vertical-align: top;
}
and avoid the space in front of Create the Source name.
<input id="radio2" type="radio"/> Create the Source name
<input id="radio1" type="radio" checked="checked"/><label for="radio1">Create the application name</label>
<input id="radio2" type="radio" /><label for="radio2">Create the application name</label>
input,label{
vertical-align: top;
}
FIDDLE DEMO
<form >
<label>
<input name="radiobutton" type="radio" value="radiobutton" />
Man</label>
<label><br>
<input name="radiobutton" type="radio" value="radiobutton" />
Women</label>
</form>
/******this will help you********/