I am using Vue (not that it matters as this is a CSS issue I'm sure).
I have 3 flip boxes, taken mostly from the w3schools instructions at https://www.w3schools.com/howto/howto_css_flip_box.asp and all works as expected on a Desktop screen.
However, on my phone the image doesn't fit the whole box, leaving a space at the bottom. I have added background-repeat: no-repeat; as otherwise the image starts to repeat to fill in the space
Edit: Adding the html as requested ion the comments:
<template>
<div class="flip-box">
<div class="flip-box-inner">
<div class="flip-box-front">
<h2>{{ frontText }}</h2>
</div>
<div class="flip-box-back">
<div class="opaque-box">
<p class="mt-3 ms-2">{{ backText }}</p>
<span v-html="url"></span>
</div>
</div>
</div>
</div>
</template>
Is there anything obvious from the css below?
Thanks
<style scoped>
body {
font-family: Arial, Helvetica, sans-serif;
}
.flip-box {
width: 300px;
height: 200px; /* 200 best for desktop but not mobile */
border: 1px solid #f1f1f1;
perspective: 1000px;
}
.flip-box-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.8s;
transform-style: preserve-3d;
}
.flip-box:hover .flip-box-inner {
transform: rotateX(180deg);
object-fit: fill;
}
.flip-box-front, .flip-box-back {
background-image: v-bind(backgroundImage);
position: absolute;
width: 100%;
height: 100%;
color: white;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
}
.flip-box-front {
background-size: 100%;
background-repeat: no-repeat;
}
.flip-box-back {
background-size: 100%;
background-repeat: no-repeat;
font-weight: 600;
transform: rotateX(180deg);
}
.opaque-box{
position: absolute;
background-image: v-bind(backgroundImage);
background-size: 100%;
background: rgba(0, 0, 0, 0.50);
height: 100%;
}
</style>
Having spent quite some time wrestling with this before posting I have now fixed it by adding background-size: cover;
So the CSS now looks like this:
<style scoped>
...
.flip-box-front {
background-size: 100%;
background-repeat: no-repeat;
background-size: cover; /* Added this */
}
.flip-box-back {
background-size: 100%;
background-repeat: no-repeat;
font-weight: 600;
transform: rotateX(180deg);
background-size: cover; /* Added this */
}
...
</style>
Related
So I really like this kind of special effect here https://www.w3schools.com/howto/howto_css_blurred_background.asp where you can blur out a background and have the text show up. The problem that I am currently having right now is that I want to add in another wallpaper for my second content below my first content. The first content is good. Now I want my second content to be in the second wallpaper as you scroll. Kind of like creating a parallax effect, but instead I am am creating my own unique website.
This time I want a blurring background (wallpaper number two) while having the stuff where I already want it placed and have it focus.
Is there a way to achieve that?
Starting where the bg-image2, I want the h1, and the p, inside bg-image2 to focus over the blurring background image.
NOTE: The wallpaper will not show in the snippet below because I already got the pictures I need in my folder which is located in my computer.
body,
html {
height: 100%;
}
* {
box-sizing: border-box;
}
.bg-image {
/* The image used */
background-image: url("images/wallpaper1.jpg");
/* Add the blur effect */
filter: blur(8px);
-webkit-filter: blur(8px);
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* Position text in the middle of the page/image */
.bg-text {
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/opacity/see-through */
color: white;
font-weight: bold;
border: 3px solid #f1f1f1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
width: 80%;
padding: 20px;
text-align: center;
}
.bg-image2 {
/* The image used */
background-image: url("images/wallpaper2.jpg");
/* Add the blur effect */
filter: blur(8px);
-webkit-filter: blur(8px);
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.profilePicture {
position: absolute;
left: 50%;
margin: 200px auto;
transform: translate(-50%, -50%);
}
<div class="bg-image"></div>
<div class="bg-text">
<h1>My name is Stackoverflow</h1>
<p>And I am a website</p>
</div>
<div class="bg-image2">
<!-- This is the part where I want my stuff to not be blurred and focus -->
<div class="profilePicture">
<img src="images/profilePic.jpg" style="width: 170px; height: 170px; border-radius:50%;">
<h1>This is a title</h1>
<p>This is just a paragraph</p>
</div>
</div>
Is that the result you are looking for?
https://codepen.io/anon/pen/exVRyy
All i did was to create a div around the bg-image2 and profilePicture, so that the blur on bg-image2 doesn't affect profilePicture, then set that div to position:relative; , so that the profilePicture can be placed in the middle like you did.
Here is your HTML edited:
<div class="bg-image"></div>
<div class="bg-text">
<h1>My name is Stackoverflow</h1>
<p>And I am a website</p>
</div>
<div class="bg-test">
<div class="bg-image2">
<!-- This is the part where I want my stuff to not be blurred and focus -->
</div>
<div class="profilePicture">
<img src="https://images.pexels.com/photos/1253661/pexels-photo-1253661.jpeg?cs=srgb&dl=android-wallpaper-bluhen-blume-1253661.jpg&fm=jpg" style="width: 170px; height: 170px; border-radius:50%;">
<h1>This is a title</h1>
<p>This is just a paragraph</p>
</div>
</div>
And the CSS:
body,
html {
height: 100%;
}
* {
box-sizing: border-box;
}
.bg-image {
/* The image used */
background-image: url("https://images.unsplash.com/photo-1507608616759-54f48f0af0ee?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80");
/* Add the blur effect */
filter: blur(8px);
-webkit-filter: blur(8px);
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* Position text in the middle of the page/image */
.bg-test {
position:relative;
}
.bg-text {
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/opacity/see-through */
color: white;
font-weight: bold;
border: 3px solid #f1f1f1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
width: 80%;
padding: 20px;
text-align: center;
}
.bg-image2 {
/* The image used */
background-image: url("https://whatthenewsblog.files.wordpress.com/2015/03/ecl-ann.jpg");
/* Add the blur effect */
filter: blur(8px);
-webkit-filter: blur(8px);
/* Full height */
height: 100vh;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.profilePicture {
position: absolute;
left: 50%;
top:50%;
margin: 0 auto;
transform: translate(-50%, -50%);
}
I was facing a similar issue. After a lot of searches, I found the perfect solution.
You can use backdrop-filter.
Your code:
body,
html {
height: 100%;
}
* {
padding: 0px;
margin: 0px;
box-sizing: border-box;
}
.bg-image {
/* The image used */
background-image: url("https://images.unsplash.com/photo-1507608616759-54f48f0af0ee?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80");
/* Add the blur effect */
/* Full height */
height: 100%;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* Position text in the middle of the page/image */
.bg-test {
position:relative;
}
.bg-text {
background-color: rgb(0, 0, 0);
/* Fallback color */
background-color: rgba(0, 0, 0, 0.4);
/* Black w/opacity/see-through */
color: white;
font-weight: bold;
backdrop-filter: blur(8px);
border: 3px solid #f1f1f1;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 2;
width: 80%;
padding: 20px;
text-align: center;
}
.bg-image2 {
/* The image used */
background-image: url("https://blog.prezi.com/wp-content/uploads/2019/03/patrick-tomasso-208114-unsplash-1024x768.jpg");
/* Add the blur effect */
/* Full height */
height: 100vh;
/* Center and scale the image nicely */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.profilePicture {
backdrop-filter: blur(8px);
height: 100vh;
width: 100vw;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
position: absolute;
left: 50%;
color: white;
top:50%;
margin: 0 auto;
transform: translate(-50%, -50%);
}
<div class="bg-image">
<div class="bg-text">
<h1>My name is Stackoverflow</h1>
<p>And I am a website</p>
</div>
</div>
<div class="bg-test">
<div class="bg-image2">
<!-- This is the part where I want my stuff to not be blurred and focus -->
<div class="profilePicture">
<img src="https://images.pexels.com/photos/1253661/pexels-photo-1253661.jpeg?cs=srgb&dl=android-wallpaper-bluhen-blume-1253661.jpg&fm=jpg" style="width: 170px; height: 170px; border-radius:50%;">
<h1>This is a title</h1>
<p>This is just a paragraph</p>
</div>
</div>
</div>
I know its been so long since you asked and you got the answers.
Hope this will be helpful for someone else :)
I modified code from cryptomothy
I'm currently trying to figure out a way to make it so that upon hovering over each separate box on the front page of my website (http://thefloodplains.com/), a shadow animation occurs for that specific box. I want it to look very similar to what can be found at this page: http://tobiasahlin.com/blog/how-to-animate-box-shadow/. I've used this page as a guide in an attempt to set up a hover shadow effect.
Here's the CSS/HTML specifically for the div boxes on my web page (http://thefloodplains.com/):
.col-md-4 {
color:#00A5D1;
height:300px;
}
.col-md-3 {
color:#00A5D1;
height:300px;
box-shadow: 2 2px 3px rgba(0, 0, 0.1, 0.1);
-webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.col-md-4:hover {
background-color: #FFE097;
}
.col-md-3:hover {
-webkit-transform: scale(1.25, 1.25);
transform: scale(1.25, 1.25);
}
.col-md-4 h3 {
position: relative;
top: 40%;
transform: translateY(-50%);
}
.col-md-4 {
color:#00A5D1;
height:300px;
border: 1px solid #FF8B6F;
position: relative;
}
.col-md-3 {
height:300px;
position: relative;
}
.col-md-4:after {
content: '';
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: block;
background: #FFE097;
opacity: 0;
}
.col-md-3:after {
content: "";
position: absolute;
z-index: -1;
top: 0;
right: 0;
left: 0;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
opacity: 0;
-webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.col-md-4:hover:after {
opacity: .5;
}
.col-md-3:hover:after {
opacity: 1;
}
.col-md-4 h3 {
position: relative;
z-index: 1;
top: 40%;
transform: translateY(-50%);
}
Anything with the class ".col-md-3" is where I have attempted to add in the hover-shadow effects (in much the same way that I already have the current hover-color effects set up). The following code is the rest of the CSS/HTML of my front page:
<style>
h3 {
font-size:36px;
font-style: bold;
text-align:center;
font-family:'Buernard', Garamond, "Buenard", "EB Garamond",'EB Garamond';
}
img {
max-width: 100%;
max-height: 100%;
}
#div1 {
background-image: url('AboutIcon.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div2 {
background-image: url('ArticlesIcon.png');
background-position: center center; //center the image in the div
background-size: contain; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div3 {
background-image: url('CodingBrackets2.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div4 {
background-image: url('ContactIcon.png');
background-position: center center; //center the image in the div
background-size: contain; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div5 {
background-image: url('FSMusicArt.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div6 {
background-image: url('AudioProduction4.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div7 {
background-image: url('Violin3.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div8 {
background-image: url('GalleryImage2.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div9 {
background-image: url('Handshake2.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
div {
background-image:url(../images/please-dont-use-spaces.jpg); //add the background image
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<a href="About.html" title="About the site and Author"><div class="col-md-4" id='div1'>
<h3>About</h3>
</div></a>
<a href="Articles.html" title="Original Articles and Content"><div class="col-md-4" id='div2'>
<h3>Articles</h3>
</div>
<a href="CodingCorner.html" title="Coding Corner - Code for a Variety of Projects"><div class="col-md-4" id="div3">
<h3>Coding Corner</h3>
</div></a>
</div>
<div class="row">
<a href="Contact-Social.html" title="Contact The Floodplains & The FloodShark"><div class="col-md-4" id="div4">
<h3>Contact & Social</h3>
</div></a>
<a href="TheFloodSharkMain.html" title="The FloodShark Music and Media"><div class="col-md-4" id="div5">
<h3>
The FloodShark
Music
</h3>
</div></a>
<a href="FloodplainProductions.html" title="Floodplain Productions - virtual record label"><div class="col-md-4" id="div6">
<h3>Floodplain Productions</h3>
</div></a>
</div>
<div class="row">
<a href="ClassicalCorner.html" title="Classical Corner - A nook dedicated to sharing and categorizing classical music"><div class="col-md-4" id="div7">
<h3>Classical Corner</h3>
</div></a>
<a href="Gallery.html" title="Images, Photographs, and Album Art"><div class="col-md-4" id="div8">
<h3>Gallery</h3>
</div></a>
<a href="Contribute-Support.html" title="Contribute to The Floodplains!"><div class="col-md-4" id="div9">
<h3>Contribute / Support</h3>
</div></a>
</div>
</div>
</body>
I tried adding "col-md-3" to the div's as a second class in the above code along with "col-md-4," which controls the color hover effect. The problem is, I don't think this method works, but I'm not really sure what does. As of right now, I'm using the "col-md-4" color hover effect - which is working - but getting a shadow effect to work simultaneously is something I have yet to figure out.
So currently - upon hovering - the boxes turn to that transparent shade of orange/yellow. Is there a way that I can get the shadow animation AND the color-change hovers to work together at the same time? So basically I just need a hover animation added to what is already here at http://thefloodplains.com/.
Thank you in advance for your time.
Create a new class for the effect i.e. hovernow add the following code:
body {
background-color: white;
}
.hovernow {
background-color: red;
width: 100px;
height: 100px;
margin: 10px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
transition: box-shadow 0.3s ease-in-out;
}
.hovernow:hover {
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.8);
}
<div class="hovernow">
</div>
Then add this class .hovernow to the div's which you like the hover effect to apply to.
Are you looking for this, Fiddle
I have added the style for .col-md-4. Please check the code...
I'm trying to create overlay effect for a services section. I've managed to get it to cover going from right to left and need to create a few different ones, but can't get it to go from top to bottom or from bottom to the top. Here is an example of the code.
.window-display {
min-height: 500px;
background-image: url('http://loremflickr.com/320/240');
background-size: cover;
background-position: center center;
}
.window-display .heading {
padding-left: 15px;
}
.window-display .overlay {
background-color:rgba(38,37,98,0.8);
min-height: 500px;
width: 40%;
float: right;
overflow: hidden;
-webkit-transition-duration: 2s; /* Safari */
transition-duration: 2s;
}
.window-display:hover .overlay {
width: 100%;
}
<div class="window-display">
<div class="overlay">
<div class="heading">
<h2 style="color: #fff;">SECTION TITLE</h2>
</div>
</div>
</div>
You can use position: absolute on the overlay to achieve the bottom to top and vice versa effect your after.
JSFiddle from bottom to top
JSFiddle from top to bottom
Here's the working code that you can tinker with:
<div class="window-display">
<div class="overlay">
<div class="heading">
<h2>SECTION TITLE</h2>
</div>
</div>
</div>
.window-display {
height: 500px;
background-image: url('http://loremflickr.com/320/240');
background-size: cover;
background-position: center center;
position: relative;
}
.window-display .heading {
padding-left: 15px;
}
.window-display .heading h2 {
color: #fff;
}
.window-display .overlay {
background-color:rgba(38,37,98,0.8);
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height:50px;
-webkit-transition-duration: 2s; /* Safari */
transition-duration: 2s;
}
.window-display:hover .overlay {
height: 100%;
}
I've been learning about the :after selector, and I wanted to create a nice looking gallery.
I've made the thumbnail I want for the gallery. Currently my thumbnail only works with an :after selector.
However instead of making each individual thumbnail its own class, I want to be able to set the background image in the HTML file.
I want to know what the best way to accomplish this.
body{
font-family: Arial, sans-serif;
}
a, a:hover, a:focus{
text-decoration: none;
color: #fff;
}
.thumbnailouterwrap{
width: 250px;
height: 250px;
}
.imgthumbnail{
text-align: center;
width: 100%;
height: 100%;
background-color: transparent;
color: #ffffff;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
overflow: hidden;
opacity: 1;
position: relative;
}
.imgthumbnail:after{
content:'';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url("http://doc.jsfiddle.net/_downloads/jsfiddle-logo.png");
background-size: cover;
background-position: center;
transition: 500ms all ease-in-out;
}
.thumbnailinnerwrap{
width: 100%;
height: 100%;
overflow: hidden;
background-color: #1d1d1d;
}
.thumbtext{
opacity: 0;
transition: 500ms all ease-in-out;
transform: scale(1, 1);
z-index: 1;
}
.imgthumbnail hr{
width: 0%;
border-top: solid 1px #fff;
transition: 800ms all ease-in-out;
}
.imgthumbnail:hover .thumbtext, .thumbtext:hover{
opacity: 1;
}
.imgthumbnail:hover hr, hr:hover{
width: 100%;
}
.imgthumbnail:hover:after{
transform: scale(1.2, 1.2);
opacity: 0.7;
filter: blur(2px);
}
<body>
<div class="thumbnailouterwrap">
<a href="http://jsfiddle.net" class="anchorthumb">
<div class="thumbnailinnerwrap">
<div class="imgthumbnail">
<div class="thumbtext">
<h3>Title</h3>
<hr/>
<p>Description</p>
</div>
</div>
</div>
</a>
</div>
</body>
JsFiddle
Sorry if this isn't clear, or if this post is bad (it's my first)
If I understand correctly, you want to style a parent element with the image of the child.
What you can do is setting the background-image of .parentSelector, but put a background-size of 0.
Then you inherit this background-image in .childSelector, and put a larger background-size.
div {
outline: 1px solid black;
}
.parentSelector {
background-image: linear-gradient(green, gold);
background-size: 0 0;
display: block;
overflow: hidden;
height: 50vh; width: 50vh;
}
.childSelector {
display: inline-block;
background-image: inherit;
background-size: cover;
}
<div class='parentSelector'>
parentSelector
<div class='childSelector'>
childSelector
</div>
</div>
It's not recommended to set the background-image in the html file.
If you want to use :after selector, you can use data- attribute but that is not implemented anywhere yet. (Using HTML data-attribute to set CSS background-image url)
.imgthumbnail:after{
content:'';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: attr(data-image-src url);
background-size: cover;
background-position: center;
transition: 500ms all ease-in-out;
}
...
<div class="imgthumbnail" data-image-src="http://doc.jsfiddle.net/_downloads/jsfiddle-logo.png">
<div class="thumbtext">
<h3>Title</h3>
<hr/>
<p>Description</p>
</div>
</div>
...
You can set the background image to each element using :nth-child selector. You can add the style tag to the html file but it's not in the html content.
Example:
.imgthumbnail:first-child:after {
background-image:url(first_image_url);
}
.imgthumbnail:nth-child(2):after {
background-image:url(second_image_url);
}
... and so on.
http://www.w3schools.com/cssref/sel_nth-child.asp
I created a responsive page which has a box with text and blurred background. The page is available here on JSFiddle.
The problem is: .content element is not visible without setting its opacity to 0.99. Why?
HTML
<div class="content-box">
<div class="content-bg"></div>
<div class="content">
<p>Text with blurred background</p>
<p>Text with blurred background</p>
</div>
</div>
CSS
body {
background-image: url('http://hazor.iki.fi/2003/juhannus/isot/DSCN9068-Maisema.jpg');
background-color: black;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
background-size: cover;
background-size: no-repeat fixed center center cover;
overflow: hidden;
}
.content-box {
position: relative;
width: 300px;
overflow: hidden;
}
.content-bg {
position: absolute;
background-size: cover;
background-image: url('http://hazor.iki.fi/2003/juhannus/isot/DSCN9068-Maisema.jpg');
background-color: black;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
background-size: cover;
background-size: no-repeat fixed center center cover;
filter: blur(5px);
-webkit-filter: blur(5px);
}
.content {
border-radius: 10px;
z-index: 100;
background-color: rgba(0, 0, 0, 0.7);
opacity: 0.99999; /* Does not work without this wtf */
color: white;
}
.content :first-child { margin-top: 0px }
JS
function updateBackground() {
var contentBox = $(".content-box");
var bg = $(".content-bg");
bg.css("left", -(contentBox.offset().left));
bg.css("top", -(contentBox.offset().top));
bg.width($(window).width());
bg.height($(window).height());
}
$(window).resize(function() {
updateBackground();
});
updateBackground();
Why does the code not work without opacity?
This is because your content element seems to be behind the content-bg element. The z-index has no effect because there is no position property assigned to it.
Why does it work when opacity of 0.99 is added?
As mentioned by BoltClock in this answer, adding a opacity less than 1 automatically creates a new stacking context (similar to adding z-index to a positioned element). This brings content element forward and thus it gets displayed.
What is the ideal solution?
Adding position: relative would make the z-index work as expected (which is bring the element above content-bg) and that would solve the issue.
function updateBackground() {
var contentBox = $(".content-box");
var bg = $(".content-bg");
bg.css("left", -(contentBox.offset().left));
bg.css("top", -(contentBox.offset().top));
bg.width($(window).width());
bg.height($(window).height());
}
$(window).resize(function() {
updateBackground();
});
updateBackground();
body {
background-image: url('http://hazor.iki.fi/2003/juhannus/isot/DSCN9068-Maisema.jpg');
background-color: black;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
background-size: cover;
background-size: no-repeat fixed center center cover;
overflow: hidden;
}
.content-box {
position: relative;
width: 300px;
overflow: hidden;
}
.content-bg {
position: absolute;
background-size: cover;
background-image: url('http://hazor.iki.fi/2003/juhannus/isot/DSCN9068-Maisema.jpg');
background-color: black;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
background-size: cover;
background-size: no-repeat fixed center center cover;
filter: blur(5px);
-webkit-filter: blur(5px);
}
.content {
position: relative; /* add this */
border-radius: 10px;
z-index: 100;
background-color: rgba(0, 0, 0, 0.7);
color: white;
}
.content:first-child {
margin-top: 0px
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="content-box">
<div class="content-bg"></div>
<div class="content">
<p>Text with blurred background</p>
<p>Text with blurred background</p>
</div>
</div>