75579

CSS3 blur filter on HTML body tag

Question:

Is it possible to have a background image on the Bodytag, and then add blur filter on it, whitout getting the blur effect on the div's thats inside the body ?

Or do U need to add it on the first div inside the body as I can see many ex. on ?

Answer1:

Using CSS filters, all child elements of the element being blurred will also be blurred. However, rather than clutter your markup with an extra div just for the sake of a bg image with blur, you can use a pseudo element.

Don't forget to give it a z-index below the other content. In this case I just used -1, but you could use any number and give the other elements another number higher.

CSS

body:before { content: ''; z-index: -1; position: absolute; left: 0; right: 0; top: 0; bottom: 0; -webkit-filter: blur(10px); background: url(http://hackingui.com/wp-content/uploads/2014/05/meng2-1980x1000.jpg) no-repeat; background-size: cover; }

<a href="http://cdpn.io/wdGsz" rel="nofollow">Check it out on codepen</a>

Recommend

  • Why LINQ to Entities does not recognize the method 'System.String ToString()?
  • Compare adjacent list items
  • After first click, If ajax is done, on second click e.stopPropagation
  • How to set Camera View as background with views over it?
  • Partially blurring UIImage in objective C
  • How to create loading screen in android?
  • Frame of animated GIF only showing deltas
  • Does the Xml Schema spec define the serialization of optional attributes with a default?
  • Symfony 3 new project error
  • position: fixed with margin: auto in IE9/10
  • staticfiles and STATIC_URL with virrtualenv - django
  • Colorize knockoutjs comment bindings in code editor
  • MySQL Query Tuning - Why is using a value from a variable so much slower than using a literal?
  • cast stl::vector containing pointers to stl::vector containing constant pointers
  • Fast way to alphabetically sort the contents of a file in java
  • Is there an easy way to associate an event with a ListViewItem?
  • allocating memory to an array of string
  • For loop with if condition on multiple R functions
  • jQuery: add elements until a particular height is reached
  • Reduction and collapse clauses in OMP have some confusing points
  • Loading .coffee files via a view in Rails
  • C: Incompatible pointer type initializing
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • Linq Objects Group By & Sum
  • PHPUnit_Framework_TestCase class is not available. Fix… - Makegood , Eclipse
  • Projection media query: browser support and workarounds?
  • Optimizing database types to compact database (SQLite)
  • Why HTML5 Canvas with a larger size stretch a drawn line?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • When should I choose bucket sort over other sorting algorithms?
  • Weird JavaScript statement, what does it mean?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • R: gsub and capture
  • Unanticipated behavior
  • Traverse Array and Display in markup
  • Buffer size for converting unsigned long to string
  • Proper way to use connect-multiparty with express.js?
  • Django query for large number of relationships
  • reshape alternating columns in less time and using less memory
  • Conditional In-Line CSS for IE and Others?