Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
<div name="outer" style='background-color:red; '>
       <div name="inner"style='background-color:yellow; '>

       some content<br>
       some content<br>
       some content<br>
       some content<br>
       some content<br>


        </div>
</div>




Note: inner div not set width and height static. inner div content bind dynamically from database so in database admin set width and height.this width and height fix to outer div. and also div must be show on center of window with responsive

thanks
Posted
Updated 25-Sep-17 3:19am
v4

If you want that inner div covers the whole width and height of your outer div, set width and height of your inner div to 100% like this
HTML
<div style="width:100%; height:100%"></div>
 
Share this answer
 
Comments
Member 11384516 2-Sep-15 3:40am    
if i set like that means div not center of window see

http://jsfiddle.net/yPMVJ/61/
Member 10371622 2-Sep-15 3:46am    
you want this ?
http://jsfiddle.net/yPMVJ/63/
Member 11384516 2-Sep-15 3:48am    
yes i want like that but no need to show red color as well as bottom and top not center of page remember don't set static bottom and top value
Member 10371622 2-Sep-15 3:54am    
If you don't want to show red color, simply remove the color of outer div.
what's the problem ?
Member 11384516 2-Sep-15 4:00am    
ok i will set. but top and bottom div not center see.
http://jsfiddle.net/yPMVJ/69/
Try this:
XML
<!DOCTYPE html>
<html>
<head>
<style>
#inner {
    background-color: yellow;
    position: absolute;
    top:0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
}
</style>
</head>
<body>
<div name="outer" id="outer">
       <div name="inner" id="inner" style="width:250px; height:350px">
       put your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents hereput your contents
put your contents here
        </div>
</div>
</body>
</html>

As for adding responsiveness, read my article From Indifferent to Responsive Web Design[^]
 
Share this answer
 
v2
If I get what you are asking and you want the outer div to fill up the whole window and the inner div to be in the center of the outer div.
You could try something like this (Testing in Chrome):
CSS
/*css*/
html, body {
    height:100%
}
.outer {
    background-color: red;
    height:100%;
}
.inner {
    background-color: yellow;
    position:relative;
    top:50%;
    width:50%;
    transform:translateY(-50%);
    margin: auto auto auto auto;
}

HTML
<!--html-->
<div name="outer" class="outer">
    <div name="inner" class="inner">put your contents here ...</div>
</div>

You can remove the background-color, they are only for show.
Here is the fiddle:http://jsfiddle.net/yPMVJ/71/[^]

Here is the link to the vertical align technique: http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/[^]
 
Share this answer
 
I didn't understand the meaning of this line
"How to set inner div width and height to outer div"

If you want to set position of your div center to your screen just set the style like this
HTML
<div style="margin: 0 auto"></div>
 
Share this answer
 
Comments
Member 11384516 2-Sep-15 3:29am    
hi there,
it mean inner div width:250px; height:350px means this width and height also affect to outer div

please see http://jsfiddle.net/yPMVJ/49/ this link i want show only yellow div
Member 10371622 2-Sep-15 3:32am    
What you want to do ?
Member 11384516 2-Sep-15 3:35am    
i want show div center on page with responsive like fancybox
Member 11384516 2-Sep-15 3:38am    
how can do this task? this is my question.because div content append from database html code. i did not set property static. one content small other more content.
Member 11384516 2-Sep-15 3:38am    
how can do this task? this is my question.because div content append from database html code. i did not set property static. one content small other more content.

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