Currently having problems with vertically aligning the slider buttons on Owl Carousel, so that as the slider responds the arrows stay in the vertical centre. I’ve set some CSS on the “.owl-controls.clickable” element so that it positions the buttons’ container 32% from the top but surely this should be 50% so that it stays consistent through each breakpoint?
Ah excellent, thanks for the response - didn’t think to use margin to re-position it after setting a top, doh!
Is this generally acceptable or seen as bad-practice?
I haven’t tended to use this method before since it means maintenance if the arrows were to change size, but can’t think of a suitable alternative?
You’d still need to change the size of the code for the arrow wouldn’t you so I don’t see ts much effort. If you want automatic alignment then you’d need to use flexbox or display:table-cell inside the absolute element.
You could also center easily if you have a fixed height.
It’s fine when its not a ‘magic number’ which it is not because you are working with a an element of fixed height. Negative margins are bad when you use them just to make things line up depending on a guessed size. For something like an arrow its fine bit not for a box full of fluid content.
Of course automatic is always better and if you nested a full height display:table element and a table-cell element inside your absolute element you could simply use vertical-align:middle.
Or indeed use flexbox although again the structure would probably need to be changed.
The easiest solution in this case is the negative margin or the fixed height auto margin example (the snippet above).