0

In my ruby on rails web application, I have an Image that consists of two colours the first portion is black and the second portion is blue. When I set this image on the background, the image is repeating:

body {
    background:url("bg.png");
}

but when I use below the repeatation of the image is remove:

body {
    background:url("bg.png") 0 0 repeat-x;
}

but vertically its not fit to the screen,

enter image description here

it covers the 2/3rd portion of the screen. and the black portion is fit but the blue portion not cover the remaining screen and I want to increase only the blue portion of the image not black, is it possible.

Kindly suggest me, waiting for your reply. Thanks.

user88
  • 1,174
  • 3
  • 27
  • 51

2 Answers2

0

It's possible to use CSS3 gradient together with a background image. See this Q&A for details.

Create a background image that is just the black part and then use the CSS gradient to create the blue part.

Community
  • 1
  • 1
RaneWrites
  • 268
  • 1
  • 2
  • 12
0

Different Elements

Using background images is an art

I would recommend using two elements - a "nav" element & then set the background of the body to the blue gradient. You can use the background-size: cover property to make this work:

http://jsfiddle.net/wM2B7/

#app/assets/stylesheets/application.css.scss
body {
    background: url("gradient.png");
    background-size: cover;
}

nav {
    height: 45px;
    display: block;
    background: url("black.png") 0 0 repeat-x;
}

This will allow you to give the illusion of having a single background image, whilst maintaining the flexibility of having multiple elements (I.E the body styling will act for the body, the nav styling will act for the nav)

Richard Peck
  • 76,116
  • 9
  • 93
  • 147