I want to have a single set of slide controls (next and prev buttons). I want to know how to fix position of these controls relative to image. I can do it at a fixed viewport width but as I change width the content adapt responsively and then button controls position changes.
Adrian Black
@thisfncodeioAll comments
- @Mahesh-yadavSubmitted over 4 years ago@thisfncodeioPosted over 4 years ago
Not sure what @ayoeix means by making the picture relative and position the controls absolutely to the picture, that would be some serious CSS voodoo. Because absolutely positioned elements can only be positioned to the closest PARENT element that also has a position set or be positioned relative to the body element. ('body' has a position of static by default)
You can, however, wrap the controls and the photo in a container div, then set the container to a position of relative and the controls to a position of absolute. This will remove the controls from the normal document flow and the container div will collapse to enclose the picture (ie. Only be as high and wide as the picture [there might be some extra whitespace and the bottom of the container that can easily be removed by setting the image to vertical-align: bottom]) you can then position the controls to hang halfway outside the container div. There's plenty of ways to do this, you can set the top position to 100% then translateX it back -50%. You can set the left position of the controls to whatever floats your boat.
The good thing about doing it this way is that the controls and the image are now one element (the container) and resizing the browser will have no effect on the controls therefore it won't jump around the page.
If you found this helpful, please give me a thumbs up. Thanks. Good Luck.
1 - @kawoodySubmitted over 4 years ago
The part that threw me the most is the left component (in desktop view). Even though I have a specific grid-gap between the three icons (and an empty 4th column) it would still sometimes stretch them out further than that. I think I could have put those icons in their own div and use flexbox with a flex-start and a margin-right. That probably would've solved that part.
I also wasn't sure the best way to extend the negative space of that component. The empty area to the right of the icons. Mine is slightly narrower than the design.
EDIT: I had a colon in the
@import
that was causing it to not import! Thanks @Channeas! ORIGINAL: I'm also not sure why the screenshot shows the "185" as lining figures. If you visit the live site it's using oldstyle figures.@thisfncodeioPosted over 4 years agoWow, this is nearly identical, Only thing I can see is that the first container with the logo needs a little more right padding than the mock, but besides that everthing looks good.
0 - @shylietaraSubmitted over 4 years ago
Not sure how to get rid of the white space at the bottom where the margin should be.
@thisfncodeioPosted over 4 years agoNot exactly sure what white space you're referring to because I can't see any. Your solution is nearly spot on except for the fact that the component was supposed to be contained in the center of the screen whereas your design takes up the full screen, and the top half of the card, is supposed to be white. Other than that, it's great.
0 - @kcdeSubmitted over 4 years ago
what is the purpose of the before and after pseudo-elements
@thisfncodeioPosted over 4 years agoFirst off, a great solution. Your solution does end up stretching the with of the entire screen which causes it to look off on widescreen devices. You could put a max-width on the container so it only stretches so far.
As for the purpose of pseudo-elements, they are exactly like regular elements except for the fact that they do not show up in the DOM therefore you cannot grab them with JS.
0