Current location: Hot Scripts Forums » General Web Coding » CSS » Auto adjust div on content


Auto adjust div on content

Reply
  #1 (permalink)  
Old 01-28-07, 09:31 AM
dihan dihan is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 267
Thanks: 0
Thanked 0 Times in 0 Posts
Question Auto adjust div on content

I'm new to CSS and I'm having the basic of problems. How can I set a div to change its dimensions with its content.

At present I have the shadow (com_shadow) and main area (com_post) which I'm trying to set so it so it will expand with the background color/image depending on the content. I'm sure its pretty straight forward but I've been trying for days with no joy.

http://www.dihan.co.uk/help/test.html

http://www.dihan.co.uk/help/comments.css

You can probably see what I'm trying to do but if not please let me know so I can be more clear.

Last edited by dihan; 01-28-07 at 09:59 AM.
Reply With Quote
  #2 (permalink)  
Old 01-29-07, 03:30 AM
Vicious's Avatar
Vicious Vicious is offline
Community VIP
 
Join Date: Jan 2007
Location: Belgium
Posts: 584
Thanks: 0
Thanked 0 Times in 0 Posts
haha actually I don't see what you want. Perhaps I'm stupid on this Monday morning
__________________
Jack Bauer makes Chuck Norris cry
Reply With Quote
  #3 (permalink)  
Old 01-29-07, 04:29 AM
dihan dihan is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 267
Thanks: 0
Thanked 0 Times in 0 Posts
lol. on the 1st one I needed the div shadow on the right hand side to be at 100% height so it would look like the comment area has a shadow and on the second one I need the main content area to be at 100% height (same height as the right hand side patten and shadow).

Please download the file to you comp and open it with dreamweaver and you can probably get a better idea.

Thanks for helping BTW
Reply With Quote
  #4 (permalink)  
Old 01-30-07, 03:42 PM
dihan dihan is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 267
Thanks: 0
Thanked 0 Times in 0 Posts
After weeks on this I found the answer. I'm already thinking of switching back to tables!! CSS is drving me nuts!!

http://www.alistapart.com/articles/fauxcolumns/
Reply With Quote
  #5 (permalink)  
Old 01-30-07, 06:24 PM
jfulton's Avatar
jfulton jfulton is offline
Community VIP
 
Join Date: Apr 2006
Location: Los Angeles, CA
Posts: 660
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
After weeks on this I found the answer. I'm already thinking of switching back to tables!! CSS is drving me nuts!!
Hahah, css is actually incredibly useful and simple once you learn it .

For your "comments" elements, you could simply do something like this:
Code:
.comment {
   width: 400px;
}
.comment .header {
   width:100%;
   height: 15px;
   background-image: url('url/to/image');
}

.comment .body {
   width:100%;
   background-image: url('url/to/image');
   background-repeat: repeat-y;
}

.comment .footer {
   width:100%;
   height:15px;
   background-image: url('url/to/image');
}
Code:
<div class="comment">
   <div class="header">posted by whoever on...</div>
   <div class="body">post information...</div>
   <div class="footer">any footer info if needed</div>
</div>
Of course, this is just mock code, but it gives you an idea of what you could do. If you piece together the background into a few blocks, then it won't clutter up your markup at all. The 'header' div will have the background for the top part of the block, the body will have the repeating side borders, and the footer will have the rounded corner.

Also, in your document, you were using IDs where you should've been using classes. IDs should only be used when the element is unique - when there will only ever be one of them on a page (ie. a footer, or a main navigation block.) A class should be used when there may be more than one (ie. a comment on a post, a gallery image.)

Hope that helps...and convinces you to stick with css!
Reply With Quote
  #6 (permalink)  
Old 01-31-07, 03:53 AM
Vicious's Avatar
Vicious Vicious is offline
Community VIP
 
Join Date: Jan 2007
Location: Belgium
Posts: 584
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by jfulton
Hope that helps...and convinces you to stick with css!
CSS is like quiting with alcohol/smoking: at first it's difficult, but it gets easier
__________________
Jack Bauer makes Chuck Norris cry
Reply With Quote
  #7 (permalink)  
Old 01-31-07, 05:04 AM
dihan dihan is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 267
Thanks: 0
Thanked 0 Times in 0 Posts
Ha ha.. Puerly on the fact that I've seen great new sites made by it, I think I will have a good try at it.. I'm still learning so I'm sure I will feel more comfortable knowing the restrictions
Reply With Quote
  #8 (permalink)  
Old 01-31-07, 05:43 AM
dihan dihan is offline
Coding Addict
 
Join Date: Jan 2004
Posts: 267
Thanks: 0
Thanked 0 Times in 0 Posts
PS. thanks for the tips.

and also I will try to quite smoking one day.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hideORshow tables, divs, or rows--need assistance deltatango5 JavaScript 2 09-20-06 08:48 AM
Writing content to a div drky JavaScript 3 08-22-06 01:43 PM
Can't Understand java script maverickminds JavaScript 1 07-16-06 01:23 PM
Replace DIV content if Flash is installed Wuiqed JavaScript 1 01-17-06 05:26 PM
Error On Registeration timmy408 ASP 2 09-05-04 02:53 PM


All times are GMT -5. The time now is 01:59 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.