Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Is It Possible To Insert 2 Separate Background Images?

Featured Replies

I wanted to create a stripe from one side of the page to the other, no matter the resolution.

So I used this code:

 

body {
background:url('url/to/img.png') repeat-x;
}

 

I created that way a pattern with an image that repeats itself so it creates a stripe.

Now I want to add another stripe at another part of the page. How do I set another stripe at a different place with that code?

You can just separate multiple background images with a comma. Either like this,

 

 

/*could all be on one line*/

background: url('../images/bg-image.png') 50% 50% no-repeat, 
            url('../images/bg-image2.png') 100px 250px repeat-x, 
            url('../images/bg-image3.png') 300px 300px no-repeat;

 

 

or separate each set of values, like this,

 

 

background-color : #B4DA55;
background-image : url('../images/bg-image.png'), url('../images/bg-image2.png'), url('../images/bg-image3.png');
background-repeat : no-repeat, repeat-x, repeat;
background-position : 100% 95%, -10% 100%, 0 0; 
 

 

Edited by JustOliver

  • Author

 

You can just separate multiple background images with a comma. Either like this,

 

 

/*could all be on one line*/

background: url('../images/bg-image.png') 50% 50% no-repeat, 
            url('../images/bg-image2.png') 100px 250px repeat-x, 
            url('../images/bg-image3.png') 300px 300px no-repeat;

 

 

or separate each set of values, like this,

 

 

background-color : #B4DA55;
background-image : url('../images/bg-image.png'), url('../images/bg-image2.png'), url('../images/bg-image3.png');
background-repeat : no-repeat, repeat-x, repeat;
background-position : 100% 95%, -10% 100%, 0 0; 
 

 

 

 

Okay then lets say I want this image to be at the top with repeat x:

http://imageshack.us/a/img689/4559/5f7a.jpg

 

And this image at the bottom repeat x too:

http://imageshack.us/a/img203/7673/2cs8.jpg

 

What do I need to write in the first code to do that and do I paste it in the CSS just the way it is?

if it's a simple stripe then you can take it a step further and just use the css linear gradients avoiding the need for an image which is always a plus.

 

I knocked up a quick fiddle demonstrating how it can be done, I also threw in a regular css gradient so you can see how the syntax differs between a gradual gradient and a more instant change in colour.

 

http://jsfiddle.net/vyYz5/

 

* If you use this code don't forget to add in the other vendor prefixes.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.