2

when I add the <form> tag in my HTML, it messes up the "inline" display of my form.

HTML that works:

<div class="header">
<a href="index.html"> <img src="icon.png" width="45"></a>
<div class="headertitle">TITLE</div>

    <select class="form-field">
    <option>test</option> 
    </select>

    <select class="form-field" >
    <option>test2</option>
    </select>

    <div class="headermenu">test3</div> 

    <select class="form-field" >
    <option>test4</option>
    </select>

   <div class="headermenu">test5</div>
 </div>

and if I add <form> it doesn't work... see html code:

<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="form1">    
    <select class="form-field">
    <option>test</option> 
    </select>

    <select class="form-field" >
    <option>test2</option>
    </select>

    <div class="headermenu">test3</div> 

    <select class="form-field" >
    <option>test4</option>
    </select>

</form>

look at image for working and non working image....

here is my CSS:

.header{width: 100%; background-color: #5e6172;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
align-items: center;    /* vertical align */
justify-content: center;    /* horizontal align */
position: fixed;
top:0; 
height: 80px;
} 

 .headertitle{color: #ffffff; font-size: 1.7em; font-family: h35; margin: 0 0.5%; 
 font-weight:bold; display: inline-block;}

 .headermenu{color: #ffffff; font-size: 1.4em; font-family: h35; margin: 0 0.3%; 
 display: inline-block;}

.form-field {background: #fff; color: #5e6172; padding:4px;  font-family: h35; 
 font-size: 1.2em; margin: 0 0.4%; }

.form-field:focus {background: #e0dedf;    color: #725129;    } 

enter image description here

enter image description here

2 Answers 2

2

you can add display: inline-flex to form to fix the container's width:

FIDDLE

Sign up to request clarification or add additional context in comments.

4 Comments

Thank you... but I see your TEST3 is slightly above the vertical center compare to the other ones.. how could I correct that ?
@user3011784 what browser are you on?
can you post a screen shot? im on chrome and im not seeing an alignment issue
well, it works well on my site.. the FiDDLE shows a slight problem, but on my site it's fine.. so thank you for the answer
0

The .header is a Flexbox, and it should have direct flex children, but <form> is blocking it.

Just add display: contents style to <form> so it will be ignored in CSS box/layout.

form {
    display: contents;
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.