nanjero echizen nanjero echizen - 6 months ago 12
CSS Question

CSS - How can I align my radio buttons?

This is my HTML form code:

<div id="myForm">
<form action="<?php echo $__SERVER["PHP_SELF"];?>" method="post">
<table>
<input type="radio" name="tableNames" value="<?php echo $tempName; ?>" > <?php echo $tempName ?> <br/>

<tr>
<td><input type="submit" value="submit"></td>
<td><input type="reset" value="reset"></td>
</tr>
</table>
</form>
</div>


this is my current css:

#myForm {
margin: auto;
width: 700px;
}
#myForm form {
background-color: #E0E0E0;
text-align: center;
padding: 5px;
}
#myForm table {
margin: auto;
width: 60%;
padding: 15px;
}


this is what my form looks like right now:
radio buttons
How can i align the radio button's buttons

Answer

you could wrap the inputs in a div, then center that div and give it text-align left.

#myForm {
  margin: auto;
  width: 700px;
}
#myForm form {
  background-color: #E0E0E0;
  text-align: center;
  padding: 5px;
}
#myForm table {
  margin: auto;
  width: 60%;
  padding: 15px;
}
.test {
  width: 300px;
  margin: 0 auto;
  text-align: left;
}
<div id="myForm">
  <form method="post">
    <table>
      <div class="test">
        <input type="radio" name="tableNames" value="asdasd123123">asdasdasd
        <br/>
        <input type="radio" name="tableNames" value="asd">asdasdasd
        <br/>

        <input type="radio" name="tableNames" value="asdasdasdas?>">123
        <br/>
        <input type="radio" name="tableNames" value="123123123123">asdasdasd1231231231231231231231
        <br/>
      </div>
      <tr>
        <td>
          <input type="submit" value="submit">
        </td>
        <td>
          <input type="reset" value="reset">
        </td>
      </tr>
    </table>
  </form>
</div>

Comments