首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在HTML和CSS中将动画图像和一致的文本居中显示在网页上,而不管设备类型?

如何在HTML和CSS中将动画图像和一致的文本居中显示在网页上,而不管设备类型?
EN

Stack Overflow用户
提问于 2018-06-21 04:20:56
回答 1查看 810关注 0票数 0

我尝试将动画图像放入表中,但动画在这种情况下不起作用。

我只能使用HTML和CSS来实现这一点。

我想让绿色旋转的圆圈在页面上垂直和水平居中,让logo坐在不旋转的圆圈内,让文本在它正下方每隔5秒改变一次,水平居中,不离圆圈边缘太远。

现在,使用以下代码,移动版本如下所示:

(红色圆圈圈住了徽标,它看起来也比我想要的要小)

桌面视图当前如下所示:

正如你在这里看到的,徽标在垂直方向上仍然稍微偏离中心,圆圈实际上离屏幕顶部很近,而不是中心。

到目前为止,我在HTML中有:

代码语言:javascript
运行
复制
<div id="animatedLogo">
    <div id="loadingCircle">
        <img id="loadingLogo" src="../Content/images/HCSS_GooglePresentation_Spinner_Green.PNG" class="circle" />
    </div>
    <div id="wordLogo">
        <img id="HCSSLogo" src="../Content/images/hcss logo2.jpg" class="logo" />
    </div>
    <div id="myPhrase" class="phrase"></div>
</div>




<div class="main-container container-fluid">
    <div class="row">
        <div class="span6">
            <form method="post" action="{responseUri}">
                {responseFields}
            </form>
        </div>
    </div>
</div>

<link href="../Content/please-wait.css" rel="stylesheet" />
<script src="/Scripts/logoAnimation.js"></script>
<script src="/Scripts/formPostResponse.js"></script>

在CSS中,我有:

代码语言:javascript
运行
复制
#animatedLogo {
    text-align: center;
}

#loadingLogo {
    animation: rotation 2.5s infinite linear;
    min-height: 100%;
    min-width: 35%;
    padding: 1% 0;
}

@keyframes rotation {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(359deg);
    }
}

#loadingCircle {
    min-height: 77%;
    min-width: 35%;
}

#wordLogo {
    width: 100%;
    height: 67%;
    position: absolute;
    top: 0;
    left: 0;
    /*padding: 5% 0;*/
    margin-top: 5%;
}

.circle {
}

.logo {
    width: 10%;
    padding: 11% 0;
}

.phrase {
    font-family: "Proxima Nova", sans-serif;
    font-size: 24px;
    font-style: oblique;
    position: absolute;
    /* top: 625px; */
    margin-left: 50%;
    /* text-align: center; */
    transform: translateX(-50%);
}

(6/20下午3:58添加)此外,我需要确保圆圈不会改变形状,变成椭圆形,就像我改变我的解决方案以适合建议的答案时所做的那样:

在上午8:19添加。在6/21/18,圆圈不再变成椭圆形!然而,现在没有任何东西是居中的。

截至上午9:24的更新

我们越来越近了!!

1)我意识到我可能应该选择徽标的大小与旋转器的大小的一定比例来使用,这样徽标在移动版本中就不会变得太小。我正在网上搜索想法,但如果你知道一个特别适合这个项目,让我知道!

2)现在我们需要把短语放在旋转器下面,而不是放在边上。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50956441

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档