html - 我想使图像居中
问题描述
我正在为启动画面创建加载徽标。动画看起来完全像这样。所以当我尝试这段代码时,我的标志没有按我的意愿定位在中心,而且随着设备长度的增加,标志正在下降,它看起来像这样。应该是这样的。我使用的是ionic4/angular8。
ion-content{
--background:yellow;
}
.tree {
left: 0;
right: 10%;
margin:0 auto;
top:50%;
transform:translateY(-50%);
position: relative;
}
.tree > div {
position: absolute;
height: 100%;
width: 100%;
background: yellow;
top: 0;
left: 0;
-webkit-animation-name: hello;
-webkit-animation-duration: 5s;
-webkit-animation-fill-mode: forwards;
animation-name: hello;
animation-duration: 5s;
animation-fill-mode: forwards;
}
.tree img {
max-width: 100%;
}
@keyframes hello {
0% {
height: 100%;
}
100% {
height: 0%;
}
}
@-webkit-keyframes hello {
0% {
height: 100%;
}
100% {
height: 0%;
}
}
<ion-content>
<div class="tree">
<div></div>
<img src="logo.svg" />
</div>
<ion-content>
解决方案
您可以使用边距:0 自动
.tree {
margin: 0 auto;
}
推荐阅读
- visual-studio-2019 - Visual Studio 2019 - Angular 8 - 超时异常
- excel-formula - 找到一系列棒状值之间的最小和最大对应值
- c++ - 使用 CreateProcess 时出现奇怪的减速
- javascript - 如何在不更改当前页面的情况下更改特定目录?
- javascript - 在 wordpress 中将数据插入 iframe
- dafny - 使用 Dafny 在 MVS 中违反断言,但在rise4fun 中进行了验证
- ionic-framework - 从地图页面导航回来时,Ionic 3 垂直滚动停止处理离子内容
- postgresql - Postgis - 检查点是否在多边形内
- heroku - Why can't I connect my GitHub repo to Heroku?
- linux - iPerf 声称它在给定 -w 时使用相同的 TCP 窗口大小,请求大小不同但速率不同