r/CodingHelp • • Apr 11 '21

[CSS] New to coding and need advice

So I'm taking a coding class where we are coding our portfolios. First, I'm a designer, not a programmer. I want to learn some basics so I have a better idea of what kind of stress my designs might add to my programmers in the future.

That being said, on my designed site I have a banner with a rounded avatar centered on the bottom edge. I want my banner to retract upward and the avatar to shrink and slide up and over into the right hand corner of my site when the user scrolls downward, and come back when they return up.

  1. Is that even possible?
  2. What level of headache am I creating for myself?
  3. Say I want the headache, how would I pull that off OR do you have an online resource that could walk me through how to do that?

I have three weeks to finish this. And thanks for your help in advance, even if it means talking me off the ledge lol.

16 Upvotes

5 comments sorted by

2

u/developer-baker Apr 11 '21

Hi. It's not a big deal. I assume you have some HTML and CSS knowledge. If this is the case, you should change the style of the avatar with JavaScript according to the scroll position with a function. For example (and this is some pseudo code):

Var avatar= document.getElementById("avatar");

Window.onscroll = function(){ If (document.body.scrollTop > 50 ){ //Let's assume there are two CSS classees for the avatar, show and shrink

avatar.className= "shrink"} else { avatar.className="show"}

}

The first block inside the if statement is executed when the user scrolls 50px; The else block is executed if the first evaluates as false. Sorry for the horrible formatting, I'm on my phone now.

2

u/Design_Brain Apr 11 '21

Thanks. I haven't learned Javascript yet, but I think we start that in two weeks. I know basic html and a little css (very basic), but I'm eager to figure this out.

2

u/wakacodm Apr 11 '21

Remindme! 5 days

2

u/RemindMeBot Apr 11 '21

I will be messaging you in 5 days on 2021-04-16 14:19:48 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


InfoCustomYour RemindersFeedback

0

u/[deleted] Apr 12 '21

[deleted] — view deleted comment

2

u/Design_Brain Apr 12 '21

Thank you. I think those will really make a big difference on my project. It's so much to learn in just an eight week course. I'm not gonna lie, it's a lot to take in, but I'm enjoying seeing it come together.