模糊背景图像,而不是文本

时间:2013-12-02 22:03:06

标签: javascript jquery html css css3

我在Unslider's plugin上使用my website,我想只模糊所有浏览器上的图像,而不是文本。

问题演示:

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

有人能指出我正确的方向吗? This post使用:before元素上的body标记。我在li上试过了,但是没有用。

相关链接我看过:

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

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

blur background image only

1 个答案:

答案 0 :(得分:1)

走阻力最小的路径:只需保存一个名为“...- blurred.jpg”(或png等)的模糊图像,只需使用element:hover { background-image: url('...-blurred.jpg'); }规则。

Presto,鼠标悬停在背景上现在模糊不清,文字不变。

(在缓存之后,模糊是即时的,而不是任何需要处理的替代方案,你可以提出。除非你为此编写自己的缓存,在这种情况下你真的需要想知道你为什么要重新创建所有轮子=)