两张桌子相邻

时间:2019-12-03 17:26:53

标签: php html css laravel

所以我有这个问题。 我需要将第二张桌子放在右边的第一张桌子旁边。或者更喜欢在其旁边放置10px之类的东西,但表格的顶部位于相同的'y'px处;另外,我不使表变得牢固,因为表位于for()中,并且应该有更多的表,然后只有两个表(现在是1 + 1,然后是1 + 1,在其下是1 + 1表)现在是第二个表在第一个之下。 我尝试了几件事,但仍然找不到正确的答案。我不是CSS大师,我只是在学习。有人可以帮忙吗?

    <div style="width: 400px">
  @foreach ($reminders as $reminder)

<table style="margin-left: 550px; width: 100%; position: center; margin-top: 50px;">
    <tr style="">
      <th colspan="4">{{$reminder->title}}</th>
    </tr>
    <tr> 
     <th colspan="4" style="height: 150px; text-align: left">{{$reminder->text}}</th></tr>
     <tr> 
      <th>
        <form method="post" action="/donereminder" >
              @csrf

        <input type="hidden" name="rem" value="{{$reminder->id}}" readonly style="width: 0%">
        <button type="submit" style="width: 100%">Done</button>
      </form></a></th>
      <th><button class="button" style="width: 100%">Report</button></th>
      <th><a href="/reminders/{{$reminder->id}}/edit"><button class="button" style="width: 100%">Edit</button></a></th>
      <th>
      <form method="POST" action="/reminders/{{ $reminder->id}}">
    @method('DELETE')
    @csrf

    <div class="field">
    <div class="control">
      <button type="submit" class="button" style="width: 100%;">&#128465; </button>
    </div>
  </div>
  </form>
</th></tr>
    </table>

<table style="margin-left: 550px; width: 100%; position: center; margin-top: 50px">
<form method="POST" action="/reminders/{{$reminder->id}}">

  @method('PATCH')
    @csrf

      <tr>
        <th>
          <div class="form-group">
          <label>Name</label>
          <input type="text" class="form-control" name="title" placeholder="Name of reminder" value="{{$reminder->title}}">
        </div>
      </th>
      </tr>
      <tr>
        <th>
          <div class="form-group">
          <label>Text</label>
          <input type="text" class="form-control" name="text" placeholder="Description of your reminder"  value="{{$reminder->text}}">
        </div>
        </th>
      </tr>
      <tr>
        <th> <div class="form-group">
          <label>Typ</label>
          <select class="form-control" name="typ"  value="{{$reminder->typ}}">
            <option name="typ" value="0">Práce</option>
            <option name="typ" value="1">Narozeniny</option>
            <option name="typ" value="2">Sport</option>
            <option name="typ" value="3">Jiné</option>\
          </select>
        </div></th>
      </tr>
      <tr>
        <th> <div class="form-group">
          <label>Priorita</label>
          <select class="form-control" name="priority"  value="{{$reminder->priority}}">
            <option name="priority" value="{{$reminder->priority}}">{{$reminder->priority}}</option>
            <option name="priority" value="10">10</option>
            <option name="priority" value="9">9</option>
            <option name="priority" value="8">8</option>
            <option name="priority" value="7">7</option>
            <option name="priority" value="6">6</option>
            <option name="priority" value="5">5</option>
            <option name="priority" value="4">4</option>
            <option name="priority" value="3">3</option>
            <option name="priority" value="2">2</option>
            <option name="priority" value="1">1</option>
          </select>
        </div></th>
      </tr>
      <tr>
        <th>
           <div class="form-group">
          <label>Done time</label>
          <input class="datepicker" data-date-format="mm/dd/yyyy"  type="date" placeholder="MM/DD/YYYY" name="donetime"  value="{{$reminder->donetime}}">
        </div>
        </th>
      </tr>
      <tr>
        <th>
          <div class="field">
    <div class="control">
      <button type="submit" class="button is-link"  style="width: 25%;">Upravit reminder</button>
    </div>

  </div>
        </th>
      </tr>
    </table>
    </form>

1 个答案:

答案 0 :(得分:0)

有很多方法可以做到这一点。我建议您举一个例子。

注意事项:

  • 在子元素中使用display:inline-block。这样,所有元素都将位于同一条“水平线”。
  • vertical-align默认设置为基线。因此,请设置vertical-align: top以避免这种情况。
  • 适合的表数取决于它们的width和其父项的width
  • 您可以调整各张桌子上的margin-right之间的距离。

  

通知,我删除了您的php代码并将background添加到表中   由于无法正确显示结果。


    <div>
<table style="display:inline-block;vertical-align:top;margin-right: 10px;background-color:lightgreen;">
    <tr style="">
      <th colspan="4">{{$reminder->title}}</th>
    </tr>
    <tr> 
     <th colspan="4" style="height: 150px; text-align: left">{{$reminder->text}}</th></tr>
     <tr> 
      <th>
        <form method="post" action="/donereminder" >
              @csrf

        <input type="hidden" name="rem" value="{{$reminder->id}}" readonly style="width: 0%">
        <button type="submit" style="width: 100%">Done</button>
      </form></a></th>
      <th><button class="button" style="width: 100%">Report</button></th>
      <th><a href="/reminders/{{$reminder->id}}/edit"><button class="button" style="width: 100%">Edit</button></a></th>
      <th>
      <form method="POST" action="/reminders/{{ $reminder->id}}">
    <div class="field">
    <div class="control">
      <button type="submit" class="button" style="width: 100%;">&#128465; </button>
    </div>
  </div>
  </form>
</th></tr>
    </table>
<table style="display:inline-block;vertical-align:top;background-color:lightgray;">
<form method="POST" action="/reminders/{{$reminder->id}}">
      <tr>
        <th>
          <div class="form-group">
          <label>Name</label>
          <input type="text" class="form-control" name="title" placeholder="Name of reminder" value="{{$reminder->title}}">
        </div>
      </th>
      </tr>
      <tr>
        <th>
          <div class="form-group">
          <label>Text</label>
          <input type="text" class="form-control" name="text" placeholder="Description of your reminder"  value="{{$reminder->text}}">
        </div>
        </th>
      </tr>
      <tr>
        <th> <div class="form-group">
          <label>Typ</label>
          <select class="form-control" name="typ"  value="{{$reminder->typ}}">
            <option name="typ" value="0">Práce</option>
            <option name="typ" value="1">Narozeniny</option>
            <option name="typ" value="2">Sport</option>
            <option name="typ" value="3">Jiné</option>\
          </select>
        </div></th>
      </tr>
      <tr>
        <th> <div class="form-group">
          <label>Priorita</label>
          <select class="form-control" name="priority"  value="{{$reminder->priority}}">
            <option name="priority" value="{{$reminder->priority}}">{{$reminder->priority}}</option>
            <option name="priority" value="10">10</option>
            <option name="priority" value="9">9</option>
            <option name="priority" value="8">8</option>
            <option name="priority" value="7">7</option>
            <option name="priority" value="6">6</option>
            <option name="priority" value="5">5</option>
            <option name="priority" value="4">4</option>
            <option name="priority" value="3">3</option>
            <option name="priority" value="2">2</option>
            <option name="priority" value="1">1</option>
          </select>
        </div></th>
      </tr>
      <tr>
        <th>
           <div class="form-group">
          <label>Done time</label>
          <input class="datepicker" data-date-format="mm/dd/yyyy"  type="date" placeholder="MM/DD/YYYY" name="donetime"  value="{{$reminder->donetime}}">
        </div>
        </th>
      </tr>
      <tr>
        <th>
          <div class="field">
    <div class="control">
      <button type="submit" class="button is-link"  style="width: 25%;">Upravit reminder</button>
    </div>

  </div>
        </th>
      </tr>
    </table>
    </form>