简体   繁体   中英

Blurring background image, not text

I am using Unslider's plugin on my website , and I want to blur only the image on all browsers and, but not the text.

Demo of Issue:

http://www.pure-energy.org

CSS:

.imagecarousel {
    position: relative;
    overflow: auto;
    font-size: 18px;
    line-height: 24px;
    // text-shadow: 0 0 1px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.3);
}
.imagecarousel li {
    list-style: none;
}
.imagecarousel ul{
    padding: 0;
}
.imagecarousel h1{
    color: black;
    font-size: 40px;
    line-height: 52px;
    margin-bottom: -10px;
    font-family: 'Bree Serif';
}
.imagecarousel p{
    font-family: 'Droid Sans';
    font-size: 25px;
    color: white;
}
.caption{
    position: absolute;
    top: 0px;
    padding-left: 30px;
}
.imagecarousel ul li {
    float: left;
    box-shadow: 0 -3px 6px rgba(0, 0, 0, 0.1) inset;
    display: block;
    background-position: cover;
    min-height: 800px;
    opacity: 0.5;
    z-index: -1;
}
.imagecarousel ul li:nth-child(1){
    background: url("/assets/geothermal-075276b7c15388514315dcd1af293b2f.png") no-repeat center center;
}
.imagecarousel ul li:nth-child(2){
    background: url("/assets/solar-46b6cfecb2169a3d14552f90196a56fb.jpg") no-repeat center center;
}
.imagecarousel ul li:nth-child(3){
    background: url("/assets/solar-588b14f01de3029cf161325a427415b5.jpg") no-repeat center center;
}
.imagecarousel ul li:nth-child(4){
    background: url("/assets/carouselwind-2b6e053bfbb20a5390c0f3df349444d0.jpg") no-repeat center center;
}
.imagecarousel ul li:nth-child(5){
    background: url("/assets/wind-adf42dcd750ba3b7a6508b99890b247b.jpg") no-repeat center center;
}
.imagecarousel ul li:nth-child(6){
    background: url("/assets/wind-ee6159e5689bd3475afc83cefc876069.jpg") no-repeat center center;
}
.imagecarousel ul li:nth-child(7){
    background: url("/assets/solarpanels-84a5f0e1c22b63f08f42c13cff323d08.jpg") no-repeat center center;
}
.imagecarousel ul li:nth-child(8){
    background: url("/assets/carouselhydro-4b48400ed37f87fd57390933a874ced5.jpg") no-repeat center center;
}
.imagecarousel ul li:before{
    filter: blur(5px);
    -webkit-filter: blur(5px);
    moz-filter: blur(5px);
    -o-filter: blur(5px);
    -ms-filter: blur(5px);
    // filter: url(#blur);
    // filter: blur(3px);
    // filter:progid:DXImageTransform.Microsoft.Blur(PixelRadius='3');
}

HAML:

.imagecarousel.has-dots
  %ul
    %li
      / %svg{version: "1.1", xmlns: "http://www.w3.org/2000/svg"}
      /   %filter#blur
      /     %fegaussianblur{stddeviation: "3"}
      .caption
        %p The future is in our hands.
    %li
      .caption
        %p Energy is awesome.
    %li
      .caption
        %p Clean. Safe. Efficient.
    %li
      .caption
        %p Caption 1
    %li
      .caption
        %p Caption 2
    %li
      .caption
        %p Caption 3
    %li
      .caption
        %p Caption 4
    %li

Can anyone point me in the right direction? This post used the :before tag on the body element. I tried that on li and it did not work.

Relevant Links I have looked at:

http://codepen.io/anon/pen/DzLBf

Can I apply CSS(3) filters ONLY on image sections?

blur background image only

Go the path of least resistance: just save a blurred image called "...-blurred.jpg" (or png, or etc) and simply use an element:hover { background-image: url('...-blurred.jpg'); } element:hover { background-image: url('...-blurred.jpg'); } rule.

Presto, on mouse over the background is now blurred and the text is untouched.

(and after it caches, the blur is instant, instead of whatever requires-processing alternative you can come up with. Unless you write your own caching for that, in which case you really need to wonder why you're reinventing all the wheels =)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM