Skip to content
This repository has been archived by the owner on Jul 14, 2023. It is now read-only.

Commit

Permalink
Set outer-container max-width with argument
Browse files Browse the repository at this point in the history
Closes #201
  • Loading branch information
Reda Lemeden committed Aug 1, 2014
1 parent 25496b1 commit af4c2fe
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 3 deletions.
34 changes: 32 additions & 2 deletions app/assets/stylesheets/grid/_outer-container.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
@mixin outer-container {
/**
* Makes an element a outer container by centring it in the viewport, clearing its floats, and setting its `max-width`.
*
* Although optional, using `outer-container` is recommended. The mixin can be called on more than one element per page, as long as they are not nested.
*
* @param {Number} $local-max-width ($max-width) - Max width to be applied to the element. Can be a percentage or a measure.
*
* @example scss
* .element {
* @include outer-container(100%);
* }
*
* @example css
* .element {
* *zoom: 1;
* max-width: 100%;
* margin-left: auto;
* margin-right: auto;
* }
*
* .element:before, .element:after {
* content: " ";
* display: table;
* }
*
* .element:after {
* clear: both;
* }
*/

@mixin outer-container($local-max-width: $max-width) {
@include clearfix;
max-width: $max-width;
max-width: $local-max-width;
margin: {
left: auto;
right: auto;
Expand Down
6 changes: 6 additions & 0 deletions spec/neat/container_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@
it "sets max-width" do
expect('.container-default').to have_rule('max-width: 960px')
end

context "with max-width argument: 100%" do
it "sets max-width to 100%" do
expect('.container-custom-width').to have_rule('max-width: 100%')
end
end
end
6 changes: 5 additions & 1 deletion test/outer-container.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
$max-width: 960px;

.container-default {
@include outer-container;
@include outer-container();
}

.container-custom-width {
@include outer-container(100%);
}

0 comments on commit af4c2fe

Please sign in to comment.