Reputation: 1746
I am working on a webpage where I am trying to arrange 4 div areas.
I am using below code to to create html:
<div class="input">
INPUT
</div>
<div class="output">
OUPUT
</div>
<div class="submit">
SUBMIT
</div>
<div class="save">
SAVE
</div>
and the css code:
.input{
width:45%;
float:left;
border-width:1px;
border-style:solid;
border-color:#ddd;
padding:10px;
margin-bottom:10px;
}
.output{
width:45%;
float:right;
border-width:1px;
border-style:solid;
border-color:#ddd;
padding:10px;
margin-bottom:10px;
}
.submit{
width:45%;
float:left;
border-width:1px;
border-style:solid;
border-color:#ddd;
padding:10px;
margin-bottom:10px;
}
.save{
width:45%;
float:right;
border-width:1px;
border-style:solid;
border-color:#ddd;
padding:10px;
margin-bottom:10px;
}
If all div
sections have data, they are aligning properly.But here, since output div
area getting data from a php script(echo the value), initially there will not be anything to display here.Due to that divs
are not aligning properly. the sumbit div
will occupy output div
area.
How can i fix it ? I need to stick submit div
eventhough there is no data in output.
I have setup a fiddle here. LINK if you try removing the OUPUT from output div section, you will see the issue
Upvotes: 0
Views: 686
Reputation: 178
If you still want to show the border on the output div without showing any data you can just put a
inside the div using the content property
.output:before{
content:"\00a0";
}
Upvotes: 0
Reputation: 370
Pass min-height:20px;` overflow:hidden; in .output class . infact can pass this property to every class.
Upvotes: 0
Reputation: 18008
If you want to show .submit
always below .input
, use clear:both
on .submit
.
Fiddle: http://jsfiddle.net/Qpc6F/1/
(by the way, I have used display:none
on .output
to have the effect of empty content. Remove it in your code.)
Upvotes: 3