Results 1 to 10 of 10

Thread: Combining fixed/variable widths, and overriding selectors with classes

  1. #1
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default Combining fixed/variable widths, and overriding selectors with classes

    I have two questions.
    1) Is it possible to combine fixed and variable widths with CSS? I have a sidebar that makes (heavy) use of a background image. This needs to be the correct size (or have its background image stretched, preferably; however, I don't think this is possible). However, I'd really rather not make my whole site fixed-width.
    2) Likewise, is it possible to override some properties applied to an element using a descendant selector with a class (applied later using ECMAScript)? The only way I've found so far is to use !important, which evidently isn't an acceptable solution.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    1 ) Yes but, I'm not sure what you mean in this particular case. The bit about stretching the background image can only be done in IE but, it doesn't involve the background image property. Using a background image that can tile gracefully would probably be the best bet in this case.

    2 ) For a class selector to override something when applied using javascript, it must be something that the class could override without javascript. I don't think an id or inline style can be overridden with class. Of course you can always create a function with the object(s) as its argument that applies the desired property/value pairs and one that removes them and invoke each as needed.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Quote Originally Posted by John
    I'm not sure what you mean in this particular case.
    Fixed-width sidebar, then another float taking up the rest of the width.
    Using a background image that can tile gracefully would probably be the best bet in this case.
    You're probably right. I was avoiding it because I'd have to add floats for the edge images, which wouldn't
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey
    Fixed-width sidebar, then another float taking up the rest of the width.
    This can only work if the floats are all of the same dimensions complimentary to the space you want to fill, even then it can be somewhat of a crap shoot. Technically speaking, with fixed width, there is no 'rest of the width'. I'm guessing you mean the width not showing the background image. Floats are generally imprecise, this is their beauty but perhaps makes them unsuitable for your purposes. Absolute or relative positioned elements with their left and top positions calculated by script might be the way to go.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Quote Originally Posted by John
    Absolute or relative positioned elements with their left and top positions calculated by script might be the way to go.
    Use scripts for layout?! I think I'll use tables.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Well, you really have me at a loss. I have no idea what you are doing. I had the impression this was already dynamic script driven content. Why not do what we ask most folks to do, post a link to the problem page?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Because it doesn't exist yet I have images, and a layout, and I'm speculating on the implementation.
    It will use scripts for some effects, but under no circumstances do I intend to make it Javascript-dependent.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by Twey
    Because it doesn't exist yet I have images, and a layout, and I'm speculating on the implementation.
    It will use scripts for some effects, but under no circumstances do I intend to make it Javascript-dependent.
    Ungh. That's one reason why we ask people to post a link to their page. It is, as you well know, very hard to do hypothetical. One thing invariably depends upon another in layout and markup.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #9
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Indeed... but people give you strange looks if you write a layout, then ask for help writing a layout.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  10. #10
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    I have two questions.
    1) Is it possible to combine fixed and variable widths with CSS? I have a sidebar that makes (heavy) use of a background image.
    The rest of the document certainly can be fluid, if that's what you're asking (I'm not entirely sure).

    Using absolute positioning:

    Code:
    #content {
      margin-left: x;
    }
    #sidebar {
      left: 0;
      position: absolute;
      width: x;
    }
    HTML Code:
    <div id="content">
      <!-- ... -->
    </div>
    
    <div id="sidebar">
      <!-- ... -->
    </div>
    Using floats:

    Code:
    #sidebar {
      float: left;
      width: x;
    }
    #content {
      margin-left: x;
    }
    HTML Code:
    <div id="sidebar">
      <!-- ... -->
    </div>
    
    <div id="content">
      <!-- ... -->
    </div>
    This needs to be the correct size (or have its background image stretched, preferably
    As John said, an image that's amenable to tiling's better. Alternatively, one that fades or otherwise blends into the background.

    2) Likewise, is it possible to override some properties applied to an element using a descendant selector with a class (applied later using ECMAScript)?
    It depends what you're trying to override, or rather, how specific those definitions were. If the declarations were applied through an in-line style declaration or a selector containing an id attribute (specifically, #hash rather than [id=value]), then the only way to override those declarations using only a class selector is using the !important priority.

    It's all about specificity.

    I have images, and a layout, and I'm speculating on the implementation.
    Visual aids are very useful. Even if they're only mouse-drawn doodles.

    Mike

Bookmarks

Posting Permissions

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