【问题标题】:How to add image and text together without overflow on the toolbar如何在工具栏上将图像和文本一起添加而不会溢出
【发布时间】:2020-01-31 01:58:06
【问题描述】:

我有 mat-tab,我想放置从 accuweather API 获得的天气信息。我的工具栏具有响应性和灵活性。当页面大小更改时,这些图像会变小。效果很好,但是当我想添加温度信息时在图像下,发生溢出并且看起来非常糟糕。如何使图像下的这些温度数字没有任何溢出。

实际 预期 现实 这是我在下面尝试过的

        <li>
           <div class="d-flex">
                   <div *ngFor="let dailyForecast of dailyForecasts">
           <img class="responsive" src="{{appConfig.weatherIconsPath}}{{dailyForecast.Night.Icon}}.png">       
<small>{{dailyForecast.Temperature.Minimum.Value}}°C /                                               
{{dailyForecast.Temperature.Maximum.Value}}°C</small>
             </div>                                                                                             
             </div>    
        </li>

【问题讨论】:

    标签: html css angular twitter-bootstrap


    【解决方案1】:

    应该这样做:

    <li>
      <div class="d-flex align-items-center">
        <div *ngFor="let dailyForecast of dailyForecasts" 
             class="d-flex flex-column align-items-center">
          <img class="responsive" src="{{appConfig.weatherIconsPath}}{{dailyForecast.Night.Icon}}.png">
          <small>{{dailyForecast.Temperature.Minimum.Value}}°C / {{dailyForecast.Temperature.Maximum.Value}}°C</small>
        </div>
      </div>
    </li>
    

    注意:如果没有实际的Minimal, Reproducible Example,我无法为您提供更多帮助。

    【讨论】:

      【解决方案2】:

      尝试使用 CSS 设置图像的最大宽度:

      img.responsive {
      max-width: 40px;
      }
      

      【讨论】:

      • 这在工具栏上很合适,但是,使响铃在上面
      • 你能给我们发一个链接到问题出现的地方吗?
      猜你喜欢
      • 2016-11-30
      • 1970-01-01
      • 1970-01-01
      • 2020-12-17
      • 1970-01-01
      • 1970-01-01
      • 2015-08-29
      • 1970-01-01
      • 2015-12-17
      相关资源
      最近更新 更多