[英]Wrap one right-floated element underneath another
I'm trying to put 2 divs beneath each other like this: 我试图像这样将2个div相互放置:
div 1
div 2
This is how far i've gotten in the HTML-file: 这是我在HTML文件中得到的结果:
<div width="100%" z-index:"1">
<div id="username-full">
<div id="username-form">
<input type="text" name="username" id="username-input" placeholder="Username" />
</div>
<div id="username-text">
<p>Username:</p>
</div>
</div>
</div>
<div width="100%" z-index:"1">
<div id="passwd-full">
<div id="passwd-form">
<input type="text" name="passwd" id="passwd-input" placeholder="passwd" />
</div>
<div id="passwd-text">
<p>Password:</p>
</div>
</div>
</div>
And this is my CSS-file: 这是我的CSS文件:
#username-full{
text-align:right;
float:right;
clear:right;
}
#username-text{
float:right;
margin-right:5px;
}
#username-form{
float:right;
margin-top:13px;
}
#passwd-full{
text-align:right;
float:right;
}
#passwd-text{
float:right;
margin-right:5px;
}
#passwd-form{
float:right;
margin-top:13px;
}
As you see, i've tried using the z-index, i've tried to give the 2 divs a width of 100% and i tried using float. 如您所见,我尝试使用z-index,我尝试将2 div的宽度设置为100%,并尝试使用float。 Also, I've tried using positioning, but that also didn't work.
另外,我尝试使用定位,但这也没有用。 I'm out of guesses :(.
我没有猜测:(。
Greetings, Luuk 问候,卢克
Based on your code, try adding this line: 根据您的代码,尝试添加以下行:
#passwd-full{
clear: both;
}
If you want two divs 100% with each and one above the other, you should try: 如果您希望两个div彼此之间都大于100%,则应尝试:
<div id="One">My first content</div>
<div id="Two">My second content</div>
#One, #Two {width: 100%; clear: both;}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.