Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
New install of bootstrap-7.x-3.x-dev using jsDelivr CDN providing Bootstrap 3.3.2 checked at Bootlint shows error:
E004 Line 32, Column 3: Containers (`.container` and `.container-fluid`) are not nestable
I believe the error is coming from the container class in header:
<body class="html front logged-in no-sidebars page-node page-node- page-node-1 node-type-page" >
<div id="skip-link">
<a href="#main-content" class="element-invisible element-focusable">Skip to main content</a>
</div>
<header id="navbar" role="banner" class="navbar container navbar-default">
<div class="container">
<div class="navbar-header">
My workaround was to change navbar_classes_array in page.vars.php
if (bootstrap_setting('navbar_position') !== '') {
$variables['navbar_classes_array'][] = 'navbar-' . bootstrap_setting('navbar_position');
}
elseif(bootstrap_setting('fluid_container') === 1) {
// $variables['navbar_classes_array'][] = 'container-fluid';
$variables['navbar_classes_array'][] = '';
}
else {
// $variables['navbar_classes_array'][] = 'container';
$variables['navbar_classes_array'][] = '';
}
if (bootstrap_setting('navbar_inverse')) {
$variables['navbar_classes_array'][] = 'navbar-inverse';
}
else {
$variables['navbar_classes_array'][] = 'navbar-default';
}
}
Comments
Comment #1
waverate CreditAttribution: waverate commentedComment #2
markhalliwellTechnically speaking this isn't really a "bug", it's a bootlint error. One that has since been formed after this base theme has had numerous installs. Removing this is simply not an option as it would be a BC break that affect too many existing sites. The overrides.css file takes care of the nested container.
Would I love to become more "bootlint" compliant, sure. But this is something that, unfortunately, has to be addressed in 7.x-4.x.
Comment #3
burnsjeremy CreditAttribution: burnsjeremy as a volunteer commentedI see the fix for container in overrides.less but not for container-fluid. I understand the workaround, I would still call it a bug since its a bootstrap rule though. Can I add the patch for the workaround to include .container-fluid being nested or does that need to wait?
Comment #4
markhalliwellThe only reason it's a "rule" is because of bootlint and because it is intended to give warnings for using Bootstrap only classes (not custom overrides like this project has done). So no, this particular issue isn't a "bug", just more (mis-)informative than anything.
I have re-opened/re-purposed #2349387-5: .container-fluid fix not in overrides.less for navbar to address the .container-fluid override bug.
Comment #5
mfernea CreditAttribution: mfernea at AmeXio commentedI ran into this issue too. I added a custom width for .container and another one for .navbar.container. The end result was that the .container inside .navbar.container wasn't wide enough.
But I still see this as a problem. I can't figure out a situation where someone would need .container inside a .container. bootlint is right.The tpl file could be updated along with adding a change record for those who might rely on it.
For me this is: category = bug, priority = normal, status = active, version 7.x-3.x-dev :)
Comment #6
markhalliwellChanging to proper branch version for #2554199: Bootstrap 4.
Comment #7
markhalliwellActually, these related issues solved this specific problem in 8.x-3.x.
For 7.x-3.x, there are too many installations for this kind of BC breaking change to occur, thus I am closing this. If you're truly concerned about this, fix it in a sub-theme.