Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fill div with 2 colors?

Tags:

given a div that is 500px wide, is there a way to fill the background with 2 different colors using css? I know it can be done with a background image, but just wondering if it can be done with bg color. eg : enter image description here

like image 754
raklos Avatar asked Feb 20 '11 00:02

raklos


People also ask

How do I use two colors in CSS?

To use more than 2 colors (because why not), put the powerful rgba() to use and use 2 gradient parameters. Here's an example with the background property holding an image and masking some portion of the image with a gradient of orange and transparent.

How do I add two background colors in CSS?

CSS allows you to add multiple background images for an element, through the background-image property. The different background images are separated by commas, and the images are stacked on top of each other, where the first image is closest to the viewer.


1 Answers

You can't set multiple background colors, but you could set something like:

div.twocolorish {     background-color: green;     border-left: 20px solid red; } 

As long as you don't need text to go over the part in red then this would take care of you in one div.

like image 170
Andrew Avatar answered Sep 30 '22 15:09

Andrew