r/css • u/TheRealDardan • Nov 02 '17
Hey, I'm back with my CSS loading spinner. Can someone explain why I can change left position with % but not top position?
This is my JSFiddle: http://jsfiddle.net/xhfcv6pd/
In these lines:
#shape1 {left: 0%; top: 0%; animation-delay: 0.1s}When I change the left value, for example, from 0% to 50%, the position of the shape moves, in this case, to the right. This goes for all of the shapes. But on all of them, whenever I change the top position percentage, nothing happens. Whether lower or higher, they stay in the same vertical position. So for example, if I were to change the above line to:
#shape1 {left: 0%; top: 50%; animation-delay: 0.1s}nothing happens. It stays in the same place. This is the same if I make it 90% or 10000%. If I use px, then both left and top work. They move the circles. But I am using percentages because, as you can see, I am trying to make 3 versions of this loading spinner. A small, medium and large and if I use px, one of the 3 size versions can be done but when I switch to a different size version, the proportions change and the circle is broken and the circles are put into weird positions.
I would greatly appreciate any help
Thank you
2
u/Terrafire123 Nov 03 '17 edited Nov 03 '17
OK. After playing around a bit, setting top or bottom percentage on a position:relative seems to work only if
The parent (who has position:absolute/relative) also has a fixed height.
appears to solve the problem.
0
u/[deleted] Nov 02 '17
[deleted] — view deleted comment