PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 17, 2022

[FIXED] How to align input="radio" with their labels?

 November 17, 2022     css, html, vertical-alignment     No comments   

Issue

I know there are a lot answers here. I searched, tried to adapt but I failed all the time, that is why I am asking now.

I have the following problem. I want, both, labels and there inputs to be in the same line: Yes o No o (o symbolize the input).

Here my following code, remark that I changed the display property of label to inline block:

<div class="col-sm-3">
        <label>Yes</label>
        <input type="radio" name="yes/no" checked>
        <label>No</label>
        <input type="radio" name="yes/no" >
    </div> 

Sorry for answering, although there are a lot of similar questions and answers but adapting them did just not work...


Solution

If you want the inputs and the label to be 'bottom-aligned', try using vertical-align: text-bottom.

input[type='radio'] {
  vertical-align: text-bottom;
  margin-bottom: 1px;
}
div {
  display: inline-block;
  border: 1px solid black;
}
<div class="col-sm-3">
    <label>Yes</label>
    <input type="radio" name="yes/no" checked>
    <label>No</label>
    <input type="radio" name="yes/no" >
</div>



Answered By - jo_va
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing