Results 1 to 6 of 6

Thread: CSS: Displaying div with just a background?

  1. #1

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    CSS: Displaying div with just a background?

    I rarely have a need to do any kind of web development so any time I do need to do anything im pretty lost...

    (I'm making a asp.net control for my personal website )

    My target is Firefox/IE 6.0 (since this is private, and those are the only browsers i use)

    Anyway... the part i am having problems with is:

    (this is the first section div)
    Code:
    +-------------------------------+
    |   Section Text             |>>|
    +-------------------------------+
    |                               |
    |   A Link                      |                               
    |   A Link                      |
    |                               |
    +--------------------------------
    Code:
    MenuContainer Div
    -Sections Div
      -Section Div
        -Header Div
          -Header Text
          -Expand / Collapse Div
        -Body Div
          -Body Links
      -Section Div
        -Header Div
          -Header Text
          -Expand / Collapse Div
        -Body Div
          -Body Links
    this section is nested with in 3 divs (first one is the menu container, second is Sections container, and the third is the section container (holds the section header, and section body))

    I tried to cheat a bit and display the expand/collapse image as a div so i chould change all the images my modifing the css (the images are going to be dynamically generated)

    but it seems that both firefox or ie will not display a div unless it contains something...

    is there anyway i can force it to display a div?

    it shows how i want it to in Dreamweaver for some reason...
    Last edited by <ABX; Jan 31st, 2005 at 04:22 AM.
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: CSS: Displaying div with just a background?

    Browsers often disregard empty elements. But you can force them to appear but inserting some white space between them:
    HTML Code:
      <div class="empty">&nbsp;</div>
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Re: CSS: Displaying div with just a background?

    Just a few thoughts...
    A menu like yours are usually thought of as a list of links to different parts of the website.
    So it makes more sence to use lists instead of divs to build it.
    I have always used <ul><li></li></ul> for this kind of menu, but just reasently I saw a meny built with <dl><dt><dd></dd></td></dl> Where <dt>Would be the section header and the <dd>s the actual links in that section.
    I don't know which one is more correct, I would like some input on that.

    And about that collapse/expand image. What about putting it as the background of the <a> taggs? That way you won't need empty elements just for displaying images
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: CSS: Displaying div with just a background?

    at the very least set a width and height. That should help. Other wise see if setting the clear property to all helps. Since there's no content, the browser doesn't know how big to make it, so it proly ends up being 1x1 px, or what ever the min it takes (if there is a border or not.)

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Re: CSS: Displaying div with just a background?

    btw: i had width, height, and clear set... (also min-height, min-width at one point)
    &nbsp; worked

    McCain: I will play with those options, it seems like it would make applying styles and menu items easy.

    New Problem, i have been testing this in Firefox (because it has better standards compliance, and it its the browser i prefer) after getting the images to show up i tested it IE. IE doesnt seem to like my transparent images


    My Section headers also have a image background (a rectangle with 3 pixels removed from the top corners, for the round look) i made these images with photoshop and made the corner pixels transparent. this works on firefox with
    no problems :/ but not in IE.

    -IE does not like png with transparency, I guess i'll fix this when im supplying the dynamic image (M$ is really starting to annoy me, IE7 better be standards compliant)

    and i thought supporting IE6/Firefox would be easy...

    Anyway... i'm off to tweak my section header and body text layout ...

    I just cant wait till i have to figure out the javascript to make the expand/collapse work :/
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  6. #6
    Fanatic Member McCain's Avatar
    Join Date
    Jan 2002
    Location
    Sweden/Denmark
    Posts
    802

    Re: CSS: Displaying div with just a background?

    Yeah, IE doesn't like pngs very much...
    But it sounds to me like you could do with gifs, or do you need that alpha transparancy?
    Never argue with fools, they will only drag you down to their level, and beat you with experience.

    Q: How do you tell an experienced hacker from a novice?
    A: The latter thinks there's 1000 bytes in a kilobyte, while the former is sure there's 1024 meters in a kilometer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width