html - 为什么我的图像没有内联显示

标签 html css jsp

我不确定如何让我的图像以内嵌方式显示(如水平并排显示)。目前,它们彼此下方。我的想法是为整个页面设置一个包装器,然后为图像“homepageImageBanner”设置一个 div,然后为该 div 使用 display-inline 但也许我需要专门针对图像以内联显示它们?

.wrapper {
  width: 80%;
  margin: auto;
}
.homepageImageBanner {
  width: 80%;
  margin: auto;
  display: inline-block;
}
.homepageImageBannerList {
  list-style-type: none;
}
.sgaBadge {
  width: 200px;
  height: 200px;
  border: 0;
}
.lgaBadge {
  width: 120px;
  height: 120px;
  border: 0;
}
.egLogo {
  border: 0;
}
<div class="wrapper">
  <!-- Images -->
  <div class="homepageImageBanner">
    <ul class="homepageImageBannerList">
      <li>
        <a href="http://www.sga.org/" target="_blank">
          <img class="sgaBadge" alt="sga logo" src="http://placehold.it/200x200" />
        </a>
      </li>
      <li>
        <a href="http://www.lga.org.uk/" target="_blank">
          <img class="lgaBadge" alt="lga logo" src="http://placehold.it/120x120" />
        </a>
      </li>
      <li>
        <a href="http://eg.com/" target="_blank">
          <img class="egLogo" alt="eg logo" src="http://placehold.it/50x50" />
        </a>
      </li>
    </ul>
  </div>

最佳答案

因为 li 是 block 元素。将其更改为内联

.homepageImageBannerList li{
 display:inline-block
}

DEMO

关于html - 为什么我的图像没有内联显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29604199/

相关文章:

html - 我如何记录提交?

jsp - Tomcat/Windows 7 上的 HTTP 状态 500

jsp - spring MVC 多文件上传

html - <legend> 标签接受内联宽度

html - 多对象位置 HTML/CSS

javascript - 页面在更改 url 中的 id 时出现抖动?

java - Hibernate 5 延迟加载问题

html - 内容 100% 高度到窗口高度

html - 内联 flex 盒元素填充调整问题

javascript - 如何为使用 javascript 创建的表添加分页?