1

我正在尝试使用中间的旋转图标进行加载叠加效果。我使用fontawesome。所以我编码了这个:http: //jsfiddle.net/eys3d/7/

它有效,但我试图让它响应。我的意思是,当截面尺寸减小时,旋转尺寸也会减小(保持居中)。如果部分的大小增加,则相反。

我尝试使用em单位,但没有得到预期的结果。

这是最好的方法吗?我怎样才能让它响应?

CSS

section {
    width: 200px;
    height: 200px;
    margin: 50px;
}
#overlay {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 99999999999;
    background: rgba(0, 0, 0, 0.5);
}
#overlay i {
    position: absolute;
    top: 50%;
    left: 50%;
}
.spin-big {
    font-size: 50px;
    height: 50px;
    width: 50px;
    margin-top: -25px;
    margin-left: -25px;
}
.spin-normal {
    font-size: 35px;
    height: 35px;
    width: 35px;
    margin-top: -22.5px;
    margin-left: -22.5px;
}
.spin-small {
    font-size: 20px;
    height: 20px;
    width: 20px;
    margin-top: -10px;
    margin-left: -10px;
}

HTML

<section>
    <div id="overlay"> 
        <i class="fa fa-spinner fa-spin spin-big"></i>
    </div>
</section>

<section>
    <div id="overlay"> 
        <i class="fa fa-spinner fa-spin spin-normal"></i>
    </div>
</section>

<section>
    <div id="overlay"> 
        <i class="fa fa-spinner fa-spin spin-small"></i>
    </div>
</section>

任何提示、建议或帮助将不胜感激,如果您需要更多信息,请告诉我,我将编辑帖子。

4

4 回答 4

5

为什么你不会尝试对display:table覆盖 div 和display:table-cellfontawesomei类使用属性?如下:

#overlay {
    width: 100%;
    height: 100%;
    display:table;
    background: rgba(0, 0, 0, 0.5);
}
#overlay i {
   display:table-cell;
    vertical-align:middle;
    text-align:center;
}

工作演示

于 2013-11-15T09:30:27.670 回答
1

你可以用这个来达到很好的效果

.loading 
{
 pointer-events: all;
 z-index: 99999;
 border: none;
 margin: 0px;
 padding: 0px;
 width: 100%;
 height: 100%;
 top: 0px;
 left: 0px;
 cursor: wait;
 position: fixed;
 background-color: rgba(0, 0, 0, 0.6);
}
于 2016-10-10T11:56:43.353 回答
0

只是遇到这个寻找类似的解决方案。

响应更改字体大小的唯一方法是通过媒体查询。

IE:

@media min-device-width: 300px{
    font-size: 8px;
}

@media min-device-width: 480px{
    font-size: 12px;
}

分机

于 2014-06-15T04:32:20.287 回答
-1
-----------div in Layout Page---------------
 <div class="loading-bg" id="dvSpinner">
        <img src="~/Areas/Images/loader.gif">
    </div>
----------css-----------
.loading-bg {
    background: #e9e9e9;
    display: none;
    height: 100%;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    opacity: 0.5;
    z-index: 5000;
    width: 100%;
}
.loading-bg img{
    position: absolute;
    top: 42%;
    left: 46%;
    height: 100px;
    width: 100px;
}


-------------html------------
<div class="appendInputFieldForUAIHiddenDiv"
                     id="appendInputFieldForUAIHiddenDiv">

                    @Html.TextBoxFor(model => model.PrimaryEmail, new { @class = "form-control enter-email-FPHidden-div", id = "email-address-entered", name = "email-address-entered" })
                    @Html.ValidationMessageFor(model => model.PrimaryEmail)

                    <button type="submit" class="btn btn-info submit-button-FPHidden" onclick="submitbuttonFPHidden()">
                        @ASRP.Resources.Resource.Submit
                    </button>
                </div>

--------------scripts--------------------------

function submitbuttonFPHidden() {


    var username = $('#email-address-entered').val();
    if (username == null || username == "") {
        document.getElementById("email-address-entered").style.borderColor = "#ff0232";
        return false;
    }

    if (!validateEmail(username)) {
        document.getElementById("email-address-entered").style.borderColor = "#ff0232";
        return false;
    }
    document.getElementById('dvSpinner').style.display = "block";
    $.ajax({
        url: "../User/ForgotPassword",
        data: { email: username },
        dataType: "json",
        type: "post",
        error: function (error, msg) {
            $('div#dvSpinner').hide();
            return false;
        },
        success: function (data) {
            if (data.success) {


                if (data.emailSent == "Successful") {
                    document.getElementById('FPHiddenDivContainer').style.display = "none";
                    document.getElementById('entered-email-address').style.display = "block";
                    document.getElementById('entered-email-address-para').innerHTML = document.getElementById('email-address-entered').value;
                    document.getElementById('PwdMsgNew').style.display = "none";

                }
                else if (data.emailSent == "Failure")
                {
                    document.getElementById('FPHiddenDivContainer').style.display = "none";
                    document.getElementById('entered-email-address').style.display = "block";
                    document.getElementById('entered-email-address-para').innerHTML = document.getElementById('email-address-entered').value;
                    document.getElementById('PwdMsg').style.display = "none";
                    document.getElementById('lblThankYou').style.display = "none";

                }


            }
            else {
                var ddlLangValue = $('#ddlLangs').val();
                setCookie("culture", ddlLangValue, 31536e3);
                var resources = {}; // Global variable.

                (function ($) {

                    $.getJSON("Resource/GetResources", function (data) {
                        resources = data;
                        alert(resources.fpUnabletoProcessReq);
                    });
                })(jQuery);
            }
            document.getElementById('dvSpinner').style.display = "none";
        }

    });
    return true;
}
于 2018-04-30T05:00:30.927 回答