[英]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.