1

TL;DR: ASEsideNav won't inherit the height of any of it's parents, regardless of the "!important" tag. I just want the side bar to scale with the size of the contain in case the page extends farther than 800px (Which in a LOT of cases, it does). What do?

EDIT I've made a fiddle for the code now. First time using Fiddle, hope I did it correctly:
http://jsfiddle.net/B7k4G/

Please refer to the image below for everything being said. I've included screenshots, code and page layout within the image. I don't have the power to embed it into this thread and with how large the image is, it wouldn't be a good idea anyway. Moving on ~
https://i.stack.imgur.com/Sm8Jf.png

As you can see on the left, my collapsible navbar wont match the height of it's parent. The only way I was even able to fit the catalog part on the site is by having set a "min-height" to 800px. All I want is for ASEsideNav to match the height of defineMainRow or contentContainer, which are all children of ASEwrapper.

        <div class="col-xs-3 sidebar" id="ASEsideNav">
      <!-- This is left Vertical Nav bar -->
      <div class="navbar navbar-inverse" id="ASEsideNav">

      <!-- This is the heading -->
      <div id="ASEsideHeader">
        <h3 id="ASEheading">Our Products</h3>
      </div>

        <div class="collapse navbar-collapse" id="ASEsideNav">
          <ul class="nav nav-stacked" id="menu-bar"> <!-- Notice the "nav-stacked" class we added here -->
          </ul>

          <!-- This is the catalogue section -->
          <div>
            <div id="ASEsideHeader">
              <h3 id="ASEheading">Download Catalog</h3>
            </div>
            <div>
              <a href="/ase_site_new/downloads/catalog2009.pdf"><img src="/ase_site_new/images/catalog2009.png" width="228" height="168" alt="Download Catalog" class="center-block"></a>
            </div>
          </div>

        </div> <!-- End of navbar-collapse -->
      </div> <!-- End of navbar-inverse -->
    </div> <!-- End of row -->

I've tried a myriad of different properties pertaining to height, min-height and display but to no avail. I've even mucked about with it within Firebug and Firefox's native inspector and can't get ASEsideNav to do what I want. None of Auto, inherit, or % work.

I feel like there might be something I'm missing? Or maybe I have the format of something wrong. Though, I'm sort of afraid of changing the format because I'd then have to change a large number of HTML documents. There must be some way to fix this via CSS?

On the left, you can see the screenshot of the site being rendered. On the right you can see the class structure. Below those, you can see references to the HTML and CSS.

  <!-- This where the website begins -->

<!-- Applies black container shadow -->
<div id="ASEwrapper">

  <!-- This imports the top portion of the website -->
  <?php 
    $path = $_SERVER['DOCUMENT_ROOT'];
    $path .= "/ase_site_new/import/import_navtop.html";
    include_once($path);
  ?>

  <!-- These are the breadcrumbs that show the page progession -->
  <div class="container">
    <div class="row">
      <div class="col-xs-12" id="ASEbreadcrumbs">
        <ol class="breadcrumb">
          <li class="active">Home</li>
        </ol>
      </div>
    </div>
  </div>

  <div class="container" id="contentContainer">
    <div class="row" id="defineMainRow">

      <!-- This imports the side bar navigation of the website -->
      <?php 
        $path = $_SERVER['DOCUMENT_ROOT'];
        $path .= "/ase_site_new/import/import_navside.html";
        include_once($path);
      ?>

enter image description here

Isuress
  • 29
  • 1
  • 8

1 Answers1

1

As I can't test your code, I will make an attempt to solve it theoretically

Your ASEsideNav is inheriting it's height from the parent element defineMainRow which doesn't have a height and so there is nothing to inherit. Try setting defineMainRow's height to 100%. You may have to set the height of all elements containing it to 100% too, until a parent element has an explicit height (eg. 800px), or you reach the body element.

See this SO for details: CSS - make div's inherit a height

EDIT

Problem found: the sidebar is floated to left due to bootstrap's .sidebar class. A floated div is taken out of the regular flow of positioned elements and isn't aware of it's parent or sibling elements, thus it can't inherit a parent's height.

Sadly there is no fast and easy solution to this as layout is based on the floated sidebar so

option A: live with the current sidebar

or B: re-design your layout which I see as the best course of action. Remove content and focus on the layout of header, footer, sidebar and content. You will find a lot of tutorials out there to help you, SO is a good place to start: HTML page with a standard header footer layout without using table tag

Community
  • 1
  • 1
caffeinated.tech
  • 6,428
  • 1
  • 21
  • 40
  • I'm attempting to get a fiddle made for it but I haven't used fiddle before. I'll post a link shortly in another comment once I have it going. – Isuress Apr 22 '14 at 18:51
  • Alright, I think this should work. Hopefully you can find what's causing the issue? http://jsfiddle.net/B7k4G/ – Isuress Apr 22 '14 at 18:57
  • I would bet most likely this is the problem. Children can only *inherit* the height of their parent if their parent has a known, specific height. – Adam Jenkins Apr 22 '14 at 19:03
  • Wooa! what a fiddle... for starters the concept of the `id` tag is that it should be unique, never have two elements with the same id in a page. You should use classes for this. Also with the sheer size of that fiddle this will take ages, but I may figure it out in the end, I would usually advise making a minimalist example in a jsfiddle. – caffeinated.tech Apr 22 '14 at 19:06
  • @Adam, But I thought the default value for all heights is "auto" or something of that sort? Would it not automatically take that into consideration? I have to put "100%" on all the CSS IDs for the participating elements? Would that mess out anything perchance? – Isuress Apr 22 '14 at 19:08
  • @LcLk Yeah, I'm somewhat new at HTML and CSS. I've gotten most of the basics down and the website actually looks pretty good. It took awhile to make though because I'm an amateur. I actually gave you the entire stylesheet and the entire HTML document. I apologize for the complexity. There's already quite a few unique IDs though, there would be almost double the amount of IDs if I had to make a identifier for each element. Classes? I'm already inheriting things from bootstrap classes. Like I said, I'm still somewhat new at this. – Isuress Apr 22 '14 at 19:13
  • Automatically take what into consideration? `height: auto` (the default) just means that the height of an element is dictated by it's children. If a child element has `height:100%` and the parent element has `height:auto` - then `100%` of `auto` is unable to be determined. – Adam Jenkins Apr 22 '14 at 19:13
  • @Isuress, what @Adam said regarding height `auto` vs `100%`. It is indeed a complex site, well done on the layout thus far. You don't need unique IDs for eveything, use chained CSS selectors for that. But use classes for things like the `ASEnavLeftButton` – caffeinated.tech Apr 22 '14 at 19:17
  • @LcLk, thank you. I'm somewhat proud of it regardless of the headaches I've gotten from it. That aside, how could I go about doing what you're suggesting though? Maybe explain @Adam's thing further? As well as explain `chained CSS selectors` and how I would go about using classes verses IDs; while also incorporating the fact that I'm already using Twitter-Bootstrap classes for a lot of things. Truthfully, I'm not 100% on how those work at times. – Isuress Apr 22 '14 at 19:32
  • @Isuress, see my edit, turns out you can't, though a hack may be found. For CSS selectors see [this CSS-tricks page](http://css-tricks.com/multiple-class-id-selectors/) – caffeinated.tech Apr 22 '14 at 19:35
  • For the time being I think we'll stick with the current sidebar. It's not THAT bad, it would just be nice if it followed it's parent's height but it'll do for now. I'll eventually find a solution or redo it all just like you suggested I suppose. I appreciate you taking the time to help me figure this out. Thanks dude, sad that there ended up being no practical solution. I'll definitely look through the links you posted though and see what else I can learn! Thanks again ~ – Isuress Apr 22 '14 at 20:00
  • 1
    @Isuress, I did just come across a link talking through your exact issue with a rather ingenious solution: http://matthewjamestaylor.com/blog/equal-height-columns-cross-browser-css-no-hacks . Good luck and don't give up – caffeinated.tech Apr 22 '14 at 20:07
  • @LcLk, oh awesome! I'll definitely take a look at it tomorrow when I come back into work. I'm technically the IT guy but I've been working on this on the side for these guys for the time being as I wait for tickets to come in. I have 3 very long articles to read from you so I'll definitely be busy tomorrow, haha. ty ty ~ – Isuress Apr 22 '14 at 20:11