简体   繁体   中英

How to make full div without using width and height property?

I have a code

<div class="outer">
 <div class="inner">A</div>
</div>

My outer is responsive for window size ie width = 100%, height= 100%.

All i need is to make "inner" as height and width of 100%, but without using width and height property for inner?

i.e inner{height: 100%; width : 100%}

Even i dont want use js?

.outer{
position:relative;
}

.inner{
position:absolute;
left:0;
top:0;
right:0;
bottom:0;
}

Demo here

Here is the solution:

Using position property.

http://jsfiddle.net/9HTSA/

On the outer div set display:table;

On the inner div set display: table-cell

FIDDLE

we can do with position property

.outer{
position:relative;
}

link : http://www.w3schools.com/css/css_positioning.asp learn this

you can try below code:

<div class="outer" style="width:100%;height:100%">
  <div class="inner" style="display: block;height: inherit;">A</div>
</div>

Visit this Url:

http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks

It uses the float element for the output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM