【问题标题】:How to align the text in front of images [duplicate]如何对齐图像前面的文本[重复]
【发布时间】:2018-09-18 21:29:42
【问题描述】:

这是我的代码:

.left-ul {
  margin-left: 10px!important;
  display: inline-block!important;
  vertical-align: top;
  width: 350px;
}

.iconic {
  padding: 2%!important;
  color: #111!important;
  font-size: 16px!important;
}

li {
  display: list-item;
  text-align: -webkit-match-parent;
}
<div id="news">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-4 text-center">
        <img src="images/prof.jpg" style="width:90%;">
      </div>
      <div class="col-md-8 price-grid feature-list">
        <legend>
          <h2>Highlights of the Program</h2>
        </legend>
        <ul class="left-ul">
          <img src="images/thumb.png" style="width:55px; height:55px;">
          <li class="iconic">Industry experts as faculty and guest lecturers</li>
        </ul>
      </div>
    </div>
  </div>
</div>

我要显示文字:

作为教师和客座讲师的行业专家

在图片前面,我的文字在图片下面。

我无法对齐图片前面的文字。两者都应该面对面。
我曾尝试使用 text-align 属性,但没有奏效。

如果您需要更多文件,请告诉我。

【问题讨论】:

  • 您应该考虑使用&lt;figure&gt;&lt;figcaption&gt; 在图像下定位文本。
  • @Andrew 我不想将文本放置在图像下方,但我想在图像的正面或面对面的位置相互靠近
  • 您的 HTML 中有一个错误:
  • 之外。将它放在
  • 中,在文本之后。顺便说一句, 也放错了位置,但我认为这不是太大的问题。

标签: css


【解决方案1】:

您可以将float: right; 应用于图像:

.left-ul {
  margin-left: 10px!important;
  display: inline-block!important;
  vertical-align: top;
  width: 350px;
}

.iconic {
  padding: 2%!important;
  color: #111!important;
  font-size: 16px!important;
}
.left-ul > img {
  float: right;
}
<div id="news">
  <div class="container-fluid">
    <div class="row">
      <div class="col-md-4 text-center">
        <img src="images/prof.jpg" style="width:90%;">
      </div>
      <div class="col-md-8 price-grid feature-list">
        <legend>
          <h2>Highlights of the Program</h2>
        </legend>
        <ul class="left-ul">
          <img src="images/thumb.png" style="width:55px; height:55px;">
          <li class="iconic">Industry experts as faculty and guest lecturers</li>
        </ul>
      </div>
    </div>
  </div>
</div>

【讨论】:

    猜你喜欢
    相关资源
    最近更新 更多
    热门标签