Skip to content
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

add solution #3940

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 36 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,44 @@
<title>Calendar</title>
<link
rel="stylesheet"
href="styles/index.scss"
href="styles/main.scss"

Choose a reason for hiding this comment

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

The stylesheet is linked to a .scss file. Browsers cannot directly interpret SCSS files; they need to be compiled into CSS. Ensure that the SCSS file is compiled to a CSS file and link the resulting CSS file instead.

/>
</head>
<body>
<h1>Calendar</h1>
<!-- <div class="container"> -->
<div class="calendar calendar--start-day--wed calendar--month-length--31">
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
<div class="days"></div>
</div>
<!-- </div> -->
</body>
</html>
70 changes: 70 additions & 0 deletions src/styles/calendar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@import 'variables';

Choose a reason for hiding this comment

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

Ensure that the 'variables' file contains all the necessary variable definitions such as $block, $gap, $cal-padding, $days, etc., used in this SCSS file.


.container {
position: relative;
width: 100vw;
height: 100vh;
}

.calendar {
display: flex;
flex-wrap: wrap;
max-width: calc(#{$block-column * $block} + #{$gap * ($block-column - 1)});
gap: $gap;
padding: $cal-padding;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);

// &:nth-child(7n) {
// margin-top: 0;
// }

@each $day, $index in $days {
&.start-day--#{$day} {
@for $i from 1 through $index {
.calendar::before {
content: '';
width: $block;
height: $block;
margin-right: $gap;
background-color: transparent;
border: none;
}
}
}
}

}

.days {
width: $block;
height: $block;
background-color: #eee;
border: 1px solid #000;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
transition: transform 0.5s ease-in-out;
cursor: pointer;

@for $index from 1 through 31 {
&:nth-child(#{$index})::before {
content: '#{$index}';
// font-weight: normal;
}
}

&:hover {
transform: translateY(-20px);
background-color: #ffbfcb;
}
}

@for $index from 28 through 31 {
.calendar--month-length--#{$index} .days:nth-child(n + #{$index + 1}) {
display: none;
}
}
3 changes: 0 additions & 3 deletions src/styles/index.scss

This file was deleted.

14 changes: 14 additions & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@import 'calendar';

* {
box-sizing: border-box;
}

html {
font-family: Arial, Helvetica, sans-serif;
font-size: 30px;
}

body {
margin: 0;
}
5 changes: 5 additions & 0 deletions src/styles/variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$block: 100px;
$block-column: 7;
$gap: 1px;
$cal-padding: 10px;
$days: ('mon' 0, 'tue' 1, 'wed' 2, 'thu' 3, 'fri' 4, 'sat' 5, 'sun' 6);
Loading