通过WordPress中的html将<img/>标记置于<div>标记中

时间:2017-01-13 21:05:08

标签: html

我在这里做错了什么?

我是网络开发世界的新手。

我想把这两张图片放在中心,而且没有这样的运气:

<!-- WHITE SPACE LOGO AREA -->
<div style="background-color:white;color:white;padding:20px;">
    <img src="/wp-content/uploads/2017/01/affiliate-color-logo.jpg" alt="American Welding Society Member" class="midImg">
    <img src="/wp-content/uploads/2017/01/ASNT-corp_mem_logo_webrgb.jpg" alt="ASNT Corporate Partner" class="midImg">
</div>

1 个答案:

答案 0 :(得分:0)

您可以使用text-align: center,请参阅此示例:

&#13;
&#13;
<div style="background-color:white;color:white;padding:20px;text-align: center;">
  <img src="/wp-content/uploads/2017/01/affiliate-color-logo.jpg" alt="American Welding Society Member" class="midImg">
  <img src="/wp-content/uploads/2017/01/ASNT-corp_mem_logo_webrgb.jpg" alt="ASNT Corporate Partner" class="midImg">
</div>
&#13;
&#13;
&#13;

但更好的做法是不使用内联样式,请使用类和CSS查看以下改进的代码:

&#13;
&#13;
.images {
  background-color:white;
  color:white;
  padding:20px;
  text-align: center;
}
&#13;
<div class="images">
  <img src="/wp-content/uploads/2017/01/affiliate-color-logo.jpg" alt="American Welding Society Member" class="midImg">
  <img src="/wp-content/uploads/2017/01/ASNT-corp_mem_logo_webrgb.jpg" alt="ASNT Corporate Partner" class="midImg">
</div>
&#13;
&#13;
&#13;