【问题标题】:How do I make div same height as img beside it?如何使 div 与它旁边的 img 高度相同?
【发布时间】:2019-01-18 21:08:18
【问题描述】:

我需要帮助使 div 与它旁边的 img 在同一 flex 行中的高度相同

这里是html

`<div class="about">
     <img class="headshot" src="../img/headshot.jpg">
     <div class="textbox">here is where my text is</div>
 <div>`

我希望 .textbox 的大小与 .headshot 的高度和宽度相同。到目前为止,我的宽度相同,但我无法使高度相同。

这是css:

`.about {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    text-align: center;
}

.headshot {
    max-height: auto;
    max-width: 25%;
}

.textbox {
    background-color: hotpink;
    width: 25%;
    height: auto;
}`

我确信这是一些简单的解决方案,但我一直在努力解决它,所以非常感谢任何帮助! :)

【问题讨论】:

    标签: flexbox resize alignment responsive sizing


    【解决方案1】:

    尝试为“文本框”类设置height:100%

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-03
      • 1970-01-01
      相关资源
      最近更新 更多