【问题标题】:How to Add an Image with Image Name in Ionic 2如何在 Ionic 2 中添加具有图像名称的图像
【发布时间】:2018-04-14 17:06:22
【问题描述】:

我想在用户图像的中心显示用户名的用户图像, 那么我如何通过响应来实现这一点。 enter image description here

【问题讨论】:

  • 您是否有任何代码可以分享,您创建的这些代码是为了自己解决这个问题?

标签: css angular ionic-framework sass ionic2


【解决方案1】:

您可以尝试使用 Ionic 提供的现有 CSS 类 text-centerhttps://ionicframework.com/docs/theming/css-utilities/

【讨论】:

  • 我有多个用户图像,并分别内联显示图像和用户名。
  • 您想要一个图像列表和一个名称(在描述中给出,一个在另一个之下)?您可以在 ng-repeat 中使用相同的结构。
【解决方案2】:

以下是在图像上定位文本的示例: HTML:

<div class="container">
  <img src="img_fjords_wide.jpg" alt="Norway" style="width:100%;">
  <div class="bottom-left">Bottom Left</div>
  <div class="top-left">Top Left</div>
  <div class="top-right">Top Right</div>
  <div class="bottom-right">Bottom Right</div>
  <div class="centered">Centered</div>
</div>

和 CSS:

/* Container holding the image and the text */
.container {
    position: relative;
    text-align: center;
    color: white;
}

/* Bottom left text */
.bottom-left {
    position: absolute;
    bottom: 8px;
    left: 16px;
}

/* Top left text */
.top-left {
    position: absolute;
    top: 8px;
    left: 16px;
}

/* Top right text */
.top-right {
    position: absolute;
    top: 8px;
    right: 16px;
}

/* Bottom right text */
.bottom-right {
    position: absolute;
    bottom: 8px;
    right: 16px;
}

/* Centered text */
.centered {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-09-03
    • 2016-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-29
    • 2022-01-25
    相关资源
    最近更新 更多