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

[2주차 기본/심화 과제] 웨비의 사진관 😋 #4

Merged
merged 9 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion week2/assign1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ <h1>2021</h1>
</div>
</section>
</main>
<a class="top-btn" href="#top">
<a id="top-btn" href="#top">
<button type="button">▴</button>
</a>
<footer>end</footer>
<script src="script.js"></script>
</body>
</html>
7 changes: 7 additions & 0 deletions week2/assign1/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const windowHeight = window.innerHeight;
const topBtn = document.getElementById("top-btn");

document.addEventListener("scroll", () => {
console.log(window.scrollY, windowHeight);
topBtn.style.opacity = window.scrollY / windowHeight / 2;
});
Copy link
Member

Choose a reason for hiding this comment

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

저는 y축 스크롤 된거를 스크롤할 수 있는 최대치로 나눠서 구현했는데 이렇게도 할 수 있군요!

4 changes: 3 additions & 1 deletion week2/assign1/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ footer {
}

/* top button */
.top-btn {
#top-btn {
opacity: 0;

background-color: var(--green-color);
color: var(--white-color);

Expand Down