Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

background gradient with solid color

I have to do the following: The top of the div is an image of a gradient, then in the bottom it continues as a solid color. Can I do this with simple CSS? I know the following is invalid.

{background: url(img/right_column_bg_top.png) no-repeat rgba(10,26,39,1) top 225px;

Note: the first 225px, which the image fills, should be without the background-color

like image 893
marcias Avatar asked Jul 29 '13 12:07

marcias


People also ask

Can background color be a gradient?

Just as you can declare the background of an element to be a solid color in CSS, you can also declare that background to be a gradient. Using gradients declared in CSS, rather using an actual image file, is better for control and performance.

How do you fill a gradient with color?

Apply a preset gradientClick the shape, and when the Format tab appears, click Shape Fill. Click Gradient > More Gradients. Under Fill, click Gradient fill > Preset gradient and pick the one you want.

How do I create a gradient fill background?

Click the “Design” pane on the main menu bar across your screen. Click on the “format background” option. Switch to “gradient fill” Create your custom gradient of two, three, or more colors by adding in color stops.


1 Answers

As far as I know, you need to use a gradient for the solid color, so that you can set it correctly.

The CSS would be:

.imgbg {
   width:255px;
    height:355px;
   background:  url('http://blue2.hu/danone/nogravity/img/right_column_bg_top.png'), linear-gradient(90deg, #f7d8e8, #f7d8e8);
    background-position: 0px 0px, 0px 112px;
    background-repeat: no-repeat, no-repeat;
    background-size: 255px 112px, 255px 233px;
}

Here is your updated fiddle

Basic suport should be fine for browsers supporting multiple backgrounds, the only problem would be with IE <= 8. Gradient background could be a problem with IE9, but I think that it should work (I can not test IE9). If it would be really a problem, see colozilla for a fix.

like image 88
vals Avatar answered Sep 28 '22 02:09

vals