css3 - Apply a CSS filter only on background -
in following snippet, have applied blur filter on .sub-menu
text filtered.
how can apply blur filter only on background , not text?
.sub-menu { list-style: none; position: relative; float: left; margin: 0px; padding-left: 0px; z-index: 1; } .sub-menu li { display: block; color: #888888; text-decoration: none; font-size: 14px; line-height: 32px; padding: 0 12px; } .sub-menu li a:hover { color: black; } .sub-menu { position: absolute; top: 100%; left: 0; -webkit-filter: blur(10px); /* chrome, opera */ -moz-filter: blur(10px); -ms-filter: blur(10px); filter: blur(10px); padding: 0 }
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" rel="stylesheet" /> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> <ul class="nav navbar-nav"> <li><a href="#">edit book</a> <ul class="sub-menu"> <li><a href="#">new</a> <li><a href="#">browse</a> <li><a href="#">approval</a> </ul> </li> </ul>
you can apply blur filter on pseudo element , stack behind .sub-menu
content :
.sub-menu { list-style: none; position: relative; float: left; margin: 0px; padding-left: 0px; z-index: 1; } .sub-menu li { display: block; color: #888888; text-decoration: none; font-size: 14px; line-height: 32px; padding: 0 12px; } .sub-menu li a:hover { color: black; } .sub-menu { position: absolute; top: 100%; left: 0; padding: 0 } .sub-menu:after { content: ''; position: absolute; left: 0; top: 0; width: 100%; height: 100%; z-index: -1; background:url('http://lorempixel.com/output/nature-q-c-640-480-6.jpg'); background-size:cover; -webkit-filter: blur(10px); /* chrome, opera */ -moz-filter: blur(10px); -ms-filter: blur(10px); filter: blur(10px); }
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css" rel="stylesheet" /> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" /> <ul class="nav navbar-nav"> <li><a href="#">edit book</a> <ul class="sub-menu"> <li><a href="#">new</a> <li><a href="#">browse</a> <li><a href="#">approval</a> </ul> </li> </ul>
Comments
Post a Comment