From c554e4a6fa61ae2ba6022bf8611327d8d6828800 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Sun, 1 Jan 2023 20:28:23 +0200 Subject: [PATCH] Add image text overlay --- snippets/image-text-overlay.md | 55 ++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 snippets/image-text-overlay.md diff --git a/snippets/image-text-overlay.md b/snippets/image-text-overlay.md new file mode 100644 index 000000000..3e0092c2e --- /dev/null +++ b/snippets/image-text-overlay.md @@ -0,0 +1,55 @@ +--- +title: Image with text overlay +tags: visual +author: chalarangelo +cover: blog_images/icebreaker.jpg +firstSeen: 2023-01-29T05:00:00-04:00 +--- + +Displays an image with a text overlay. + +- Use the `
` and `
` elements to display the image and the text overlay respectively. +- Use a `linear-gradient` to create the overlay effect over the image. + +```html +
+ +
+

Business
Pricing

+
+
+``` + +```css +.text-overlay-image { + box-sizing: border-box; + position: relative; + margin: 8px; + max-width: 400px; + max-height: 400px; + width: 100%; +} + +.text-overlay-image figcaption { + box-sizing: border-box; + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + display: flex; + flex-direction: column; + justify-content: flex-end; + background: linear-gradient(0deg, #00000088 30%, #ffffff44 100%); + color: #fff; + padding: 16px; + font-family: sans-serif; + font-weight: 700; + line-height: 1.2; + font-size: 28px; +} + +.text-overlay-image figcaption h3 { + margin: 0; +} +```