【发布时间】:2016-01-02 14:21:25
【问题描述】:
我目前正在开发一个简单的天气小部件,但在定位某些 div 时遇到了一些问题。我今天刚开始使用 CSS(但有其他编程语言的经验)。它需要向上 100 像素,我不知道为什么它会偏离这么多。
.
<style>
#weather
{
position: relative;
width: 100%;
height: 275px;
margin-left: auto;
margin-right: auto;
text-align: center;
background-color: rgba(32,32,32,0.5);
border-style: solid;
border-width: 1px;
border-color: rgba(32,32,36,0.7);
border-radius: 5px;
}
#temp
{
position: relative;
width: 15%;
height: 50;
top: 30px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
#wind
{
position: relative;
width: 75%;
height: 50;
top: 30px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
#desc
{
position: relative;
width: 75%;
height: 50;
top: 30px;
margin-left: auto;
margin-right: auto;
text-align: center;
}
</style>
.
这是发生定位错误的页面:http://www.thenorthcoastoutpost.com/lake
非常感谢任何有关定位 div/文本的帮助或提示。我尝试了多个使用不同 CSS 代码的网站,但似乎都没有帮助。
提前致谢。
【问题讨论】:
-
你想要哪个 div 在哪里?
-
天气 div 内的温度、风和降序。它们水平对齐,只是垂直根本不起作用。它完全对齐,但后来我在天气 div 中添加了一个轮廓,它就坏了。
-
它们已经垂直对齐。检查i.stack.imgur.com/zezzM.png
-
这很奇怪。它也没有显示正确的文本。我会截取屏幕截图,然后找个地方发布它,让你看看它在我的屏幕上的样子。
-
屏幕截图(移动端,但仍与桌面端相似):m.imgur.com/puzDVjw
标签: html css position css-position