Finally, bugfix for overflows & incorrect paddings

This commit is contained in:
DarkCat09 2023-07-26 12:54:56 +04:00
parent df2d73bed3
commit 73f8046888
4 changed files with 18 additions and 27 deletions

View file

@ -28,18 +28,21 @@ const { title, description } = Astro.props;
@import "/src/styles/theme.less"; @import "/src/styles/theme.less";
@import "/src/styles/max_width.less"; @import "/src/styles/max_width.less";
* {
box-sizing: border-box;
}
body { body {
.theme-mixin(); .theme-mixin();
margin: 0; margin: 0;
padding: 0;
box-sizing: border-box;
padding: 0 @body-padding; padding: 0 @body-padding;
background: var(--bg); background: var(--bg);
color: var(--fg); color: var(--fg);
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Liberation Sans', 'Helvetica Neue', sans-serif; font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Liberation Sans', 'Helvetica Neue', sans-serif;
overflow-wrap: break-word;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -49,12 +52,13 @@ const { title, description } = Astro.props;
margin: auto; margin: auto;
padding: @main-padding; padding: @main-padding;
max-width: @max-width; max-width: @max-width;
width: 100%;
} }
article { article {
max-width: 100vw;
width: fit-content;
margin: auto; margin: auto;
width: fit-content;
.container-width-mixin();
&.centered { &.centered {
display: flex; display: flex;
@ -103,6 +107,7 @@ const { title, description } = Astro.props;
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
margin: 0; margin: 0;
line-height: 1.1;
} }
a, .link { a, .link {

View file

@ -49,7 +49,6 @@ const {
@import "/src/styles/max_width.less"; @import "/src/styles/max_width.less";
article { article {
.container-width-mixin();
margin: 0; margin: 0;
& > h1:first-of-type { & > h1:first-of-type {
@ -84,21 +83,15 @@ const {
} }
pre { pre {
.element-width-mixin(); padding: 0.75rem;
padding: 1rem;
border-radius: var(--bdrs); border-radius: var(--bdrs);
font-size: 1rem; font-size: 1rem;
font-family: font-family:
"JetBrains Mono", "Fira Code", "Iosevka", "Source Code Pro", "JetBrains Mono", "Iosevka", "Fira Code", "Source Code Pro",
"Liberation Mono", "Lucida Console", monospace; "Liberation Mono", "Lucida Console", monospace;
} }
figure {
.element-width-mixin();
}
img { img {
max-width: 100%; max-width: 100%;
display: block; display: block;
@ -114,7 +107,6 @@ const {
} }
table { table {
.element-width-mixin();
margin: auto; margin: auto;
border-collapse: collapse; border-collapse: collapse;

View file

@ -38,10 +38,12 @@ const description =
</BlogLayout> </BlogLayout>
<style lang="less"> <style lang="less">
@import "/src/styles/max_width.less";
#articles { #articles {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
gap: 0.8rem; gap: @body-padding + @main-padding;
} }
</style> </style>

View file

@ -1,19 +1,11 @@
@max-width: 50rem; @max-width: 50rem;
@body-padding: 0.5rem; @body-padding: 0.25rem;
@main-padding: 0.25rem; @main-padding: 0.15rem;
@all-padding: @body-padding * 2 + @main-padding * 2; @all-padding: @body-padding * 2 + @main-padding * 2;
// Bugfix for elements like <pre>
// that goes beyond container's width
.element-width-mixin() {
max-width: calc(100vw - @all-padding) !important;
box-sizing: border-box;
}
// Bugfix for containers like <article> // Bugfix for containers like <article>
// that somehow goes beyond container's width // that somehow goes beyond container's width
// trying to fit all the text // trying to fit all the text
.container-width-mixin() { .container-width-mixin() {
max-width: calc(~'100% -' @all-padding) !important; max-width: calc(~'100% -' @all-padding);
box-sizing: border-box;
} }