This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes DIV Tag Auto Width and Height Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "DIV Tag Auto Width and Height" Watch "DIV Tag Auto Width and Height" New topic
Author

DIV Tag Auto Width and Height

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1394
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

Joined: Jan 10, 2002
Posts: 60810
    
  65

WHat have you tried so far?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1394
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

Joined: Jan 10, 2002
Posts: 60810
    
  65

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.)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DIV Tag Auto Width and Height
 
Similar Threads
div 'overflow:auto;' css question...
Control Image Size
scrollbar
Keeping DIV tags Displayed Correctly
Div Tag Width Changing si Undesireable