Background color gradient in Ionic 2 - css

I'm trying to set the background-color for my app using $background-color variable in variables.scss file. This works fine when setting just a color, like #000 or #fff, but can't make it work with a gradient.
$background-color: linear-gradient(to bottom, #000 0%, #fff 100%);
This code throws the following Sass error:
argument '$color' of 'rgba($color, $alpha)' must be a color Backtrace.
So, how can I set the background-color to be a gradient?

This is the scss code I use for my own background gradient.
$SIDEMENU_TOP: #A23C4B;
$SIDEMENU_BOTTOM: #ff9068;
$SIDEMENU_TRANSPARENCY: rgba(255,255,255,0.4);
.side-menu-gradient{
background: -webkit-gradient(left top, $SIDEMENU_TOP, $SIDEMENU_BOTTOM);
background: -o-linear-gradient(bottom right, $SIDEMENU_TOP, $SIDEMENU_BOTTOM);
background: -moz-linear-gradient(bottom right, $SIDEMENU_TOP, $SIDEMENU_BOTTOM);
background: linear-gradient(to bottom right, $SIDEMENU_TOP, $SIDEMENU_BOTTOM);
}
(Maybe highly inspired from Ionic Creator - Creating beautiful Sidemenus (YouTube)

If you want to set the background colour of a page, for example home.html page, to a gradient, you should follow these two steps:
In home.html you should have a class called home in the ion-content tag:
<ion-content padding class="home">
...
</ion-content>
Go to home.scss file (create one if you do not have it) and define the home class:
.home {
background: linear-gradient(to bottom, #000 0%, #fff 100%);
}
Make sure this sass is being compiled by importing it into app.css file:
#import "../pages/home/home";
Insert this line of code in your app.css file.
Do ionic run android in your Terminal and ... you'll have a gradient background for your home page!
Done!

$background-color variable won't work instead use $app-background
Example:
$app-background: linear-gradient(to bottom, #000 0%, #fff 100%);

Related

React glamor doesn't solve prefixes in a correct way

I'm new to React and I've recently started to use glamor instead of the various css pre-proccesors that are available. Anyway, I noticed that glamor (which should solve all prefixes) does not solve prefixes in the right way. For example:
background: linear-gradient(to bottom, #000 0%, #fff 100%);
When glamor tries to add the prefixes, it adds
background: -webkit-linear-gradient(to bottom, #000 0%, #fff 100%);
Which is wrong, it should skip/replace "to bottom" with "top". The same thing goes with -moz- prefixes. My question is: why does it do this? Just curious.

Getting current Quill Editor's toolbar background color

I'm implementing a primeNg/quill editor, and as part of the UX design I need to display a container in the screen with the same color background as the editor's toolbar. I'm looking at the snow.css file but can't seem to find it, any quill experts know where I can find this on snow.css or any other dependent css of Quill? Thank you!
The toolbar background color in the PrimeNG Quill demo is part of the PrimeNG theme and not part of Quill's snow.css.
You can use the developer toolbar in Firefox and Chrome to see the CSS rules:
.ui-widget-header {
border: 1px solid #d9d9d9;
color: #1b1d1f;
background: #f6f7f9 0 0 repeat-x;
background: -moz-linear-gradient(top, #f6f7f9 0%, #ebedf0 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f6f7f9), color-stop(100%,#ebedf0));
background: -webkit-linear-gradient(top, #f6f7f9 0%,#ebedf0 100%);
background: -o-linear-gradient(top, #f6f7f9 0%,#ebedf0 100%);
background: -ms-linear-gradient(top, #f6f7f9 0%,#ebedf0 100%);
background: linear-gradient(top, #f6f7f9 0%,#ebedf0 100%);
}
Just put inside a div with background color, and for editing area color use
Style backround color property.
below code for bootstrap and angular
<div class="bg-light">
<quill-editor [styles]="{height: '500px', backgroundColor: 'white'}">
</quill-editor>
</div>

Invalid property value for multiple backgrounds with image and linear-gradient

I'm trying to set up a select element with multiple backgrounds (one image, and one linear-gradient). It worked while I was developing, but for some reason it stopped working when it was pushed to production.
Here's the code I started with (in SCSS):
$select-arrow-uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAICAYAAAAvOAWIAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0Nzox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ML2dkAAAAASUVORK5CYII=';
select{
background-color: #f5f5f5;
background-image: url("#{$select-arrow-uri}");
background-image: url("#{$select-arrow-uri}"), -webkit-linear-gradient(bottom, #e5e5e5 0%, #f5f5f5 100%);
background-image: url("#{$select-arrow-uri}"), linear-gradient(#e5e5e5 0%, #f5f5f5 100%);
background-position: 95% center;
background-repeat: no-repeat;
}
and this is how it is appearing in the browser:
background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAICAYAAAAvOAWIAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyNpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDIxIDc5LjE1NDkxMSwgMjAxMy8xMC8yOS0xMTo0NzoxNiAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChNYWNpbnRvc2gpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOkExMjY4NTZGRTdCNTExRTNCOEJDRDIyQTAwRDQ5MzU2IiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOkExMjY4NTcwRTdCNTExRTNCOEJDRDIyQTAwRDQ5MzU2Ij4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6QTEyNjg1NkRFN0I1MTFFM0I4QkNEMjJBMDBENDkzNTYiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6QTEyNjg1NkVFN0I1MTFFM0I4QkNEMjJBMDBENDkzNTYiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4L3nSlAAAAm0lEQVR42mL4//8/AwinpKQowtjIGCguB2MzMQBBampqF5A6D6TNGJAAkG8DpK4C6UYQnxGo0xhInwRiZiD+CMRus2fPPgVVuB2IeYD4FxAbMoKMB0rEAjnzkTRUAnEXksJooAFrwIqhViYAqTlQDTAAVwh2Bkwxkob5UO5fII6AKQQBJmQPASUWAKlEqMJoZIVgQCi4kDFAgAEAFOFxgtML2dkAAAAASUVORK5CYII=) 95% center no-repeat,
linear,to bottom,#e5e5e5,#f5f5f5;
When I remove the background-image rule with linear-gradient, it works fine. It doesn't have any problems with the -webkit-linear-gradient line, just the linear-gradient line.
Is there a syntax issue? Could Sass be compiling weird? Is it trouble with the URI string?
Please help! Thanks!
Figured it out. I have the Bourbon library loaded, and there is a function for linear-gradient that is made to work with the background-image mixin, and that was being used without using the background-image mixin. I switched to the background-image mixin to get it to work, but I'll probably report this to them. Not cool Bourbon.

background image not showing css and is automatically set to none

i have a div with a background image <div id='mcts1'></div>
now when i view it in chrome, the image does not show, and when press F12 [inspect element], this is what i see:
<div id="mcts1" style="background-image: none;">......
</div>
now i'm wondering how did it happened that the background-image property was set to none when i actually declared it in the css.
here is the css file together with the code snippet where i echoed the <div id="mcts1">fiddler file here:
link
Try changing your CSS starting on line 311 to this:
.navigator{
background: #efefef url(../images/nav.png);
background: linear-gradient(top, #efefef 0%, #bbbbbb 100%) url(../images/nav.png);
background: -moz-linear-gradient(top, #efefef 0%, #bbbbbb 100%) url(../images/nav.png);
background: -webkit-linear-gradient(top, #efefef 0%,#bbbbbb 100%) url(../images/nav.png);
}
I think this might be coming somewhere from js or jquery..

How do I overlay a gradient background over an existing background with CSS?

I am trying to overlay a white-black linear gradient to an existing image. I have it set up like below; however, only the gradient layer is showing. Can someone point out where I went wrong?
JS Fiddle: http://jsfiddle.net/6nJJD/
HTML
<div>hello</div>
CSS
div {
background:linear-gradient(to bottom, #ffffff 0%, #000000 100%), url("http://us.123rf.com/400wm/400/400/adroach/adroach1210/adroach121000001/15602757-flower-and-bird-ornaments-retro-tile-repeat-as-many-times-as-you-like.jpg") repeat #eae7de;
color:#544a46;
font:62.5%/1.6 Helvetica, Arial, Sans-serif;
height:500px;
width:500px
}
try to change your gradient colours using RGBA values
background:
linear-gradient(to bottom, rgba(255,255,255, 0) 0%, rgba(0,0,0, 1) 100%),
url(...);
Example fiddle: http://jsfiddle.net/J7bUd/
Try also changing rgba(255,255,255, 0) with transparent: the result is slightly different but probably it's exactly what you're trying to achieve
You can accomplish this using RGBA in the gradient.
http://jsfiddle.net/6nJJD/3/
CSS:
linear-gradient(to bottom, rgba(0,0,0,0.65) 0%,rgba(0,0,0,0) 100%)
You can modify the "0.65" value to attain the desired transparancy.
For Creating More Gradients as you like you can visit Ultimate Css
Gradient Generator
Hope This HElps
like this?
http://jsfiddle.net/6nJJD/2/
linear-gradient(to bottom, rgba(255,255,255,0.9) 0%, #000000 100%)

Resources