Как бы я переписать эту простую таблицу без использования таблицы? Имея 2 деления рядом и левое по центру - PullRequest
1 голос
/ 27 марта 2020

Я пытаюсь улучшить свои навыки. Делать то, что я хочу, с таким столом очень просто

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <style>
    table {
      width: 500px;
    }
  </style>
  <table>
    <tr>
      <td class="t">Thing_____</td>
      <td class="p">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
        It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with
        desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</td>
    </tr>
  </table>
</body>

</html>

Однако я думал, что было бы легко обойтись без таблицы, и не смог приблизиться к разрыву текста. Похоже на автомобильную аварию. Мне было интересно, есть ли простой способ сделать это без стола? или я должен использовать таблицу, даже если это на самом деле не таблица?

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <style>
    .box {
      width: 700px;
      columns: 2;
    }
    
    .t {
      display: inline-block;
    }
    
    p {
      width: 500px
    }
  </style>
  <div class="box">
    <div class="t">Thing_____</div>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
      has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    <div>
</body>

</html>

1 Ответ

2 голосов
/ 27 марта 2020

Flexbox может сделать тот же вывод в этом случае:

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <style>
    .box {
      width: 500px;
      display:flex;
    }
    
    .t {
       margin:auto 5px;
    }

  </style>
  <div class="box">
    <div class="t">Thing_____</div>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It
      has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
      publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
    <div>
</body>

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