0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-11-30 12:24:19 +01:00
Bootstrap/site/static/docs/4.3/assets/scss/_component-examples.scss
Mark Otto 634344c003
v4/v5: Add responsive containers (#29095)
* create responsive containers

provide more flexibility and allow the user to determine when containers switch from fluid to fixed width.

* fix the base container code

this commit fixes the non-media portion of the generated CSS. I learned about the `@extends` directive and was able to put it to good use.

I create a new temporary map that contains all the main `$container-max-widths` and join it to our 2 special cases of 'xs' and 'fluid'.  Then we loop through that and, with the appropriate infixes, extend our placeholder

* formatting for style

forgot to run my tests before the last push, i think these are better.

* finish incomplete comment

* fix the responsive containers

using the `@extend` directive I was able to clean up this code

* fix responsive containers in the navbar

mostly we just look through all of our breakpoints so we can include all of the responsive container classes in the tweaks we have to do for the navbar (redeclaring flex properties, don't double up on padding, etc)

* Simplify container extends

* Simplify navbar containers

* Rearrange, add comments, ensure everything is nested in $enable-grid-classes

* Reduce new CSS by using attribute selector

We avoid using `@extend` whenever possible, and this is more readable

* Update _grid.scss

* Update _navbar.scss

* Add docs for responsive containers, redesign the container layout page

* Add to the Grid example
2019-07-21 17:38:36 -07:00

326 lines
4.8 KiB
SCSS

// stylelint-disable no-duplicate-selectors, selector-no-qualifying-type
//
// Grid examples
//
.bd-example-row {
.row {
> .col,
> [class^="col-"] {
padding-top: .75rem;
padding-bottom: .75rem;
background-color: rgba(86, 61, 124, .15);
border: 1px solid rgba(86, 61, 124, .2);
}
}
.row + .row {
margin-top: 1rem;
}
}
.bd-example-row-flex-cols .row {
min-height: 10rem;
background-color: rgba(255, 0, 0, .1);
}
.bd-highlight {
background-color: rgba($bd-purple, .15);
border: 1px solid rgba($bd-purple, .15);
}
.bd-example-responsive-containers {
[class^="container"] {
padding-top: .75rem;
padding-bottom: .75rem;
background-color: rgba(86, 61, 124, .15);
border: 1px solid rgba(86, 61, 124, .2);
}
}
// Grid mixins
.example-container {
width: 800px;
@include make-container();
}
.example-row {
@include make-row();
}
.example-content-main {
@include make-col-ready();
@include media-breakpoint-up(sm) {
@include make-col(6);
}
@include media-breakpoint-up(lg) {
@include make-col(8);
}
}
.example-content-secondary {
@include make-col-ready();
@include media-breakpoint-up(sm) {
@include make-col(6);
}
@include media-breakpoint-up(lg) {
@include make-col(4);
}
}
//
// Container illustrations
//
.example-container-element {
background-color: rgba($blue, .25);
border: 1px solid rgba($blue, .25);
}
//
// Docs examples
//
.bd-example {
position: relative;
padding: 1rem;
margin: 1rem (-$grid-gutter-width / 2) 0;
border: solid $gray-100;
border-width: .2rem 0 0;
@include clearfix();
@include media-breakpoint-up(sm) {
padding: 1.5rem;
margin-right: 0;
margin-left: 0;
border-width: .2rem;
}
+ .highlight,
+ .clipboard + .highlight {
margin-top: 0;
}
+ p {
margin-top: 2rem;
}
> .form-control {
+ .form-control {
margin-top: .5rem;
}
}
> .nav + .nav,
> .alert + .alert,
> .navbar + .navbar,
> .progress + .progress {
margin-top: 1rem;
}
> .dropdown-menu {
position: static;
display: block;
}
> .form-group:last-child {
margin-bottom: 0;
}
}
// Typography
.bd-example-type {
.table {
td {
padding: 1rem 0;
border-color: #eee;
}
tr:first-child td {
border-top: 0;
}
}
h1,
h2,
h3,
h4,
h5,
h6 {
margin-top: 0;
margin-bottom: 0;
}
}
// Images
.bd-example {
> svg + svg,
> img + img {
margin-left: .5rem;
}
}
// Buttons
.bd-example {
> .btn,
> .btn-group {
margin-top: .25rem;
margin-bottom: .25rem;
}
> .btn-toolbar + .btn-toolbar {
margin-top: .5rem;
}
}
// List groups
.bd-example > .list-group {
max-width: 400px;
}
.bd-example > [class*="list-group-horizontal"] {
max-width: 100%;
}
// Navbars
.bd-example {
.fixed-top,
.sticky-top {
position: static;
margin: -1rem -1rem 1rem;
}
.fixed-bottom {
position: static;
margin: 1rem -1rem -1rem;
}
@include media-breakpoint-up(sm) {
.fixed-top,
.sticky-top {
margin: -1.5rem -1.5rem 1rem;
}
.fixed-bottom {
margin: 1rem -1.5rem -1.5rem;
}
}
}
// Pagination
.bd-example .pagination {
margin-top: .5rem;
margin-bottom: .5rem;
}
// Example modals
.modal {
z-index: 1072;
.tooltip,
.popover {
z-index: 1073;
}
}
.modal-backdrop {
z-index: 1071;
}
.bd-example-modal {
background-color: #fafafa;
.modal {
position: relative;
top: auto;
right: auto;
bottom: auto;
left: auto;
z-index: 1;
display: block;
}
.modal-dialog {
left: auto;
margin-right: auto;
margin-left: auto;
}
}
// Tooltips
.tooltip-demo a {
white-space: nowrap;
}
// Scrollspy demo on fixed height div
.scrollspy-example {
position: relative;
height: 200px;
margin-top: .5rem;
overflow: auto;
}
.scrollspy-example-2 {
position: relative;
height: 350px;
overflow: auto;
}
.bd-example-border-utils {
[class^="border"] {
display: inline-block;
width: 5rem;
height: 5rem;
margin: .25rem;
background-color: #f5f5f5;
}
}
.bd-example-border-utils-0 {
[class^="border"] {
border: 1px solid $border-color;
}
}
//
// Code snippets
//
.highlight {
padding: 1rem;
margin-top: 1rem;
margin-bottom: 1rem;
background-color: $gray-100;
-ms-overflow-style: -ms-autohiding-scrollbar;
@include media-breakpoint-up(sm) {
padding: 1.5rem;
}
}
.bd-content .highlight {
margin-right: (-$grid-gutter-width / 2);
margin-left: (-$grid-gutter-width / 2);
@include media-breakpoint-up(sm) {
margin-right: 0;
margin-left: 0;
}
}
.highlight {
pre {
padding: 0;
margin-top: 0;
margin-bottom: 0;
background-color: transparent;
border: 0;
}
pre code {
@include font-size(inherit);
color: $gray-900; // Effectively the base text color
}
}