Hi friends is there any possible to get a double color background like this as 100% width and height like this
Here is the sample image:
Sample Image http://www.mediaserveit.com/demo/vivek/resources/question.png
(sample)white in left hand side rest of them are other color.
if i did with div's means
.left{
float:left;
width:30%;
background-color:#fff;
}
.right{
float:right;
width:70%;
background-color:#B97A57;
}
which made height problem.it increases depends upon the contents on the div's.if i use min-height means it also changed on different screens.if there any hack to set like this background in html body!because i need it in full screen
Use a gradient as background.
body{
background: #fcfcfc; /* Old browsers */
background: -moz-linear-gradient(left, #fcfcfc 30%, #6b1717 30%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(30%,#fcfcfc), color-stop(30%,#6b1717)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #fcfcfc 30%,#6b1717 30%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #fcfcfc 30%,#6b1717 30%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, #fcfcfc 30%,#6b1717 30%); /* IE10+ */
background: linear-gradient(to right, #fcfcfc 30%,#6b1717 30%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#fcfcfc', endColorstr='#6b1717',GradientType=1 ); /* IE6-9 */
}
Gradient generated using: http://www.colorzilla.com/gradient-editor/
Demo: http://jsfiddle.net/guE5L/
Related
Unable to use gradient along with image.
This works:
background: red url("/Style Library/Images/Recurr.png") center no-repeat
This wont work:
background: linear-gradient(black, white) url("/Style Library/Images/Recurr.png") center no-repeat
How to use gradient along with image.
You can use it.
See this:
background: #6cab26;
background-image: url(/Style Library/Images/Recurr.png); /* fallback */
background-image: url(/Style Library/Images/Recurr.png), -webkit-gradient(linear, left top, left bottom, from(#6cab26), to(#6ceb86)); /* Saf4+, Chrome */
The key is to use background-image for image and background for gradient.
I have included redundancies for other browsers.
.Blue{
background:#47b; /* Old browsers */
background:-webkit-linear-gradient(top,#47b 0%,#249 100%); /* Chrome10+,Safari5.1+ */
background:-o-linear-gradient(top,#47b 0%,#249 100%); /* Opera 11.10+ */
background:-ms-linear-gradient(top,#47b 0%,#249 100%); /* IE10+ */
background:linear-gradient(to bottom,#47b 0%,#249 100%); /* W3C */
filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#4477bb',endColorstr='#224499',GradientType=0); /* IE6-9 */
background-image: url("/Style Library/Images/Recurr.png") center no-repeat;
}
I would like to put a gradient border at the top of a div.
So the start color should be #c4268c and ends with #9a0b72
<div class="bordertest"></div>
For easing here is the fiddle :http://jsfiddle.net/aKhjk/
I searched but could not find a suitable way.
you could use an image http://border-image.com/ or use a pseudo element over your border :
.bordertest {
height:300px;
width:300px;
border-top:30px solid #c4268c;
background:#000;
position:relative;
margin:1em;
}
.bordertest:first-child:before {
content:'';
position:absolute;
width:100%;
height:30px;
background:linear-gradient(to left, #c4268c, #9a0b72);
top:-30px;
left:0;
}
http://jsfiddle.net/aKhjk/1/ - jsfiddle.net/aKhjk/3
Try this, its also cross browser ready. So not so much work for you to do.
http://jsfiddle.net/cornelas/aKhjk/6/
.bordertest {
height:300px;
width:300px;
border-top:30px solid #c4268c;
/** Created at http://www.colorzilla.com/gradient-editor/ **/
background: rgb(196,38,140); /* Old browsers */
background: -moz-linear-gradient(top, rgba(196,38,140,1) 0%, rgba(154,11,114,1) 5%, rgba(0,0,0,1) 10%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(196,38,140,1)), color-stop(5%,rgba(154,11,114,1)), color-stop(10%,rgba(0,0,0,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(196,38,140,1) 0%,rgba(154,11,114,1) 5%,rgba(0,0,0,1) 10%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(196,38,140,1) 0%,rgba(154,11,114,1) 5%,rgba(0,0,0,1) 10%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(196,38,140,1) 0%,rgba(154,11,114,1) 5%,rgba(0,0,0,1) 10%); /* IE10+ */
background: linear-gradient(to bottom, rgba(196,38,140,1) 0%,rgba(154,11,114,1) 5%,rgba(0,0,0,1) 10%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c4268c', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
}
Now, you can use linear gradients with the border-image attribute in all modern browsers.
.bordertest {
color: pink;
border: 10px solid pink;
border-image: repeating-linear-gradient( 45deg, pink, pink 1%, purple 1%, purple 8%) 10;
}
See: https://css-tricks.com/almanac/properties/b/border-image/
hi there i am using the following code to create a gradient background in firefox... but the problem is that the gradient fills the page alright but it repeats...
<body style="background-image:linear-gradient(#eee,#ddd); background-image: -moz-linear-gradient(top, #2F2727, #1a82f7);">
and below is the result of the above code
i want the gradient to stretch and fill the whole page... how can i do this.... any help would be appreciated thanks in advance... :)
Put this in a css file for a crossbrowser gradient:
body {
background: #2f2727; /* Old browsers */
background: -moz-linear-gradient(top, #2f2727 0%, #1a82f7 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2f2727), color-stop(100%,#1a82f7)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #2f2727 0%,#1a82f7 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #2f2727 0%,#1a82f7 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #2f2727 0%,#1a82f7 100%); /* IE10+ */
background: linear-gradient(to bottom, #2f2727 0%,#1a82f7 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2f2727', endColorstr='#1a82f7',GradientType=0 ); /* IE6-9 */
}
Gradient generator.
The easiest way would be to simply add background to HTML element and set its height to 100%:
html {
/* and dont forget the prefixes ;) */
background: linear-gradient(to bottom, #2f2727 0%,#1a82f7 100%) no-repeat;
height: 100%;
}
http://jsfiddle.net/Caja9/
i tried the below code and it worked
background-image:-moz-linear-gradient(#eee,#ddd); height:100%;
I know that this can easily be done in any image editing program, I was just curious if there was a way just using css.
Example:
body {background-color: #837960; background-image: url("Images/background.jpg") background-repeat: no-repeat;}
Could you use css to fade the background image into the background color so a visible line does not exist or should I keep adding a gradient to transparency in Photoshop?
It is possible - in CSS3 you can set multiple values for background
body {
background: #837960 url("https://i.stack.imgur.com/MUsp6.jpg") 0 0 no-repeat;
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(130,91,0,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0)), color-stop(100%,rgba(130,91,0,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(130,91,0,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(130,91,0,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(130,91,0,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(130,91,0,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#825b00',GradientType=0 ); /* IE6-9 */
}
However, it will work only in modern browser that supports CSS3
(code generated via http://www.colorzilla.com/gradient-editor/)
Yes it's possible with CSS using the linear-gradient() function with multiple background images:
body {
background-color: #837960;
background-image: linear-gradient(
to bottom, transparent, #837960
), url("Images/background.jpg");
background-repeat: no-repeat;
}
Specify the gradient as the first image so it gets stacked on top, and use it to fade from transparent at the top to the opaque background-color at the bottom. This will give the illusion the image underneath is fading into the background without requiring alpha-transparency on the image itself.
Ideally, you should just edit the image so as to have a consistent look across browsers.
While you can have a background gradient, that would appear behind an image, as the background images are placed over background color. In order to have the image look like it is fading into another color, you would need to place another tag on top of that the body such as:
body { background: url('https://i.stack.imgur.com/MUsp6.jpg') }
div.content {
width: 100%;
height: 100%;
background: -moz-linear-gradient(top, rgba(255,255,255,0) 0%, rgba(255,255,255,1) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(255,255,255,0)), color-stop(100%,rgba(255,255,255,1))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* IE10+ */
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%,rgba(255,255,255,1) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00ffffff', endColorstr='#ffffff',GradientType=0 ); /* IE6-9 */
}
<body>
<div class="content">Example</div>
</body>
Or whatever color/positioning combination you would like. A good resource is http://www.colorzilla.com/gradient-editor/
I tried using the "ultimate CSS gradient generator" and it produced the following:
background: #657575; /* Old browsers */
background: -moz-linear-gradient(left, #657575 0%, #758585 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,#657575), color-stop(100%,#758585)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, #657575 0%,#758585 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, #657575 0%,#758585 100%); /* Opera11.10+ */
background: -ms-linear-gradient(left, #657575 0%,#758585 100%); /* IE10+ */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#657575', endColorstr='#758585',GradientType=1 ); /* IE6-9 */
background: linear-gradient(left, #657575 0%,#758585 100%); /* W3C */
But is seems that the gradient does not work at least with my version of IE9. So is there any way I can produce a simple horizontal gradient with IE9?
Does IE9 support CSS linear gradients?
background:#fff;
background-image: -moz-linear-gradient(top, #fff, #000);
background-image: -webkit-gradient(linear,left bottom,left top,color-stop(0, #fff),color-stop(1, #000));
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr='#ffffff', endColorstr='#000000');/*For IE7-8-9*/
height: 1%;/*For IE7*/
Here is a site that might help you regarding CSS gradients:
http://www.htmlcenter.com/blog/cross-browser-gradient-backgrounds/
In my option, for fixed height elements I usually use a 1px image and repeat that image across the width of the element. That way you know it will look the same in all browsers.
Example:
.element{
height: 30px;
background: url(<1px image location>) repeat-x;
}
There are also websites that will create these gradient images for you. Here is one that is free to use:
http://www.ogim.4u2ges.com/gradient-image-maker.asp