Hi. I’m trying to get our nonprofit’s new site design up this week but have hit a little snag with (I think) some CSS.
We have a quiz that’s responsive. Everything about it re-sizes nicely except the ‘NEXT’ and ‘PREVIOUS’ buttons. They don’t move and end up overlapping the answers.
Like I said, I think it’s a CSS issue but I’m not sure. Any help would be so appreciated.
I have a feeling position: absolute is the main culprit.
But until the HTML is valid there’s no way to know for sure.
You have a start p tag, div tags, script tags, then the closing p tag.
Both p and div tags are block level, and it could be the browser(s) “fix” this by adding the missing p tag before the starting div tag. But they aren’t smart enough to add an opening p tag before the closing p tag.
Try removing those (the pair of p tags) to see if it helps
Don’t position them absolutely, as you can simply place them under the questions statically and they will move with the rest of the content.
If you really want to use positioning, then a better approach is to add bottom padding to the quiz container and then position the buttons down in that padding area, which will ensure that they never overlap anything else.
Hi and thank you. I did change the positioning to static and two things happened that I didn’t know how to correct:
The (Next / Previous) buttons ran the whole width of the quiz (like the answer buttons).
They were stacked on top of each other - even though I tried to add margins.
I like your second suggestion best but I have no idea how to code it. The quiz script was found on the Internet and I’ve done my best to customize it. This is my last hang-up and I’m pretty lost.
I’m a bit of a CSS “hack” and I’m sure others will offer more robust changes, all I did was
div.prev
removed `bottom: 75px;`
changed `left:55px;` to `left: 2em;`
div.next
removed `bottom: 75px;
changed `right:55px;` to `right: 2em;`
The “px to em” is because px seemed like a “magic number” and I try to avoid those.
(except for known dimension images and border thickness - but not positioning)
I’m not seeing an overlap of the previous and next buttons unless you mean at narrow widths?
If so you will first need the meta viewport (see post #8) tag in place if you want the site to adapt to mobile correctly and then add this media query.