_navbar.scss (15955B)
1 // 2 // Navbars 3 // -------------------------------------------------- 4 5 6 // Wrapper and base class 7 // 8 // Provide a static navbar from which we expand to create full-width, fixed, and 9 // other navbar variations. 10 11 .navbar { 12 position: relative; 13 min-height: $navbar-height; // Ensure a navbar always shows (e.g., without a .navbar-brand in collapsed mode) 14 margin-bottom: $navbar-margin-bottom; 15 border: 1px solid transparent; 16 17 // Prevent floats from breaking the navbar 18 @include clearfix; 19 20 @media (min-width: $grid-float-breakpoint) { 21 border-radius: $navbar-border-radius; 22 } 23 } 24 25 26 // Navbar heading 27 // 28 // Groups `.navbar-brand` and `.navbar-toggle` into a single component for easy 29 // styling of responsive aspects. 30 31 .navbar-header { 32 @include clearfix; 33 34 @media (min-width: $grid-float-breakpoint) { 35 float: left; 36 } 37 } 38 39 40 // Navbar collapse (body) 41 // 42 // Group your navbar content into this for easy collapsing and expanding across 43 // various device sizes. By default, this content is collapsed when <768px, but 44 // will expand past that for a horizontal display. 45 // 46 // To start (on mobile devices) the navbar links, forms, and buttons are stacked 47 // vertically and include a `max-height` to overflow in case you have too much 48 // content for the user's viewport. 49 50 .navbar-collapse { 51 overflow-x: visible; 52 padding-right: $navbar-padding-horizontal; 53 padding-left: $navbar-padding-horizontal; 54 border-top: 1px solid transparent; 55 box-shadow: inset 0 1px 0 rgba(255,255,255,.1); 56 @include clearfix; 57 -webkit-overflow-scrolling: touch; 58 59 &.in { 60 overflow-y: auto; 61 } 62 63 @media (min-width: $grid-float-breakpoint) { 64 width: auto; 65 border-top: 0; 66 box-shadow: none; 67 68 &.collapse { 69 display: block !important; 70 height: auto !important; 71 padding-bottom: 0; // Override default setting 72 overflow: visible !important; 73 } 74 75 &.in { 76 overflow-y: visible; 77 } 78 79 // Undo the collapse side padding for navbars with containers to ensure 80 // alignment of right-aligned contents. 81 .navbar-fixed-top &, 82 .navbar-static-top &, 83 .navbar-fixed-bottom & { 84 padding-left: 0; 85 padding-right: 0; 86 } 87 } 88 } 89 90 .navbar-fixed-top, 91 .navbar-fixed-bottom { 92 .navbar-collapse { 93 max-height: $navbar-collapse-max-height; 94 95 @media (max-device-width: $screen-xs-min) and (orientation: landscape) { 96 max-height: 200px; 97 } 98 } 99 } 100 101 102 // Both navbar header and collapse 103 // 104 // When a container is present, change the behavior of the header and collapse. 105 106 .container, 107 .container-fluid { 108 > .navbar-header, 109 > .navbar-collapse { 110 margin-right: -$navbar-padding-horizontal; 111 margin-left: -$navbar-padding-horizontal; 112 113 @media (min-width: $grid-float-breakpoint) { 114 margin-right: 0; 115 margin-left: 0; 116 } 117 } 118 } 119 120 121 // 122 // Navbar alignment options 123 // 124 // Display the navbar across the entirety of the page or fixed it to the top or 125 // bottom of the page. 126 127 // Static top (unfixed, but 100% wide) navbar 128 .navbar-static-top { 129 z-index: $zindex-navbar; 130 border-width: 0 0 1px; 131 132 @media (min-width: $grid-float-breakpoint) { 133 border-radius: 0; 134 } 135 } 136 137 // Fix the top/bottom navbars when screen real estate supports it 138 .navbar-fixed-top, 139 .navbar-fixed-bottom { 140 position: fixed; 141 right: 0; 142 left: 0; 143 z-index: $zindex-navbar-fixed; 144 145 // Undo the rounded corners 146 @media (min-width: $grid-float-breakpoint) { 147 border-radius: 0; 148 } 149 } 150 .navbar-fixed-top { 151 top: 0; 152 border-width: 0 0 1px; 153 } 154 .navbar-fixed-bottom { 155 bottom: 0; 156 margin-bottom: 0; // override .navbar defaults 157 border-width: 1px 0 0; 158 } 159 160 161 // Brand/project name 162 163 .navbar-brand { 164 float: left; 165 padding: $navbar-padding-vertical $navbar-padding-horizontal; 166 font-size: $font-size-large; 167 line-height: $line-height-computed; 168 height: $navbar-height; 169 170 &:hover, 171 &:focus { 172 text-decoration: none; 173 } 174 175 > img { 176 display: block; 177 } 178 179 @media (min-width: $grid-float-breakpoint) { 180 .navbar > .container &, 181 .navbar > .container-fluid & { 182 margin-left: -$navbar-padding-horizontal; 183 } 184 } 185 @media screen and (max-width: $screen-sm-min){ 186 padding: ($navbar-padding-vertical - 8) $navbar-padding-horizontal/2; 187 height: 45px; 188 padding-left: ($navbar-padding-horizontal * 0.8); 189 padding-top: ($navbar-padding-vertical * 0.4); 190 padding-bottom: $navbar-padding-vertical/2; 191 padding-right: $navbar-padding-horizontal; 192 } 193 } 194 195 196 // Navbar toggle 197 // 198 // Custom button for toggling the `.navbar-collapse`, powered by the collapse 199 // JavaScript plugin. 200 201 .navbar-toggle { 202 position: relative; 203 float: right; 204 margin-right: $navbar-padding-horizontal; 205 padding: 9px 10px; 206 @include navbar-vertical-align(34px); 207 background-color: transparent; 208 background-image: none; // Reset unusual Firefox-on-Android default style; see https://github.com/necolas/normalize.css/issues/214 209 border: 1px solid transparent; 210 border-radius: $border-radius-base; 211 212 // We remove the `outline` here, but later compensate by attaching `:hover` 213 // styles to `:focus`. 214 &:focus { 215 outline: 0; 216 } 217 218 // Bars 219 .icon-bar { 220 display: block; 221 width: 22px; 222 height: 2px; 223 border-radius: 1px; 224 } 225 .icon-bar + .icon-bar { 226 margin-top: 4px; 227 } 228 229 @media (min-width: $grid-float-breakpoint) { 230 display: none; 231 } 232 } 233 234 235 // Navbar nav links 236 // 237 // Builds on top of the `.nav` components with its own modifier class to make 238 // the nav the full height of the horizontal nav (above 768px). 239 240 .navbar-nav { 241 margin: ($navbar-padding-vertical / 2) (-$navbar-padding-horizontal); 242 243 > li > a { 244 padding-top: 10px; 245 padding-bottom: 10px; 246 line-height: $line-height-computed; 247 } 248 249 @media (max-width: $grid-float-breakpoint-max) { 250 // Dropdowns get custom display when collapsed 251 .open .dropdown-menu { 252 position: absolute; 253 float: none; 254 width: auto; 255 margin-top: 0; 256 background-color: #fff; 257 border: 1px solid #eee; 258 box-shadow: none; 259 > li > a, 260 .dropdown-header { 261 padding: 5px 15px 5px 25px; 262 } 263 > li > a { 264 line-height: $line-height-computed; 265 &:hover, 266 &:focus { 267 background-image: none; 268 } 269 } 270 } 271 } 272 273 // Uncollapse the nav 274 @media (min-width: $grid-float-breakpoint) { 275 float: left; 276 margin: 0; 277 278 > li { 279 float: left; 280 > a { 281 padding-top: $navbar-padding-vertical; 282 padding-bottom: $navbar-padding-vertical; 283 } 284 } 285 } 286 } 287 288 289 // Navbar form 290 // 291 // Extension of the `.form-inline` with some extra flavor for optimum display in 292 // our navbars. 293 294 .navbar-form { 295 margin-left: -$navbar-padding-horizontal; 296 margin-right: -$navbar-padding-horizontal; 297 padding: 10px $navbar-padding-horizontal; 298 border-top: 1px solid transparent; 299 border-bottom: 1px solid transparent; 300 $shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 1px 0 rgba(255,255,255,.1); 301 @include box-shadow($shadow); 302 303 // Mixin behavior for optimum display 304 @include form-inline; 305 306 .form-group { 307 @media (max-width: $grid-float-breakpoint-max) { 308 margin-bottom: 5px; 309 310 &:last-child { 311 margin-bottom: 0; 312 } 313 } 314 } 315 316 // Vertically center in expanded, horizontal navbar 317 @include navbar-vertical-align($input-height-base); 318 319 // Undo 100% width for pull classes 320 @media (min-width: $grid-float-breakpoint) { 321 width: auto; 322 border: 0; 323 margin-left: 0; 324 margin-right: 0; 325 padding-top: 0; 326 padding-bottom: 0; 327 @include box-shadow(none); 328 } 329 } 330 331 332 // Dropdown menus 333 334 // Menu position and menu carets 335 .navbar-nav > li > .dropdown-menu { 336 margin-top: 0; 337 @include border-top-radius(0); 338 } 339 // Menu position and menu caret support for dropups via extra dropup class 340 .navbar-fixed-bottom .navbar-nav > li > .dropdown-menu { 341 margin-bottom: 0; 342 @include border-top-radius($navbar-border-radius); 343 @include border-bottom-radius(0); 344 } 345 346 347 // Buttons in navbars 348 // 349 // Vertically center a button within a navbar (when *not* in a form). 350 351 .navbar-btn { 352 @include navbar-vertical-align($input-height-base); 353 354 &.btn-sm { 355 @include navbar-vertical-align($input-height-small); 356 } 357 &.btn-xs { 358 @include navbar-vertical-align(22); 359 } 360 } 361 362 363 // Text in navbars 364 // 365 // Add a class to make any element properly align itself vertically within the navbars. 366 367 .navbar-text { 368 //@include navbar-vertical-align($line-height-computed); 369 margin-top: 10px; 370 margin-bottom: 10px; 371 372 @media (min-width: $grid-float-breakpoint) { 373 float: left; 374 margin-left: $navbar-padding-horizontal; 375 margin-right: $navbar-padding-horizontal; 376 } 377 378 @media screen and (max-width: $screen-xs-max){ 379 margin-top: 3px; 380 margin-bottom: 2px; 381 margin-left: 5px; 382 margin-right: 5px; 383 } 384 } 385 386 387 // Component alignment 388 // 389 // Repurpose the pull utilities as their own navbar utilities to avoid specificity 390 // issues with parents and chaining. Only do this when the navbar is uncollapsed 391 // though so that navbar contents properly stack and align in mobile. 392 // 393 // Declared after the navbar components to ensure more specificity on the margins. 394 395 @media (min-width: $grid-float-breakpoint) { 396 .navbar-left { 397 float: left !important; 398 } 399 .navbar-right { 400 float: right !important; 401 margin-right: -$navbar-padding-horizontal; 402 403 ~ .navbar-right { 404 margin-right: 0; 405 } 406 } 407 } 408 409 410 // Alternate navbars 411 // -------------------------------------------------- 412 413 // Default navbar 414 .navbar-default { 415 background-color: $navbar-default-bg; 416 border-color: $navbar-default-border; 417 418 .navbar-brand { 419 color: $navbar-default-brand-color; 420 &:hover, 421 &:focus { 422 color: $navbar-default-brand-hover-color; 423 background-color: $navbar-default-brand-hover-bg; 424 } 425 } 426 427 .navbar-text { 428 color: $navbar-default-color; 429 } 430 431 .navbar-nav { 432 > li > a { 433 color: $navbar-default-link-color; 434 435 &:hover, 436 &:focus { 437 color: $navbar-default-link-hover-color; 438 background-color: $navbar-default-link-hover-bg; 439 } 440 } 441 > .active > a { 442 &, 443 &:hover, 444 &:focus { 445 color: $navbar-default-link-active-color; 446 background-color: $navbar-default-link-active-bg; 447 } 448 } 449 > .disabled > a { 450 &, 451 &:hover, 452 &:focus { 453 color: $navbar-default-link-disabled-color; 454 background-color: $navbar-default-link-disabled-bg; 455 } 456 } 457 458 } 459 460 .navbar-toggle { 461 border-color: $navbar-default-toggle-border-color; 462 &:hover, 463 &:focus { 464 background-color: $navbar-default-toggle-hover-bg; 465 } 466 .icon-bar { 467 background-color: $navbar-default-toggle-icon-bar-bg; 468 } 469 } 470 471 .navbar-collapse, 472 .navbar-form { 473 border-color: $navbar-default-border; 474 } 475 476 // Dropdown menu items 477 .navbar-nav { 478 // Remove background color from open dropdown 479 > .open > a { 480 &, 481 &:hover, 482 &:focus { 483 background-color: $navbar-default-link-active-bg; 484 color: $navbar-default-link-active-color; 485 } 486 } 487 488 @media (max-width: $grid-float-breakpoint-max) { 489 // Dropdowns get custom display when collapsed 490 .open .dropdown-menu { 491 > li > a { 492 color: $navbar-default-link-color; 493 &:hover, 494 &:focus { 495 color: $navbar-default-link-hover-color; 496 background-color: $navbar-default-link-hover-bg; 497 } 498 } 499 > .active > a { 500 &, 501 &:hover, 502 &:focus { 503 color: $navbar-default-link-active-color; 504 background-color: $navbar-default-link-active-bg; 505 } 506 } 507 > .disabled > a { 508 &, 509 &:hover, 510 &:focus { 511 color: $navbar-default-link-disabled-color; 512 background-color: $navbar-default-link-disabled-bg; 513 } 514 } 515 } 516 } 517 } 518 519 520 // Links in navbars 521 // 522 // Add a class to ensure links outside the navbar nav are colored correctly. 523 524 .navbar-link { 525 color: $navbar-default-link-color; 526 &:hover { 527 color: $navbar-default-link-hover-color; 528 } 529 } 530 531 .btn-link { 532 color: $navbar-default-link-color; 533 &:hover, 534 &:focus { 535 color: $navbar-default-link-hover-color; 536 } 537 &[disabled], 538 fieldset[disabled] & { 539 &:hover, 540 &:focus { 541 color: $navbar-default-link-disabled-color; 542 } 543 } 544 } 545 } 546 547 // Inverse navbar 548 549 .navbar-inverse { 550 background-color: $navbar-inverse-bg; 551 border-color: $navbar-inverse-border; 552 553 .navbar-brand { 554 color: $navbar-inverse-brand-color; 555 &:hover, 556 &:focus { 557 color: $navbar-inverse-brand-hover-color; 558 background-color: $navbar-inverse-brand-hover-bg; 559 } 560 } 561 562 .navbar-text { 563 color: $navbar-inverse-color; 564 } 565 566 .navbar-nav { 567 > li > a { 568 color: $navbar-inverse-link-color; 569 570 &:hover, 571 &:focus { 572 color: $navbar-inverse-link-hover-color; 573 background-color: $navbar-inverse-link-hover-bg; 574 } 575 } 576 > .active > a { 577 &, 578 &:hover, 579 &:focus { 580 color: $navbar-inverse-link-active-color; 581 background-color: $navbar-inverse-link-active-bg; 582 } 583 } 584 > .disabled > a { 585 &, 586 &:hover, 587 &:focus { 588 color: $navbar-inverse-link-disabled-color; 589 background-color: $navbar-inverse-link-disabled-bg; 590 } 591 } 592 } 593 594 // Darken the responsive nav toggle 595 .navbar-toggle { 596 border-color: $navbar-inverse-toggle-border-color; 597 &:hover, 598 &:focus { 599 background-color: $navbar-inverse-toggle-hover-bg; 600 } 601 .icon-bar { 602 background-color: $navbar-inverse-toggle-icon-bar-bg; 603 } 604 } 605 606 .navbar-collapse, 607 .navbar-form { 608 border-color: darken($navbar-inverse-bg, 7%); 609 } 610 611 // Dropdowns 612 .navbar-nav { 613 > .open > a { 614 &, 615 &:hover, 616 &:focus { 617 background-color: $navbar-inverse-link-active-bg; 618 color: $navbar-inverse-link-active-color; 619 } 620 } 621 622 @media (max-width: $grid-float-breakpoint-max) { 623 // Dropdowns get custom display 624 .open .dropdown-menu { 625 > .dropdown-header { 626 border-color: $navbar-inverse-border; 627 } 628 .divider { 629 background-color: $navbar-inverse-border; 630 } 631 > li > a { 632 color: $navbar-inverse-link-color; 633 &:hover, 634 &:focus { 635 color: $navbar-inverse-link-hover-color; 636 background-color: $navbar-inverse-link-hover-bg; 637 } 638 } 639 > .active > a { 640 &, 641 &:hover, 642 &:focus { 643 color: $navbar-inverse-link-active-color; 644 background-color: $navbar-inverse-link-active-bg; 645 } 646 } 647 > .disabled > a { 648 &, 649 &:hover, 650 &:focus { 651 color: $navbar-inverse-link-disabled-color; 652 background-color: $navbar-inverse-link-disabled-bg; 653 } 654 } 655 } 656 } 657 } 658 659 .navbar-link { 660 color: $navbar-inverse-link-color; 661 &:hover { 662 color: $navbar-inverse-link-hover-color; 663 } 664 } 665 666 .btn-link { 667 color: $navbar-inverse-link-color; 668 &:hover, 669 &:focus { 670 color: $navbar-inverse-link-hover-color; 671 } 672 &[disabled], 673 fieldset[disabled] & { 674 &:hover, 675 &:focus { 676 color: $navbar-inverse-link-disabled-color; 677 } 678 } 679 } 680 }