Skip to content

Commit 75e30eb

Browse files
committed
fixed overflow so it is a utility
1 parent e128bc4 commit 75e30eb

4 files changed

Lines changed: 51 additions & 19 deletions

File tree

README.md

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,13 @@ However, there still are a few issues. Unlike javascript, CSS still cannot be us
2525

2626
4. Font-family CSS variable for easy changing of default body font. Change `--font-primary` to your chosen font.
2727

28-
5. Sticky Footer. We use this [elegant solution](https://css-tricks.com/a-clever-sticky-footer-technique/) to make sure your footer is always at the bottom of the site, even when you have very little content on the page. This expects your footer to be directly in the body. If you need your footer inside a div and not directly in the body, you can view and implement these [other solutions](https://css-tricks.com/couple-takes-sticky-footer/).
28+
5. Sticky Footer. We use this [elegant solution](https://css-tricks.com/a-clever-sticky-footer-technique/) to make sure your footer is always at the bottom of the site, even when you have very little content on the page. This expects your footer to be directly in the body, or directly inside a `.page-wrap` element. If you need a different setup with sticky footer, you can view and implement these [other solutions](https://css-tricks.com/couple-takes-sticky-footer/).
2929

30-
6. Setting overflow-x so there is no horizontal scrolling. We've all been there... This can happen if an item is absolute and off to the side, even if its hidden. We fix it so that it works nicely even on iOS, where the page sometimes can lose its "springiness".
31-
32-
7. Images are responsive. All images will shrink to fit in their containers by default.
30+
6. Images are responsive. All images will shrink to fit in their containers by default.
3331

3432
## Utilities
3533

36-
Ok, so maybe a few utilities could be helpful. Only a few! Based on most websites out there, we created 8 utility classes that can be added in optionally by including the utilities file. These provide some basic and nifty layout classes to get you started, and to get any complexity out of the way. Sizing can be changed through the variables listed down below.
34+
Ok, so maybe a few utilities could be helpful. Only a few! Based on most websites out there, we created **9** utility classes that can be added in optionally by including the utilities file. These provide some basic and nifty layout classes to get you started, and to get any complexity out of the way. Sizing can be changed through the variables listed down below.
3735

3836
#### `.container-fluid`
3937

@@ -59,23 +57,41 @@ Important! For elements that will be read out loud on a screen reader device, bu
5957

6058
Very helpful for articles. Makes all items inside magically have good vertical rhythm. For some items, like headings, you may want to add styles to get those having more spacing with margins. Pairs well with container-content.
6159

60+
#### `.page-wrap`
61+
62+
The page wrap is a special element when dealing with overflow-x. It's useful when you have absolute items positioned off the screen, but don't want horizontal scrolling, like a hidden mobile menu. This class fixes it, so that it works nicely even on iOS, where things can get wonky. You can implement it directly on the body element, or on a div that is a direct child of body.
63+
64+
```HTML
65+
<body class="page-wrap">
66+
Everything....
67+
</body>
68+
69+
OR
70+
71+
<body>
72+
<div class="page-wrap">
73+
Everything....
74+
</div>
75+
</body>
76+
```
77+
6278
#### `.card-grid`
6379

6480
The perfect grid of cards! Using CSS Grid can be a bit scary, so we created a grid of cards that reflow nicely and can have a min and max size, changeable through CSS variables. It's cleaner than using flexbox for grids.
6581

6682
How to use:
6783

6884
```HTML
69-
<div class="card-grid my-elements">...</div>
85+
<div class="card-grid custom-class">...</div>
7086
```
7187

72-
Then in your CSS, you can override the card-grids sizing. The defaults are:
88+
Then in your CSS, you can override the card-grids sizing, using a custom class. The defaults are:
7389

7490
```CSS
75-
.my-elements{
91+
.custom-class{
7692
--card-min: 250px;
7793
--card-max: 1fr;
78-
--card-stretch: auto-fill; /* can be auto-fit too */
94+
--card-stretch: auto-fill; /* can also be auto-fit */
7995
}
8096
```
8197

@@ -95,7 +111,7 @@ Thats where `.container-content` makes this easy. You surround the article with
95111

96112
## CSS Variables
97113

98-
There are variables found at the bottom of Crucial.CSS and utilities. You can override them in your project, or change them directly. Remember, you can also override variables inside classes and media queries. Here are all the variables:
114+
There are variables found at the bottom of Crucial.CSS and utilities. You can override them in your project, or change them directly. Remember, you can also override variables inside classes and media queries, which is super helpful. Here are all the variables:
99115

100116
```CSS
101117
:root {
@@ -130,6 +146,7 @@ There are variables found at the bottom of Crucial.CSS and utilities. You can ov
130146
- Latest Chrome
131147
- Latest Firefox
132148
- Latest Safari
149+
- Latest Edge
133150

134151
## Install With NPM
135152

curcial.css

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ html {
1616
line-height: 1.5; /* 3 */
1717
-webkit-text-size-adjust: 100%;
1818
text-size-adjust: 100%;
19+
overflow-x: hidden;
1920
}
2021

2122
*,
@@ -28,17 +29,16 @@ html {
2829
========================================================================== */
2930

3031
/**
31-
* 1.Sticky Footer requires html and body have 100% height, so the footer stays at the bottom even when there is little content
32-
* 2. overflow-x is needed on both elements to hide offscreen items.
32+
* Sticky Footer requires html and body have 100% height, so the footer stays at the bottom even when there is little content
3333
*/
3434
html,
3535
body {
3636
height: 100%;
37-
overflow-x: hidden;
38-
transform: translate3d(0, 0, 0);
3937
}
4038

41-
body > footer {
39+
/* .page is for if the utility is used, the footer might be inside there */
40+
body > footer,
41+
.page-wrap > footer {
4242
position: sticky;
4343
top: 100vh;
4444
}
@@ -47,7 +47,6 @@ body > footer {
4747
* 1. Remove the body margin in all browsers.
4848
* 2. Add fonts
4949
* 3. Add font size
50-
* 4. Fixes strange behavior in iOS when we set body to overflow-x hidden
5150
*/
5251

5352
body {

demo.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,14 @@
6767

6868
.element {
6969
position: absolute;
70-
right: -100px;
70+
right: -90px;
7171
width: 100px;
7272
height: 100%;
7373
background: blue;
7474
}
7575
</style>
7676
</head>
77-
<body class="page">
78-
<div class="element">hello</div>
77+
<body class="page-wrap">
7978
<header>
8079
<div class="box"><p>I am a box</p></div>
8180
</header>

utilities.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@
2121
word-wrap: normal !important; /* Many screen reader and browser combinations announce broken words as they would appear visually. */
2222
}
2323

24+
/*
25+
Special div to fix overflow-x on absolute items.
26+
This should be at the top level item inside body
27+
*/
28+
.page-wrap {
29+
overflow-x: hidden;
30+
}
31+
32+
div.page-wrap {
33+
position: relative;
34+
min-height: 100%;
35+
}
36+
37+
body.page-wrap {
38+
transform: translate3d(0, 0, 0);
39+
}
40+
2441
/* basic padded container, centered with a max-width */
2542
.container {
2643
width: 100%;

0 commit comments

Comments
 (0)