[英]Positioning 2 DIVs top of each other
我正在使用PHP,HTML和CSS创建一个网站。 我遇到了这个问题:有2个div:profile_Nick和profile_Ranks。 但是profile_Ranks不能只在profile_Nick下方行进。 如何在WalkerJetBat文本下方设置其位置? 谢谢。
.profile_Nick
{
font-family:"Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
color: white;
font-size: 34px;
margin-left: 12px;
padding-left:11px;
padding-top:2px;
padding-right:11px;
padding-bottom:2px;
float: left;
left:12px;
max-width: 405px;
background-color: rgba(0,180,255,0.60);
border-radius: 2px;
}
.profile_Ranks
{
position:relative;
font-family:"Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
color: white;
font-size: 12px;
margin-left: 12px;
padding-left:11px;
padding-top:2px;
padding-right:11px;
padding-bottom:2px;
float:left;
background-color: rgba(0,180,255,0.60);
border-radius: 2px;
top:50px;
}
<div class="profile_infoholder">
<div class="profile_Nick">
<? echo $steamprofile['personaname']; ?>
</div>
<div class="profile_Ranks">
Developer
</div>
<div class="profile_Ranks">
+Premium
</div>
</div>
发现顺便说一句。
.profile_infoholder .profile_Nick
{
position:absolute;
}
添加此固定。
解决方案在这里:
我刚刚从.profile_Nick
类中删除了float
属性
.profile_Nick
{
font-family:"Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
color: white;
font-size: 34px;
margin-left: 12px;
padding-left:11px;
padding-top:2px;
padding-right:11px;
padding-bottom:2px;
left:12px;
max-width: 405px;
background-color: rgba(0,180,255,0.60);
border-radius: 2px;
}
您的.profile_Ranks
样式表包含top:50px
属性,为了使它正确显示在演示的底部,我已对其进行了缩小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.