我想淡化焦点上的整个背景

I want to fade the whole background on focus

我想在聚焦搜索字段时淡化整个背景。我只需要css,如果有办法请告诉我我被困在这里2天了。

所以很多方法可以做到这一点:

1) Use jQuery to add this class when the search field has focus:

.fader {
    opacity: .5;
    -webkit-transition: opacity .25s ease-in-out;
       -moz-transition: opacity .25s ease-in-out;
            transition: opacity .25s ease-in-out;
}

2) Use jQuery to apply this method when the search field has focus:

$("body").fadeOut(2500); // the higher the number the longer it takes to fade

Note for IE 8 compatibility: Use opacity: 0.5; filter: alpha(opacity=50);