Css add text to background

CSS Add text to background image using CSS

The following tutorial shows you how to use CSS to do «CSS Add text to background image using CSS».

CSS Style

The CSS style to do «CSS Add text to background image using CSS» is

.img-reponsive !-- w w w. d e m o 2s . c om --> display:block; max-width:100%; height:auto; margin:0 auto; > .textoverimage < position:relative; > p.title < position:absolute; top:75px; left:0; text-align:center; font-size:38px; width:100%; color:#fff > @media only screen and (max-width: 767px) < p.title < font-size:1.5em; line-height:1.5em; > > @media only screen and (max-width: 479px) < p.title < font-size:1.1em; line-height:1.1em; > >

HTML Body

body> div >"textoverimage"> img >"img-reponsive" src="http://cdn.shopify.com/s/files/1/0258/1101/t/2/assets/slideshow_3.jpg?5808719635421587686" alt="xxxx"> p >"title"> TEXT   

The following iframe shows the result. You can view the full source code and open it in another tab.

html> head> title>Custom text Over Image and Responsive meta name="viewport" content="width=device-width, initial-scale=1"> style id="compiled-css" type="text/css"> .img-reponsive < display: block; max-width: 100%; height: auto; margin: 0 auto; > .textoverimage !-- w ww . de mo 2 s . c o m --> position: relative; > p.title < position: absolute; top: 75px; left: 0; text-align: center; font-size: 38px; width: 100%; color: #fff > @media only screen and (max-width: 767px) < p.title < font-size: 1.5em; line-height: 1.5em; > > @media only screen and (max-width: 479px) < p.title < font-size: 1.1em; line-height: 1.1em; > >  body> div >"textoverimage"> img >"img-reponsive" src="http://cdn.shopify.com/s/files/1/0258/1101/t/2/assets/slideshow_3.jpg?5808719635421587686" alt="xxxx"> p >"title"> TEXT    

  • CSS divide a single background image across multiple divs to create «windowed» effect (Demo 2)
  • HTML CSS CSS on Tag Background Image Text
  • CSS Add centered text over a full-page, darkened, blurred background image (Demo 2)
  • CSS Add text to background image using CSS
  • CSS Adding text on background Image and zooming the image
  • CSS Apply opacity to background image but not text
  • CSS Apply opacity to background image but not text (Demo 2)

demo2s.com | Email: | Demo Source and Support. All rights reserved.

Источник

CSS text background

Hello fellows developers, As a CSS enthusiast I’m always trying to replicate designs I see using CSS. Today I wanted to create a text background for a paragraph.
I used codepen as always(God Bless Codepen). At first I added the necessary HTML I knew I wanted on the page:

  class="text-background">2021 “Do the hard jobs first. The easy jobs will take care of themselves.” Dale Carnegie  

Now I want my section to be centered on the screen, a dark background and some nice visuals for the body and for that I’ve added some CSS:

body  margin: 0; height: 100vh; width: 100%; background: #454545; display: grid; place-items: center; text-align: center; > 

For my particular design I want to have all the elements centered so I need to center everything inside the section also:

section  position: relative; display: grid; place-items: center; width: 100%; > 

The relative positioning will help me center and arrange the elements inside without having to mess with z-index(do to the fact of html elements order). Display grid and Place-items center will center the items inside the section. And the last and most important thing to do is to add position absolute to our text elements and some styling to look nice:

.text-background  position: absolute; font-size: 142px; color: #3d3d3d; > p  position: absolute; font-size: 20px; color: #eee; > 

The final result:
Thank you for reading this article and I’m curios if you have another method to achieve this result.

Источник

Читайте также:  Pycurl python 3 установка
Оцените статью