Hello huguys (and sorry for the terrible pun), I’m new to this great site builder.
I would like to know the best way to horizontally center an image in its container. I am using the Ananke theme including the Tachyons CSS lib.
Here is my train of thoughts:
- Centering an element in CSS means either to:
- (1) give it auto margins and display block, or
- (2) give the parent element a flex display and a justify-content center.
- Markdown doesn’t enable styling;
- raw HTML is discarded by Hugo;
- figure shortcode doesn’t have a
styleattribute; - figure shortcode allows a
classattribute which enables me to style with Tachyons; good! but:- figure shortcode doesn’t enable the (1)st way because it creates a
<figure>element with an<img>element inside, which I just can’t style as I want (anyway I didn’t manage to do so); centerand ajustify-centerTachyons classes enable the (2)nd way, but then it doesn’t seem right because if I add a caption it is also flexboxed and doesn’t slip under the image. So I’m guessing that I’m not using tools as they were intended. (literally guessing because I’m also new to Tachyons and modern HTML and CSS things such as<figure>and flexbox)
- figure shortcode doesn’t enable the (1)st way because it creates a
So I guess my questions are:
- Am I reasoning correctly in the Hugo paradigm?
- Is it possible to achieve the (1)st way with Hugo?
- Is there another way that I’m missing?