Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spacing between checkboxes and values

Tags:

html

css

JSFiddle

How would I go about editing the HTML/CSS to create spacing between each checkbox/value pairing? Right now each checkbox and each value are spaced evenly. I'd like value1 to be close to checkbox1, but checkbox2 to have some distance from the value1.

Code here:

.checkboxes {
  text-align:center;
}

.checkboxes input{
  margin: 0 20px 0;
}

<div class="checkboxes">
  <span>
    <input type="checkbox" name="One" value="One"> One
    <input type="checkbox" name="Two" value="Two"> Two
    <input type="checkbox" name="Three" value="Three"> Three
    <input type="checkbox" name="Four" value="Four"> Four
  </span>
</div>
like image 863
Matthew Snell Avatar asked Dec 18 '22 06:12

Matthew Snell


2 Answers

Use This Code

.checkboxes {
  text-align:center;
}

.checkboxes input{
  margin: 0px 0px 0px 0px;
}

.checkboxes label{
  margin: 0px 20px 0px 3px;
}
<html>
  <head></head>

  <body>
    <div class="checkboxes">
    <span>
      <input type="checkbox" name="Mow" value="Mow"> <label>One</label>
      <input type="checkbox" name="Weedeat" value="Weedeat"> <label>Two</label>
      <input type="checkbox" name="Edge" value="Edge"> <label>Three</label>
      <input type="checkbox" name="Other" value="Other"> <label>Four</label>
    </span>
    </div>
  </body>

</html>
like image 85
Saurav Jamwal Avatar answered Dec 20 '22 19:12

Saurav Jamwal


you need to reduce right margin a bit and may need to increase left margin

.checkboxes input{
  margin: 0 5px 0 30px;
}

.checkboxes {
  text-align:center;
}

.checkboxes input{
  margin: 0 5px 0 30px;
}
    <div class="checkboxes">
      <span>
        <input type="checkbox" name="Mow" value="Mow"> One
        <input type="checkbox" name="Weedeat" value="Weedeat"> Two
        <input type="checkbox" name="Edge" value="Edge"> Three
        <input type="checkbox" name="Other" value="Other"> Four
      </span>
      </div>
like image 21
Rahul Avatar answered Dec 20 '22 21:12

Rahul