Skip to content
Grav 2.0 is officially stable. Read the announcement →

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Themes & Styling

How to "push" next heading below floating image

Started by Bruno Gravato 6 years ago · 2 replies · 713 views
6 years ago

Hi,

Sorry if this is a very basic question or if I'm writing in the wrong place. I'm new to Grav and twig (and fairly new to Markdown). I'm loving it, but still trying to figure out my way around it.

I'm using Quark theme and I have a page with default template that is something like this:

MARKDOWN
# Title
## 1st Heading
![](image1.png&classes=float-right)
Some paragraphs...
---
## 2nd Heading
![](image2.png&classes=float-right)
Some more paragraphs...
---
## 3rd Heading
... (and so on) ...

My problem is that if the text height under each heading is shorter than the image height, then the image will "float over" to the next heading...

What can I do (either with Markdown, Twig, CSS, HTML, ...) to add a "section break" and force it to automatically add some extra vertical space between the paragraph and the HR, when the text height is shorter than the image, so that the HR (and the next heading) is pushed down just below the floating image?

I've search Grav manual and the forum but couldn't find any solution.

Thanks.

6 years ago

CSS Clearfix is normally used for such instances.
.clearfix::after{content: "";clear: both;display: table;}
Markdown is a rather flexible language. Try adding a few HTML line breaks <br> under the shorter paragraphs. Or just enough html <p>&nbsp;</p> to clear the image height. Bare in mind, I'm still rather new to Grav as well.

last edited 10/17/20 by lagaz dagrsen
6 years ago

Thank you for your reply!

@dagrsen:
Or just enough html <p>&nbsp;</p> to clear the image height.

That's my temporary fix but it's not the ideal solution... On a narrower browser window (such as in a mobile device) you'll end up with unnecessary vertical space.

I'll have a look at clearfix.

Suggested topics

Topic Participants Replies Views Activity
Themes & Styling · by Pedro M, 2 months ago
4 198 2 months ago
Themes & Styling · by Ian, 2 months ago
3 94 2 months ago
Themes & Styling · by Norbert, 2 years ago
11 455 3 months ago
Themes & Styling · by Lukáš Findeis, 3 months ago
0 48 3 months ago
Themes & Styling · by Sebadamus, 4 months ago
5 128 3 months ago