html - 图像不在表格容器中

标签 html css html-table

enter image description here not in container

我试图让图片保留在左栏中,但它似乎没有保留。如您所见,它悬停在 table 上方。我该怎么做才能让它留在表格内?

<table align="center" style="width:550px" id="table" cellpadding="5">
  <tr>
    <th style="text-align: left" rowspan="2">
      <img src="avi.png" alt="" id="avatar" />
    </th>
    <th style="text-align: left">
      <h1 id="hello">My Resume</h1>
    </th>
  </tr>
  <tr>
    <td style="text-align: left">
      <p>Hello this is a crazy little test that i am doing to see if this code works</p>
    </td>
  </tr>
</table>

最佳答案

如果您特别想要像您给出的示例那样的东西,那么使用表格是一种笨拙的旧方法。我建议使用 flexbox,这是一种排列事物并使它们看起来不错的简单方法。

这是一个例子:

body {
  font-family: 'Helvetica Neue', Helvetica, sans-serif;
}
.resume {
  display: flex;
  align-items: center;
  justify-content: center;
}
.resume-picture {
  border: 10px solid #1976D2;
  border-radius: 50%;
  background: #f3f2f1;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23);
  height: 175px;
}
.resume-content {
  padding: 0 15px;
}
.resume-content h2 {
  color: #1976D2;
  margin-top: 0;
}
.resume-content p {
  color: #333;
  margin: 0;
}
<div class="resume">
  <img class="resume-picture" src="https://avatars2.githubusercontent.com/u/3534427?v=3" />
  <div class="resume-content">
    <h2>My Resume</h2>
    <p>Hello this is a crazy little test that i am doing to see if this code works.
      <br>Hello this is a crazy little test that i am doing to see if this code works.
      <br>Hello this is a crazy little test that i am doing to see if this code works.</p>
  </div>
</div>

我希望这就是您正在寻找的东西。

关于html - 图像不在表格容器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39783624/

相关文章:

javascript - Uncaught ReferenceError : $ is not defined while Adding webticker

css - Jumbotron 中的社交偶像更近了

HTML/CSS : Align a Second Background Image to the Bottom Right of Page

javascript - 根据变量值隐藏表行

html - 如何在动态表格单元格中创建高度为 100% 的 div?

javascript - 每次循环递增3后关闭再打开另一个div

php - 编辑表单应显示该行的数据库值

javascript - 如何以 php,html 多选项卡形式传递数据?

html - 导航.active

html - 如何去除表格边框的阴影?