Click here to Skip to main content
15,905,414 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. I have to inputs and each one is within a div and those divs are within a larger container div. My problem is those inputs are smaller than their container divs. I don't know how to expand them to have equal size of height with their container divs. Below is my part of code.

What I have tried:

CSS
#tfheader{
		background-color:#c3dfef;
		position: relative;
		top:135px;
		height:250px;
	}

	#tfnewsearch{	
		display:inline-block;
		
	}

        .tftext{
		margin: 0;
		width: 210px;
		height:100%;	
		position: relative;
		font-family: Arial, Helvetica, sans-serif;
		font-size:14px;
		color:#666;
		border:1px solid #0076a3; 
		border-left-style:none;
		border-right-style:none;
				
	}
		
	.tftext.tftextinput1{box-sizing: border-box;}

        .tftext.tftextinput2{
	box-sizing: border-box;
	}
		
	
	.group: before,.group: after{
	 content:"";
	 position: absolute;
	 top:50%;
	 left:27%;    
	 height:33px;	 
	 display: table;
	 clear: both;
	}
			
	.inputdiv{
	vertical-align: top;
        position: relative;
        height:100%;
	display:table-cell;
	border:1px solid black;
	}

.tfclear{
		clear:both;
	}

HTML
<div id="tfheader">
	<center>
	<div class="group" style="border:1px solid black;">
		<form id="tfnewsearch" method="get" 

action="http://www.google.com" >
         <div class="inputdiv">
		       <input type="search" id="tfq1b" class="tftext 

tftextinput1" 
     name="q" size="21" maxlength="120" placeholder="Search our 

website"></input>
			   </div>
    <div class="inputdiv">			
    <input type="search" id="tfq2b" class="tftext 
    tftextinput2" name="q" size="21" maxlength="120" 

placeholder="city"></input>				  	 
    </div>
    </div>
    </form>
	</center>
		<div class="tfclear"></div>
    </div>
Posted
Updated 25-Sep-19 8:32am
Comments
ElenaRez 25-Sep-19 14:07pm    
Thank you very much for the solution. As you mentioned I had specified in the above code, in .group class which is a parent div I chose the the height to be 33px. After all, with your suggestion, I changed the value of height in inputdiv class which is such a sub container of the input to 33px. But still the the problem exists and the height of input is smaller than its container div "inputdiv" and thus its parent div "group". You know in my code "group class" is a very large container div and inside it there are 2 divs called "inputdiv" that each contains input.

Although setting the height or width to 100% should size to the containing <div>, I have found this to be a bit finicky on how the size of the container is defined.

Experiment: set the container, and perhaps it's container, too, to specific sizes in (such as in pixels). This should help you input elements know what it's 100% of that they're supposed to fill. Then - see which are not necessary.

It would be nice if just understood what you meant - but it doesn't always think the same way we do.
 
Share this answer
 
Remove display:inline-block; from the #tfnewsearch form. Inline-block elements don't play well with height:100%; rules.

Demo[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900