CSS how did he do that?
Hello
I am wondering how did he do the next and prev buttons to the side of the image?
The site is responsive. He used CSS only.
The html code is:
20 Replies
look at the
banner
and arrows
classes in the dev toolsHow I did the CSS is:
arrow width missing
this is a video, not a site, so I cannot 🙂
In the video you can see the html, and the JS, but you cannot see the CSS
This is how I'd do it https://codepen.io/jochemm/pen/JoPpvQv
First of all, thank you for your answer.
But not good, because the button half out of range
you mean that they're half on, half off the image in the example?
Yes, and everithing centered, and responsive, so 800px not good too 🙂
you can add a padding to the slider if you want, to get the buttons half-off the image:
it is not centered
you asked about the buttons
yes, the button center is half in half out, what you wrote is not half
it's a proof of concept to help you along the way. Set the width of the buttons to some value defined in a variable and the padding to half that variable, then they'll be centered
and without centering everithing is differrent the button css too
it's really not, the buttons are only dependent on the contents of the banner class. You can center that however you want
that is not the rigth way I think
alright
I'll leave someone else to answer then
If you use my css, what I linked is better
sorry I do not want to be bed, I just write it is not what it is
slider have to be flex, because there are more images inside, and the arrows are the next/prev images
Nothing is preventing the use of display: flex on the slider. You asked about the buttons, so I made a minimal example of how you could do that. The fact that there's multiple children in an unrelated element has no effect on the buttons, so I didn't include that.
If you want people to work with the exact code you have, provide a fully functioning codepen and ask complete questions
also,
position: absolute
is almost never the better solutionYes, I understand. After your, I centered the button, but I think it could be better solution than playing with padding.
this is after your code: https://codepen.io/lanszelot/pen/VYZQdpO
you can use css variables to set the width and padding using the same value and some calc() math:
The -4px is 2x the border size on the buttons, you can also stick that in a variable if you want.
...
represents code I just hid for clarity in what I changedYes, this is working well.
Thank you so much