【问题标题】:Put checkboxes next to added options将复选框放在添加的选项旁边
【发布时间】:2016-12-15 22:07:14
【问题描述】:

现在我在 html 中使用的代码是:

<label name="diet" for="">Dieet:</label>
  @foreach($diets as $diet)
      <p> {{ $diet->titel }} </p>

      <input type="checkbox" id="diet[]" for="diet[]" name="diet[]" value="{{ $diet->id }}" class="dieet{{ $diet->id }}">

在 CSS 中代码是

#form_new_recipe


    {
        margin: 0 auto;
        max-width:min-content;
        color: white;

        label{
            display: block;
        }

        input, textarea{
        margin-top:20px;
        margin-bottom:20px;
        display: block;
        }

        input[type="text"], textarea{
            margin-top:20px;
            margin-bottom:20px;
            display: block;
            width: 600px;
        }
    }

所以我的问题是:如何在添加的选项旁边看到我的复选框? (它与后端开发人员合作)

还有一些可能更难的事情,我想将添加的选项水平对齐(在一定程度上)

【问题讨论】:

    标签: html css checkbox sass alignment


    【解决方案1】:
    <label name="diet" for="">Dieet:</label>
      @foreach($diets as $diet)
    <label><input type="checkbox" id="diet[]" for="diet[]" name="diet[]" value="{{ $diet->id }}" class="dieet{{ $diet->id }}">{{$diet->titel}}</label>
    

    你是这个意思吗?在输入旁边显示标签(也可以点击)

    【讨论】:

    • 我仍然没有看到复选框:(
    • 我试过了: @foreach($diets as $diet) 现在显示复选框,但它们没有响应。
    • 我不确定我发布的内容如何行不通,但您的其他方式行不通?
    • 因为id应该是id。该框应选中具有相同ID的内容。我想知道为什么你的也不行,但我只是尝试了一些东西。您给我的代码确实给了我一些见解,但是没有用。复选框甚至没有出现。
    • 因为title应该是id。*
    【解决方案2】:

    我修好了!

        <label name="diet" for="">Dieet:</label>
      @foreach($diets as $diet)
      <input type="checkbox" id="{{$diet->titel}}" value="{{ $diet->id }}" ><label for="{{$diet->titel}}">{{$diet->titel}}</label>  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-22
      • 2019-02-15
      • 2023-01-11
      • 2017-12-06
      • 1970-01-01
      • 2021-06-05
      相关资源
      最近更新 更多