为什么<li>标签放错了地方?



有一个包含四列的表格。在第一列中有一个图像。我已将align attribute设置为 top .其余列包含文本。但是,当文本插入第四列时,<li>标签会丢失inline display顺序。

任何解决此问题的建议将不胜感激。

ul.film1 li,
ul.film2 li,
ul.film3 li {
  width: 150px;
  height: 290px;
  border: 3px solid blue;
  display: inline-block;
}
#tableheadheader1,
#tableheadbody1 {
  font-family: Lato;
  font-size: 16px;
  text-align: center;
}
#tableheadfooter1 {
  font-family: Lato;
  font-size: 10px;
  text-align: justify;
}
<ul class="film1">
  <li id="tableheadimage1">
    <img src="http://placehold.it/75x75" align="top">
  </li>
  <li id="tableheadheader1">
    <p>Tomorrowland</p>
  </li>
  <li id="tableheadbody1">
    <p>2015</p>
  </li>
  <li id="tableheadfooter1">
    <p>Whenever Casey Newton (Britt Robertson) touches a lapel pin with the letter T on it, she finds herself transported to Tomorrowland, a city filled with huge robots and sleek buildings. The gifted young woman recruits the help of scientist Frank Walker
      (George Clooney), a previous visitor to Tomorrowland, who years ago made a startling discovery about the future. Together, the two adventurers travel to the metropolis to uncover its mysterious secrets.</p>
  </li>
</ul>

如果你把vertical-align: top;放在你的<li>元素上,应该可以解决你的问题。

ul.film1 li,
ul.film2 li,
ul.film3 li {
  width: 150px;
  height: 290px;
  border: 3px solid blue;
  display: inline-block;
  vertical-align: top; /* <-- this has been added */
}
#tableheadheader1,
#tableheadbody1 {
  font-family: Lato;
  font-size: 16px;
  text-align: center;
}
#tableheadfooter1 {
  font-family: Lato;
  font-size: 10px;
  text-align: justify;
}
<ul class="film1">
  <li id="tableheadimage1">
    <img src="http://placehold.it/75x75" align="top">
  </li>
  <li id="tableheadheader1">
    <p>Tomorrowland</p>
  </li>
  <li id="tableheadbody1">
    <p>2015</p>
  </li>
  <li id="tableheadfooter1">
    <p>Whenever Casey Newton (Britt Robertson) touches a lapel pin with the letter T on it, she finds herself transported to Tomorrowland, a city filled with huge robots and sleek buildings. The gifted young woman recruits the help of scientist Frank Walker
      (George Clooney), a previous visitor to Tomorrowland, who years ago made a startling discovery about the future. Together, the two adventurers travel to the metropolis to uncover its mysterious secrets.</p>
  </li>
</ul>

最新更新