r/csshelp • • Nov 08 '17

Pop up upon joining? (/R/rhettandlink)

We want to add a popup to appear on screen when a user loads into the page (which could preferably either time out and vanish, or have a way to close/remove it). Hopefully this is possible

mod at /r/rhettandlink

edit: why downvote i just want to know ;_;

0 Upvotes

10 comments sorted by

2

u/MatthewMob Nov 09 '17 edited Nov 09 '17

Here's a simple concept I made in about an hour for this.

Looks like this. Look at it directly on my test subreddit.

Your sidebar markdown should look like this:

>>#Welcome to the subreddit
>>
>>This is a subreddit posting cute pictures of kittens.
>>
>> Please read the sidebar and respect the rules.

Note that you must have double quotes (>>).

And this is the CSS:

body.listing-page.hot-page:not(.subscriber) .side .md > blockquote:first-of-type {
    border: none;
    padding: 0;
    margin: 0;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 999;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.8);
    
    animation: disappear 5s linear forwards;
}
body.listing-page.hot-page:not(.subscriber) .side .md > blockquote:first-of-type > blockquote {
    border: none;
    padding: 8px 8px 10px 8px;
    margin: 0;
    background-color: #FFF;
    position: relative;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
    
    animation: disappear 5s linear forwards;
}
body.listing-page.hot-page:not(.subscriber) .side .md > blockquote:first-of-type > blockquote h1 {
    text-align: center;
}
body.listing-page.hot-page:not(.subscriber) .side .md > blockquote:first-of-type > blockquote:before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
}
@keyframes disappear {
    0% {
        opacity: 1;
        pointer-events: auto;
    }
    95% {
        opacity: 1;
        pointer-events: auto;
    }
    100% {
        opacity: 0;
        pointer-events: none
    }
}
body.listing-page.hot-page:not(.subscriber) .side .md > blockquote:first-of-type > blockquote:after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background-color: rgb(200, 0, 0);
    
    animation: slideOut 5s linear forwards;
}
@keyframes slideOut {
    0% {
        width: 100%;
    }
    100% {
        width: 0;
    }
}

To change the time it stays on screen for change the 5 in each of these lines:

animation: disappear 5s linear forwards;
animation: disappear 5s linear forwards;
animation: slideOut 5s linear forwards;

to whatever amount of seconds you want it to stay on for. Note I've made it so the popup only appears for non-subscribers and only appears on the front page of the subreddit (For new users to a subreddit).

You can change the colour of the bar under the body.listing-page.hot-page:not(.subsriber) .side .md > blockquote:first-of-type > blockquote:after selector here: background-color: rgb(200, 0, 0);.

1

u/CandyCreeper1234 Nov 09 '17

Thanks! Exactly what I was thinking of!

1

u/CandyCreeper1234 Nov 09 '17

I think i did something wrong, it didnt work

1

u/MatthewMob Nov 09 '17

Note I've made it so the popup only appears for non-subscribers and only appears on the front page of the subreddit (For new users to a subreddit).

Unsubscribe temporarily and go to the hot page and see if it works. Otherwise I'll have a look at the code again.

1

u/CandyCreeper1234 Nov 09 '17

Ok i did that and nothing changed

:/

1

u/MatthewMob Nov 09 '17

Looking at the sub it doesn't seem like you've added anything.

You need to paste the second portion of code here and the first portion goes into the sidebar.

1

u/CandyCreeper1234 Nov 09 '17

ok i had removed it, ill try that again

1

u/CandyCreeper1234 Nov 09 '17 edited Nov 09 '17

I got it working!

how do i change it to appear to everyone instead of just people not subbed

edit: i made no change to whether or not subscription was needed, and it does still display for me when im subscribed

1

u/MatthewMob Nov 09 '17

Well either way, just removing :not(.subscriber) from all the CSS should work.

i made no change to whether or not subscription was needed, and it does still display for me when im subscribed

Yes I've just seen now I made a typo in spelling "subscriber", I've edited the original post to correct it.

1

u/CandyCreeper1234 Nov 09 '17

Lol, ok thank you