Радиокнопки не идут рядом с текстом - PullRequest
0 голосов
/ 22 января 2019

У меня есть две настраиваемые радиокнопки рядом друг с другом. Но это третий в блоке с передними типами и названиями. Оба имеют display: inline-block; в css, но переключатели все еще находятся под текстовым блоком. Я не знаю, как получить их рядом друг с другом, как остальные.

/*radio button yes no*/
.switch-field {
  font-family: "Lucida Grande", Tahoma, Verdana, sans-serif;
  padding: 40px;
	overflow: hidden;
  margin-left: 225px;
}



.switch-field input {
    position: absolute !important;
    clip: rect(0, 0, 0, 0);
    height: 1px;
    width: 1px;
    border: 0;
    overflow: hidden;
}

.switch-field label {
  float: left;
}

.switch-field label {
  display: inline-block;
  width: 100px;
  background-color: white;
  color: rgba(0, 0, 0, 0.6);
  font-size: 14px;
  font-weight: normal;
  text-align: center;
  text-shadow: none;
  padding: 6px 14px;
  border: 1px solid #b70000;
  -webkit-transition: all 0.1s ease-in-out;
  -moz-transition:    all 0.1s ease-in-out;
  -ms-transition:     all 0.1s ease-in-out;
  -o-transition:      all 0.1s ease-in-out;
  transition:         all 0.1s ease-in-out;
}

.switch-field label:hover {
	cursor: pointer;
}

.switch-field input:checked + label {
  background-color: #b70000;;
	color:white;
}

.switch-field label:first-of-type {
  border-radius: 0px 0 0 0px;
}

.switch-field label:last-of-type {
  border-radius: 0 0px 0px 0;
}
/*radio button yes no*/

/*block*/
.block label { display: inline-block; width: 140px; text-align: right; }
<div class="CalculatorLeft" style="padding-left: 29px;"id="alles">
  <h2 style="color:#b70000;">Bereken Prijs</h2>
  <div class="block">
      <label>Aantal vierkante meters</label>
      <input type="text" style="border:0px;border-bottom:1px solid #b70000;margin-left: 92px;width:200px;" />
  </div><br>
  <div class="block">
      <label>V-naden aanwezig</label>
      <select name="cars" class="" style="border:0px;border-bottom:1px solid #b70000;margin-left: 128px;width:200px;">
        <option value="behandeling" selected>Soort behandeling</option>
        <option value="volvo">Volvo</option>
        <option value="saab">Saab</option>
        <option value="fiat">Fiat</option>
        <option value="audi">Audi</option>
      </select>
  </div><br>
  <div class="block">
      <label>Soort behandeling</label>
      <div class="switch-field">
        <input type="radio" id="switch_left" name="switch_2" value="yes" checked/>
        <label for="switch_left">Yes</label>
        <input type="radio" id="switch_right" name="switch_2" value="no" />
        <label for="switch_right">No</label>
      </div>
  </div><br>
  <div class="block">
      <label>Postcode & Huisnummer</label>
      <input type="text" style="border:0px;border-bottom:1px solid #b70000;margin-left: 89px;width:200px;" />
  </div>

</div>

Ответы [ 2 ]

0 голосов
/ 22 января 2019

Попробуйте это;

CSS

.switch-field {
    font-family: "Lucida Grande", Tahoma, Verdana, sans-serif;
    padding: 0px;
    overflow: hidden;
    margin-left: 95px;
    display: inline-block;
    vertical-align: middle;
}

ДЕМО ЗДЕСЬ

0 голосов
/ 22 января 2019

Вы должны попытаться удалить любые поля и отступы для родительского элемента радиовходов "да / нет", так как этот "контейнер" заставляет элемент отойти от метки.

См. Фрагментрешение:

/*radio button yes no*/

.switch-field {
  font-family: "Lucida Grande", Tahoma, Verdana, sans-serif;
  /*padding: 40px;*/
  overflow: hidden;
  /*margin-left: 225px;*/
  display: inline-block;
  vertical-align: middle;
}

.switch-field input {
  position: absolute !important;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  width: 1px;
  border: 0;
  overflow: hidden;
}

.switch-field label {
  float: left;
}

.switch-field label {
  display: inline-block;
  width: 100px;
  background-color: white;
  color: rgba(0, 0, 0, 0.6);
  font-size: 14px;
  font-weight: normal;
  text-align: center;
  text-shadow: none;
  padding: 6px 14px;
  border: 1px solid #b70000;
  -webkit-transition: all 0.1s ease-in-out;
  -moz-transition: all 0.1s ease-in-out;
  -ms-transition: all 0.1s ease-in-out;
  -o-transition: all 0.1s ease-in-out;
  transition: all 0.1s ease-in-out;
}

.switch-field label:hover {
  cursor: pointer;
}

.switch-field input:checked+label {
  background-color: #b70000;
  ;
  color: white;
}

.switch-field label:first-of-type {
  border-radius: 0px 0 0 0px;
}

.switch-field label:last-of-type {
  border-radius: 0 0px 0px 0;
}


/*radio button yes no*/

.block label {
  display: inline-block;
  width: 140px;
  text-align: right;
}
<div class="CalculatorLeft" style="padding-left: 29px;" id="alles">
  <h2 style="color:#b70000;">Bereken Prijs</h2>
  <div class="block">
    <label>Aantal vierkante meters</label>
    <input type="text" style="border:0px;border-bottom:1px solid #b70000;margin-left: 92px;width:200px;" />
  </div><br>
  <div class="block">
    <label>V-naden aanwezig</label>
    <select name="cars" class="" style="border:0px;border-bottom:1px solid #b70000;margin-left: 128px;width:200px;">
      <option value="behandeling" selected>Soort behandeling</option>
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
      <option value="fiat">Fiat</option>
      <option value="audi">Audi</option>
    </select>
  </div><br>
  <div class="block">
    <label>Soort behandeling</label>
    <div class="switch-field">
      <input type="radio" id="switch_left" name="switch_2" value="yes" checked/>
      <label for="switch_left">Yes</label>
      <input type="radio" id="switch_right" name="switch_2" value="no" />
      <label for="switch_right">No</label>
    </div>
  </div><br>
  <div class="block">
    <label>Postcode & Huisnummer</label>
    <input type="text" style="border:0px;border-bottom:1px solid #b70000;margin-left: 89px;width:200px;" />
  </div>

</div>

Взгляните на свой класс .switch-field на предмет изменений.Вы также можете добавить к нему поле margin, чтобы правильно расположить его.Если вам нужна дополнительная помощь, пожалуйста, дайте мне знать.

JSFiddle

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...