• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

DIV Tag Auto Width and Height

 
Steve Dyke
Ranch Hand
Posts: 1621
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know that if I set auto width or height on my div tag the content will control the width and height. However, is there a way to control the width and height based on the parent of the div tag? I need on div tag set in the center of a parent div tag at 100% width and height with the padding set to 5px on the inner div tag so it appears to have a border.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WHat have you tried so far?
 
Steve Dyke
Ranch Hand
Posts: 1621
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:WHat have you tried so far?


I have tried things like this but it still adjusts to the size of the content and not the parent container.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64959
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems like you're over-thinking things a bit. Maybe all you need is:

height: 100%;
border: 5px solid red;


or whatever border color you need.

(Assuming that the outer div has a height.)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic