Inside a div I want to put a background color in the first 50% of it's width, and another color the other 50% of it's width. Ideally On resize I want it to adjust seamlessly without any artifacts or jittery effects.
Ideally I want to avoid using other divs inside the code as I'm working with existing HTML that is difficult to change - really looking for a 100% CSS solution.
I'm looking for something like this (I mocked this up with Fireworks):
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.
To add background color in HTML, use the CSS background-color property. Set it to the color name or code you want and place it inside a style attribute. Then add this style attribute to an HTML element, like a table, heading, div, or span tag.
you can use something like, but based upong the browsers you have to support, it may not work across all of them.
background: linear-gradient(to left, #ff0000 50%, #0000ff 50%);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With