Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <body>
  <h1>Attractive Backgrounds for Texts on Wallpapers</h1>
  <h2>Extraordinary Backgrounds for Centered Text on Background Images &ndash; created with CSS</h2>
  <p>You can also view the examples with some explanations on my <a href="https://www.imarketinx.de/artikel/special-backgrounds-for-centered-text.html" title="Go to my website" target="_blank">website</a>.</p>

  <h3>1. Example with 'background: radial gradient'</h3>

  <div class="box-flex bg-flowers">
    <div class="box-content box-radial">
      <p class="text-caption">Some text with detailed informations
        <br><span><i>Some more text</i></span>
      </p>
    </div>
  </div>

  <hr>

  <h3>2. Example with an additional background image</h3>

  <div class="box-flex bg-wall">
    <div class="box-content box-broken">
      <p class="text-caption">Some text with detailed informations
        <br><span><i>Some more text</i></span>
      </p>
    </div>
  </div>

  <hr>

  <h3>3. Example with a 'screwed' background</h3>
  <p>The screws are 'screwed' into the four corners as <code>border-image</code>.</p>

  <div class="box-flex bg-wall">
    <div class="box-content box-screw">
      <p class="text-caption">Some text with detailed informations
        <br><span><i>Some more text</i></span>
      </p>
    </div>
  </div>

  <hr>

  <h3>4. Example with a 'pinned' background</h3>
  <p>The pins are 'pinned' into the four corners as <code>border-image</code>.</p>

  <div class="box-flex bg-flowers">
    <div class="box-content box-pin">
      <p class="text-caption">Some text with detailed informations
        <br><span><i>Some more text</i></span>
      </p>
    </div>
  </div>

  <hr>

  <h3>5. Colored example with an enamel sign effect</h3>
  <p>Screwed on like example no. 3 this pattern looks like an shield made from enamel fixed on a wall.</p>

  <div class="box-flex bg-wall">
    <div class="box-content box-enamel">
      <p class="text-caption caption-enamel">Some text with detailed informations
        <br><span><i>Some more text</i></span>
      </p>
      </div>
  </div>

</body>
              
            
!

CSS

              
                html {
  font-size: 100%;
}

body {
  max-width: 90rem;
  margin: 0 auto;
  padding: 1rem;
  font-family: sans-serif;
  line-height: 1.4;
  background: #efefef;
}

/* Flex container for the content boxes */
.box-flex {
  display: flex;
  flex-flow: column nowrap;
  align-items: center;
  justify-content: center;
  height: 80vh;
  width: 80vw;
  margin: 0 auto;
  padding: 0;
}

/* Two backgrounds for the content boxes */
.bg-flowers {
  background-image: url("https://img.imarketinx.de/pics/bg-flowers.jpg");
}
.bg-wall {
  background-image: url("https://img.imarketinx.de/pics/bg-wall.jpg");
}

/* Styles for all content boxes */
.box-content {
  display: flex;
  flex-flow: column nowrap;
  align-items: center;
  justify-content: center;
  height: 50vh;
  width: 50vw;
  padding: .5rem 1rem;
}

/* Styles for the examples */
.box-radial {
  background: radial-gradient(rgba(255,255,255,.1), rgba(255,255,255,.5));
  box-shadow: 0 0 5px 3px rgba(0, 0, 0, .4) inset;
  -webkit-filter: drop-shadow(5px 5px 20px rgba(255,255,255,.5));
  filter: drop-shadow(5px 5px 20px rgba(255,255,255,.5));
}

.box-broken {
  background-image: url("https://img.imarketinx.de/pics/bg-broken-glass.png"), linear-gradient(.5turn, rgba(255,255,255,.4), rgba(255,255,255,.7));
  background-position: center center;
  background-repeat: no-repeat;
  background-size: cover;
  box-shadow: 0 0 5px 3px rgba(0, 0, 0, .4) inset;
  -webkit-filter: drop-shadow(5px 5px 20px rgba(255,255,255,.5));
  filter: drop-shadow(5px 5px 20px rgba(255,255,255,.5));
}

.box-screw {
  background-image: radial-gradient(circle, rgba(255,255,255,.4) 5%, rgba(255,255,255,.5) 30%, rgba(255,255,255,.6) 55%);
  box-shadow: 0 0 1px 5px rgba(0, 0, 0, .2), 0 0 5px 2px rgba(0, 0, 0,.3);
  -webkit-filter: drop-shadow(5px 5px 2px rgba(255,255,255,.5));
  filter: drop-shadow(5px 5px 2px rgba(255,255,255,.5));
  border-style: solid; /* Chrome needs this to display the border image */
  border-image-slice: 27 27 27 27;
  border-image-width: 20px 20px 20px 20px;
  border-image-outset: 0px 0px 0px 0px;
  border-image-repeat: stretch stretch;
  border-image-source: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAABHPGVmAAAAh1BMVEUAAAAeHh4iIiIoKCgyMjI0NDQ3NzdEREROTk5PT09fX19ubm5ycnJ1dXV3d3d4eHh6enp7e3t9fX1+fn6AgICBgYGCgoKDg4OEhISFhYWHh4eJiYmKioqLi4uMjIyNjY2Pj4+QkJCRkZGSkpKUlJSXl5eYmJiZmZmcnJyfn5+goKCkpKSlpaVgxfUqAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQflBQQENTfQWvfTAAABDUlEQVRoBe2ayQ6CYBCDfzdU3EBlURERFNze//lMgABOenIumtTTtP4zDd+5xvz7L81f3U8QsvvX13N83od+1KwL2fiqISyGu2SVnOojQqpOt8uB27cmg6czqywh23ea6RJk0WB0d5xDeUVIzeXO7sV1e9b0unCOVcin7DxUjbE9Luapt7GrK0KqTrfLt9xfrh/ZtnaEbN/ppq3nb9ywuSFk43MgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARL4YQKoEoE8xSegSgTyFBEGVSKQp8kwqBKBPE0IqkQgT5NhREOivIU8VYhBlQjkqVJQJQJ5qhCDKhHI06VwmwTePIIYTWY6LzwAAAAASUVORK5CYII=");
}

.box-pin {
  background-image: radial-gradient(circle, rgba(255,255,255,.3) 5%, rgba(255,255,255,.4) 30%, rgba(255,255,255,.5) 55%);
  box-shadow: 0 0 1px 5px rgba(0, 0, 0, .2), 0 0 5px 2px rgba(0, 0, 0,.3);
  -webkit-filter: drop-shadow(5px 5px 20px rgba(255,255,255,.5));
  filter: drop-shadow(5px 5px 20px rgba(255,255,255,.5));
  border-style: solid; /* Chrome needs this to display the border image */
  border-image-slice: 27 27 27 27;
  border-image-width: 20px 20px 20px 20px;
  border-image-outset: 0px 0px 0px 0px;
  border-image-repeat: stretch stretch;
  border-image-source: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkAQMAAABKLAcXAAAABlBMVEUAAAAzMzPI8eYgAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAAHdElNRQflBQMPOiU1+U0MAAAFg0lEQVQ4EQF4BYf6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/AAAAAAAAAAAAAAAAAH+AAAAAAAAAAAPwAAAA/8AAAAAAAAAAB/gAAAD/wAAAAAAAAAAP/AAAAP/AAAAAAAAAAA/+AAAA/8AAAAAAAAAAD/4AAAD/wAAAAAAAAAAP/gAAAP/AAAAAAAAAAA/+AAAAf4AAAAAAAAAAD/wAAAA/AAAAAAAAAAAH/AAAAAAAAAAAAAAAAAP4AAAAAAAAAAAAAAAAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAB+AAAAH8AAAAAAAAAAAP8AAAA/4AAAAAAAAAAB/4AAAH/wAAAAAAAAAAP/gAAAf/AAAAAAAAAAA/+AAAB/8AAAAAAAAAAD/4AAAH/wAAAAAAAAAAP/gAAAf+AAAAAAAAAAAf+AAAA/4AAAAAAAAAAA/wAAAB/AAAAAAAAAAAB+AAAABwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACQwCtk0bXfiwAAAABJRU5ErkJggg==");
}

.box-enamel {
  padding:.5rem;
  background: linear-gradient(0deg, rgba(45,65,253,1) 0%, rgba(6,18,154,1) 100%);
  box-shadow: inset 0px 0px 16px 4px rgba(0,0,0,0.9);
  -webkit-filter: drop-shadow(5px 5px 20px rgba(255,255,255,.5));
  filter: drop-shadow(5px 5px 20px rgba(255,255,255,.5));
  border-style: solid; /* Chrome needs the border statements separated to display the border image */
  border-color: #06129A;
  border-width:.000000002px;
  border-image-slice: 27 27 27 27;
  border-image-width: 20px 20px 20px 20px;
  border-image-outset: 0px 0px 0px 0px;
  border-image-repeat: stretch stretch;
  border-image-source: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAMAAABHPGVmAAAAh1BMVEUAAAAeHh4iIiIoKCgyMjI0NDQ3NzdEREROTk5PT09fX19ubm5ycnJ1dXV3d3d4eHh6enp7e3t9fX1+fn6AgICBgYGCgoKDg4OEhISFhYWHh4eJiYmKioqLi4uMjIyNjY2Pj4+QkJCRkZGSkpKUlJSXl5eYmJiZmZmcnJyfn5+goKCkpKSlpaVgxfUqAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQflBQQENTfQWvfTAAABDUlEQVRoBe2ayQ6CYBCDfzdU3EBlURERFNze//lMgABOenIumtTTtP4zDd+5xvz7L81f3U8QsvvX13N83od+1KwL2fiqISyGu2SVnOojQqpOt8uB27cmg6czqywh23ea6RJk0WB0d5xDeUVIzeXO7sV1e9b0unCOVcin7DxUjbE9Luapt7GrK0KqTrfLt9xfrh/ZtnaEbN/ppq3nb9ywuSFk43MgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARIgARL4YQKoEoE8xSegSgTyFBEGVSKQp8kwqBKBPE0IqkQgT5NhREOivIU8VYhBlQjkqVJQJQJ5qhCDKhHI06VwmwTePIIYTWY6LzwAAAAASUVORK5CYII=");
}

/* Fluid and responsive typography */
/* Centered text on the content box */
.text-caption {
  --fluid-min: 1rem;
  --fluid-max: 2rem;
  --fluid-default: 1.75vw;
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  font-size: clamp(
    var(--fluid-min),
    calc(1rem + var(--fluid-default)),
    var(--fluid-max)
  );
  line-height: 1.2;
  text-align: center;
  text-shadow: 2px 2px 1px rgba(153, 153, 153, .5);
  word-break: break-word;
  -webkit-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
  color: #333;
}

.text-caption span {
  --fluid-min-span: .9rem;
  --fluid-max-span: 1.5rem;
  --fluid-default-span: 1.25vw;
   font-size: clamp(
    var(--fluid-min-span),
    calc(1rem + var(--fluid-default-span)),
    var(--fluid-max-span)
  );
}

@media screen and (max-width: 320px) {
  .text-caption {
    font-size: .85rem;
  }

  .text-caption span {
    font-size: .65rem;
  }
}

.caption-enamel {
  text-shadow: 2px 2px 1px rgba(0, 0, 0, .5);
  color: #f2f2f2;
}
              
            
!

JS

              
                
              
            
!
999px

Console