Nitish
Nitish

Reputation: 2763

CSS div coming inline

I am currently building a contact form. Code :

<div id="contact_form">
            <form action="contact.php" method="post">

                <div class="contact_fields">
                    <div class="cf1">NAME</div>
                    <div class="cf2">
                        <input type="text" name="name" />
                     </div>
                </div>

                <div class="contact_fields">     
                    <div class="cf1">EMAIL</div>
                    <div class="cf2">
                        <input type="text" name="name" />
                     </div>
                </div> 

                 <div class="contact_fields">     
                    <div class="cf1">PHONE</div>
                    <div class="cf2">
                        <input type="text" name="name" />
                     </div>
                </div> 

            </form>
        </div>

And The CSS :

#contact_form
{
    padding:12px 20px 10px 20px;
    background:#f5f5f5;
    overflow:hidden;
    width:700px;
}

.contact_fields
{
    width:580px;
    margin-top:20px;    
}

.cf1
{
    width:80px;
    float:left;
    color:#333333;
    font-family: Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif;
    font-size:14px;
}
.cf2
{
    width:280px;
    float:left;

}
.cf2 input
{
    height:25px;
    width:280px;
}

But the divs contact_fields are coming inline,instead of div with a break(see the image I have attached.)contact form Please offer me a solution

Upvotes: 0

Views: 57

Answers (2)

Rohit Azad Malik
Rohit Azad Malik

Reputation: 32182

Now define your parent .contact_fields overflow:hidden;

As like this

.contact_fields
{
overflow:hidden;    
}

Demo

Upvotes: 1

Mr. Alien
Mr. Alien

Reputation: 157334

Get rid of your float: left;

Demo

.cf2 {
    width:280px;
    float:left; <----Here
}

Upvotes: 1

Related Questions