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

标签 javascript jquery html css

我正在使用 Unslider's pluginmy 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 postbody 元素上使用了 :before 标签。我在 li 上试过了,但没有用。

我看过的相关链接:

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

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

blur background image only

最佳答案

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

Presto,鼠标悬停在背景上现在变得模糊,文本未被触及。

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

关于javascript - 模糊背景图像,而不是文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20338850/

相关文章:

html - Ionic 2/angular 2 - 如何将带有 Typescript 的 HTML 元素添加到我的组件中?

javascript - 我有办法在 slickgrid 标题中垂直对齐文本

javascript - 如何在 Vue.js 中将 prop 传递给父组件

javascript - 如何从 javascript 代码触发 drupal 规则

javascript - 使用 AJAX 和 JavaScript 发送选定的选项

javascript - Codewars的"Steps in Primes"

jquery - JSON.解析: unexpected end of data error

jquery - 使用 HTML 重新创建 iOS UITableView

javascript - 在嵌套循环中设置间隔

javascript - 创建和使用自定义 HTML 组件?