带有 jsfiddle ex : not working: vertical align and using full width based on width percentage of two child containers 的 Html css

标签 html css

https://jsfiddle.net/3Lthpf72/5/

带有 jsfiddle ex 的 Html css:不起作用:垂直对齐并根据两个子容器的宽度百分比使用全宽

当我使两个子容器的总和达到父容器的宽度百分比时,它会向下折叠。此外,垂直对齐中间位于底部,而不是中间。

有什么想法吗?

.payee.list-item {
  border: 1px solid red;
  height: 100%;
  width: 300px;
}
.list-item-content {
  display: inline-block;
  border: 1px solid blue;
  width: 80%
}
.payee.list-item>img {
  border: 1px solid green;
  height: 45px;
  display: inline-block;
  width: 17%;
  vertical-align: middle;
}
<div class="payee list-item">
  <img src="/Image/PayeeBillPayAccountPortrait/832">
  <div class="list-item-content">
    <h4>Colonel Sanders!</h4>
    <h3>Colonel Sanders</h3>
  </div>
</div>

最佳答案

你想做这样的事情吗?

.payee.list-item {
  border: 1px solid red;
  height: 100%;
  width: 300px;
  display: inline-block;
  position: relative;
}

.list-item-content {
  float: right;
  border: 1px solid blue;
  width: 80%
}
h3, h4 {
  width: 50%;
  float: left;
  box-sizing: border-box;
  padding: 6px;
  }

h3{background: lightgray;}
h4{background: gray;}

.payee.list-item>img {
  border: 1px solid green;
  max-height: 45px;
  width: 17%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}
<div class="payee list-item">
  <img src="https://static.pexels.com/photos/6555/nature-sunset-person-woman.jpg">
  <div class="list-item-content">
    <h3>Colonel Sanders</h3>
    <h4>Colonel Sanders!</h4>
  </div>
</div>

关于带有 jsfiddle ex : not working: vertical align and using full width based on width percentage of two child containers 的 Html css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39380380/

相关文章:

HTML 表格标题作为标题行的一部分

java - 在 Java 字符串变量上使用 HTML

javascript - html 标签和 Angular 中的属性不起作用

html - 图片卡在页眉底部

html - 如何强制肖像图像与风景图像具有相同的大小并具有响应性?

c# - CSS 在页面回发 ASP.NET 期间被删除了一段时间

javascript - 在 Canvas 上绘制描边后,将描边添加到另一个对象会更改所有描边

jquery - Overlay div - 滚动尽可能多的内容

css - Twitter Bootstrap - 具有二级导航栏,但不是下拉菜单

jquery - 显示:none and jquery show/slideDown