css - 使用 margin-top 无法将内容带到页面中间
问题描述
我有一个代码和一些使用 top 和 margin-top 的小问题,无法使用 top:50% 我不知道为什么然后我使用了 margin-top:50% 但它没有将画布移动到页面中间(50%),如何将画布移动到页面中间(只是高度而不是宽度)
.so {
position: relative;
top: 50%;
clear: both;
float: left;
left: 10%;
}
@media only screen and (orientation: landscape) {
.so {
position: relative;
margin-top: 50%;
clear: both;
float: left;
left: 10%;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="animatedParent">
<div>
<div class="so">
<canvas width="30" height="30" style="background-color:blue"></canvas>
<canvas width="30" height="30" style="background-color:pink"> </canvas>
<canvas width="30" height="30" style="background-color:gray"> </canvas>
</div>
</div>
</div>
</body>
</html>
解决方案
推荐阅读
- python - 如何“降级”一个 Keras/Tensorflow 模型,以便旧代码可以使用它
- azure - 如何将 ssis 原始文件转换为 Parquet
- javascript - 如何提醒下个月日期
- django - 结合 VueJS 和 Django 存在性能问题?
- html - 如何录制画布流?
- openvino - 使用 OpenVINO 工具包转换posenet模型?
- c# - 包含包含的 CosmosDB Linq 查询不是 IDocumentQuery 类型
- c# - 在多个上下文中报告进度:控制台应用程序、窗口窗体
- javascript - MutationObserver 用于父级更改时
- revit - REVIT:有没有办法在注释中使用变量来设置某些对象的高度?