Reputation: 13
I want two add two forms one on left and one on right of the page and then what i write should be displayed below them.But the problem is it is being shown between the two forms.
<form class="login">.....</form>
<form class="signup">.....</form>
<p>This content should be displayed below but it is displayed in space between the two forms</p>
CSS
.login{
float:left;
}
.signup{
float:right;
}
Upvotes: 0
Views: 1042
Reputation: 621
The use of floated element is highly discouraged since there are a lot of other better alternatives that can be used instead. Best alternatives are
CSS
.login{
display:inline-block;
}
.signup{
display:inline-block;
}
If you still want to use floated elements you can use a clearfix. Clearfix is a way an element automatically clears its child elements. For more information read How to use clearfix
Upvotes: 2
Reputation: 3071
Adding style clear:both
to your paragraph will help.
.clear
{
clear:both;
}
<p class="clear">This content should be displayed below but it is displayed in space between the two forms</p>
Upvotes: 0
Reputation: 1597
Mention the Width property width:50%;
it will work
.login{
float:left;
width:50%;
}
.signup{
float:right;
width:50%;
}
<form class="login">.....</form>
<form class="signup">.....</form>
<p>This content should be displayed below but it is displayed in space between the two forms</p>
Upvotes: 0