Skip to content

Instantly share code, notes, and snippets.

@dotherightthing
Last active August 15, 2019 06:21
Show Gist options
  • Save dotherightthing/97e9f518ab923a1dff9b to your computer and use it in GitHub Desktop.
Save dotherightthing/97e9f518ab923a1dff9b to your computer and use it in GitHub Desktop.
[Match width] #scss

Match width

This generated a lot of CSS, so in the end i went with a JavaScript solution.

// lock search overlay width to primary nav width:
// this adds 6kb of compressed CSS ;-)
// this could be reduced with some sort of accuracy control
$l-form-search-bp-start: 856px;
$l-form-search-bp-end: 946px;
$l-form-search-bp-range: ($l-form-search-bp-end - $l-form-search-bp-start) / 1px; // removes unit
$l-form-search-bp-step: 1px;
$max-calc-offset-chrome: 0px; // working
$max-calc-offset-safari: 0px; // 16px; // NOT working, see below
$max-calc-offset-firefox: 0px; // working
@for $i from 1 through $l-form-search-bp-range {
@include at-breakpoint( em( $l-form-search-bp-start + ($i * $l-form-search-bp-step) ) 12 ) {
$max_calc: (629px + ($i * ($l-form-search-bp-step - 0.065px) ) );
max-width: $max_calc + $max-calc-offset-chrome;
margin-top: 30px; // TEST
.firefox & { // ok
@if ($max_calc/1px) == 723 {
$max_calc: 723px;
max-width: $max_calc + $max-calc-offset-firefox; // or may just be $max_calc??
}
}
.safari & {
@if ($max_calc/1px) == 723 {
$max_calc: 723px;
max-width: $max_calc + $max-calc-offset-firefox; // or may just be $max_calc??
}
// limit max width to 697
@if ($max_calc/1px) < 698 {
max-width: $max_calc + $max-calc-offset-safari;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment