首页 > 解决方案 > div 的右侧太长。我该如何解决?

问题描述

我在这个简单的桌子上遇到了麻烦,它被一个绿色的盒子包围着,它是 div。

绿色框的右侧一直延伸到右侧。我希望它紧贴在桌子周围。我该如何解决?谢谢!

这是我的 HTML 和 CSS 代码。

.tblEdu{
  position: relative;
  left: 100px;
  right: 100px;
  background-color: #e8efeb;
}

table{

  text-align: left;
  position: relative;
  left: 10px;
  color: #214252
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="styles.css">
    <title></title>
  </head>
  <body>
    <h3>Education</h3>
  <div class="tblEdu">

  <table cellspacing="20px">
    <tr>
      <th>School</th>
      <th>Years</th>
      <th>Diploma</th>
    </tr>
    <tr>
      <td>The Lorem State University</td>
      <td>2012-2016</td>
      <td>Bachelor of Science Degree in Information Technology</td>
    </tr>
    <tr>
      <td>Ipsum High School</td>
      <td>2008-2012</td>
      <td>High School Diploma</td>
    </tr>

  </table>
</div>


  </body>
</html>

标签: htmlcss

解决方案


推荐阅读