【问题标题】:Add text below AJAX loading icon在 AJAX 加载图标下方添加文本
【发布时间】:2017-12-30 07:46:44
【问题描述】:

我正在使用 jQuery 来显示 http://ajaxload.info/ 图标。

$(".modal").show();
<div class="modal"></div>
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: rgba( 255, 255, 255, .8 ) url('http://i.stack.imgur.com/FhHRx.gif') 50% 50% no-repeat;
}

我想在图标下方添加一些文字。我尝试在 class="modal" div 中添加新的 div,但它不起作用,因为我需要在背景上添加文本。 我怎样才能在背景图片下方有文字?

【问题讨论】:

  • 您在哪里以及如何显示图标?
  • @RoryMcCrossan 该图标正在与 CSS background 属性一起显示。
  • 图标使用背景属性显示。就像@Mark_M 说的那样。

标签: javascript jquery html css ajax


【解决方案1】:

如果是我,我不会使用background 图像。我会这样做:

<style>
.modal {
    position: fixed;
    text-align:center;
    z-index: 1000;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background: rgba( 255,255,255, .8 ) 
}
.modal::before {
    margin: auto;
    display:block ;
    text-align: center;
    content: url('http://i.stack.imgur.com/FhHRx.gif');
}
</style>
<div class="modal"><p>Content loading</p></div>

这是一个工作小提琴:https://jsfiddle.net/hsyprw2m/2/

【讨论】:

  • 有效!谢谢@Mark_M。我现在正在努力再次将它放在屏幕中间:)
  • 你应该可以用top做这样的事情:jsfiddle.net/hsyprw2m/5
猜你喜欢
  • 2018-11-04
  • 1970-01-01
  • 2017-05-08
  • 1970-01-01
  • 2016-04-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多