html - 将 css 框移动到屏幕顶部
问题描述
CSS完整的新手在这里。我正在尝试将我的“框”推到页面顶部。我玩过css文件,但不知道如何完美地放置它。我认为我面临的挑战是高度和边距。我在这里从 codepen 复制了 css 。
我的目标是将盒子从底部移动到(几乎)顶部。
#box-dynamic {
width: 420px;
line-height: 25px;
background: rgba(0, 0, 0, 0.2);
float: left;
position: absolute;
bottom: 0;
z-index: 500 !important;
-ms-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
#box-dynamic.minimize {
height: 50px;
line-height: 5px;
}
#box-dynamic h1 {
margin-right: 5px;
color: #fff;
font-size: 20px;
font-family: 'Roboto Condensed', sans-serif;
margin-left: 5px;
-ms-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
#box-dynamic.minimize h1 {
font-size: 20px;
text-align: center;
}
#box-dynamic p {
color: #ccc;
font-size: 15px;
line-height: 1.4;
margin-left: 5px;
font-family: 'Roboto Condensed', sans-serif;
-ms-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
#box-dynamic.minimize p {
font-size: 0px;
}
#box-dynamic small {
color: #ccc;
font-size: 11px;
font-family: 'Roboto Condensed', sans-serif;
margin-left: 5px;
margin-top: 0;
-ms-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
#box-dynamic.minimize small {
font-size: 10px;
margin-right: 5px;
float: right;
}
#box-dynamic img {
float: left;
width: 0;
height: 0;
visibility: hidden;
-ms-transition: all 0.3s ease-out;
-moz-transition: all 0.3s ease-out;
-webkit-transition: all 0.3s ease-out;
-o-transition: all 0.3s ease-out;
transition: all 0.3s ease-out;
}
#box-dynamic.minimize img {
float: left;
width: 50px;
height: 50px;
visibility: visible;
}
<div class="box">
<div id="box-dynamic" onclick=panelView()>
<h1>This is my title</h1>
<p>few words about my paragraph so it goes like this...</p>
<br><br>
</div>
</div>
解决方案
给top :0 insted of bottom。对于水平中心给左:50%;和变换:translateX(-50%):
推荐阅读
- python - 为什么 python socket.recvfrom 得到的字节流与 WireShark 爬取的字节流不同?
- node.js - 如何重复(添加循环)具有角度内容的html元素
- javascript - 'Point-along-path' d3 可视化性能问题
- css - 在 react js 中为不同的页面应用不同的背景图片
- python - Python 数据抓取:用一系列 href 和 prettify 抓取标题不起作用
- python - TensorFlow 多类分类损失
- sql-server - Sql Server 代理作业中的包在 Integration Services 目录中成功时失败
- polymer - 使用特定 tensorboard 的 Web 组件的推荐方法是什么?
- amazon-web-services - 指标过滤器分辨率
- unity3d - 更改材质所依赖的纹理属性后,是否必须再次将纹理添加回材质中?