I am trying to have a blurred background for my content.
So far I tried this:
.background-image {
background-image: url('../img/background/image.jpg');
width: 100vw;
height: 100vh;
-webkit-filter: blur(10px);
-moz-filter: blur(10px);
-o-filter: blur(10px);
-ms-filter: blur(10px);
filter: blur(10px);
}
and then
<ion-view class="background-image">
// header, content, footer etc
<ion-view>
But then I get the problem that the whole screen is blurred and not only the background as follows:
The backdrop-filter property in CSS is used to apply filter effects ( grayscale , contrast , blur , etc) to the background/backdrop of an element. The backdrop-filter has the same effect as the filter property, except the filter effects are applied only to the background and instead of to the element's content.
To achieve this in Ionic 1, you need to set the main div's class (that is displayed in the background of your popup) to use the blur css class .
Syntax. filter: blur(px); To apply a blur effect to the background image, with the blur function use the z-index property to set the stack order of the element, set the width and height 100% to have a full background image.
put content out side the blurred div.
.background-image {
background-image: url('../img/background/image.jpg');
width: 100vw;
height: 100vh;
-webkit-filter: blur(10px);
-moz-filter: blur(10px);
-o-filter: blur(10px);
-ms-filter: blur(10px);
filter: blur(10px);
}
<div class="background-image"></div>
<div>Content</div>
there is an other way come to my head which is add second background-image
,
which in css3 you can have multi background
for one element, and the second one can be a blur image, even with low quality , like this
in sass
#element
background:
image: url(/*first url*/), url(/*second url*/)
size: auto auto /*first one*/, 100% 100% /* second one*/
i guess second will cover first or revers , you can try it out
Put the image outside the other div... Like this:
<div class="background-image"></div>
<div class="content">
<p>Here goes your content</p>
</div>
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