我有以下网址:Website
我真正想要做的是像现在一样将天气 DIV float 在页面顶部,但是当我展开或折叠它时,它只是浮动在顶部并且不会将任何内容向下推。如何实现?
我的天气 DIV CSS:
#weather {
margin: 0 auto;
padding: 0;
width: 177px;
font: 75%/120% Arial, Helvetica, sans-serif;
top: 0;
position: relative;
z-index: 999999999;
}
最佳答案
绝对定位
#weather {
position: absolute;
left: 50%;
width: 177px;
margin-left: -88px; /* 50% of the width */
}
并给你的 body 一个padding-top
当前包装的高度
body {
padding-top: 50px; /* or so */
}
关于html - 在 CSS 中 float 一个 DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15624620/