Skip to content

Improve css so anchor don't go under sidebar #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions src/theme/book.css
Original file line number Diff line number Diff line change
Expand Up @@ -128,33 +128,45 @@ table thead td {
white-space: nowrap;
}
.page-wrapper {
left: 0;
position: absolute;
right: 0;
top: 0;
bottom: 0;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: padding-left 0.5s, margin-left 0.5s;
-moz-transition: padding-left 0.5s, margin-left 0.5s;
-o-transition: padding-left 0.5s, margin-left 0.5s;
-ms-transition: padding-left 0.5s, margin-left 0.5s;
transition: padding-left 0.5s, margin-left 0.5s;
-webkit-transition: padding-left 0.5s, margin-left 0.5s, left 0.5s;
-moz-transition: padding-left 0.5s, margin-left 0.5s, left 0.5s;
-o-transition: padding-left 0.5s, margin-left 0.5s, left 0.5s;
-ms-transition: padding-left 0.5s, margin-left 0.5s, left 0.5s;
transition: padding-left 0.5s, margin-left 0.5s, left 0.5s;
}
.sidebar-visible .page-wrapper {
padding-left: 300px;
}
@media only screen and (max-width: 1079px) {
.sidebar-visible .page-wrapper {
padding-left: 0;
margin-left: 300px;
}
left: 300px;
}
.page {
outline: 0;
padding: 0 15px;
}
.content {
position: relative;
top: 0;
bottom: 0;
overflow-y: auto;
right: 0;
left: 0;
padding: 0 15px;
padding-bottom: 50px;
}
.sidebar-visible .content {
position: absolute;
top: 52px;
}
.content > main {
margin-left: auto;
margin-right: auto;
max-width: 750px;
padding-bottom: 50px;
}
.content a {
text-decoration: none;
Expand Down
37 changes: 25 additions & 12 deletions src/theme/stylus/page.styl
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@

.page-wrapper {
box-sizing: border-box
left: 0
position: absolute
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't really dig having position: absolute, but can't think of another way to do it either.

right: 0
top: 0
bottom: 0

// Animation: slide away
transition: padding-left 0.5s, margin-left 0.5s
transition: padding-left 0.5s, margin-left 0.5s, left 0.5s
}

.sidebar-visible .page-wrapper {
padding-left: $sidebar-width
}

@media only screen and (max-width: $page-plus-sidebar-width - 1) {
.sidebar-visible .page-wrapper {
padding-left: 0
margin-left: $sidebar-width
}
left: $sidebar-width
}

.page {
Expand All @@ -24,15 +22,30 @@
}

.content {
margin-left: auto
margin-right: auto
max-width: $content-max-width
position: relative
top: 0
bottom: 0
overflow-y: auto
right: 0
left: 0
padding: 0 15px
padding-bottom: 50px

main {
margin-left: auto
margin-right: auto
max-width: $content-max-width
}

a {
text-decoration: none;
&:hover { text-decoration: underline; }
}

img { max-width: 100%; }
}

.sidebar-visible .content {
position: absolute
top: 52px
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how well this will scale - the header may have a different size depending on font settings (it's 51px on my machine).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 52 on mine haha.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you define it as something like 3 em to make sure the size scales appropriately? I imagine hard-coding the size is probably going to make a difference when people view things on mobile.

}