**Creating a Blurry Effect with CSS Filters and Transitions**
Let's create an image gallery with a blurred effect that transitions smoothly when hovering over individual images.
To start, we'll set up our HTML structure. We'll create a container element called "depth" for our pyramid-shaped image gallery. Inside this container, we'll have multiple image elements. For now, let's keep it simple and use the following code:
```
```
Next, we'll add some CSS to style our image gallery. We'll use the `box-shadow` property to create a subtle border around each image. Let's say we want a box shadow with a radius of 0, 5 pixels, and an opacity of 0.3. We can also set the cursor pointer to make it interactive when hovering over the images.
```
.depth {
position: relative;
}
.depth img {
width: 100%;
height: 200px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.3), inset 0 0 0 rgba(255, 255, 255, 0.8);
cursor: pointer;
}
.depth img:hover {
cursor: pointer;
}
```
Now, let's add some CSS filters to create a blurred effect when hovering over individual images. We'll use the `filter` property and set it to `blur(4px)` for our blurred effect.
```
.depth img {
filter: blur(4px);
}
.depth img:hover {
transition: filter 0.3s linear;
}
```
To make the blur effect more dynamic, we can add a transition to the `filter` property when hovering over individual images. We'll set it to `0.3s` and use the `linear` timing function.
```
.depth img:hover {
transition: filter 0.3s linear;
}
```
Finally, let's add some CSS to make our image gallery interactive when hovering over individual images. We can use the `filter` property again to create a blurred effect when hovering over each image individually.
**Using the Blur Effect on Individual Images**
To apply the blur effect to individual images, we'll need to modify our HTML structure slightly. Instead of having multiple `img` elements inside the `.depth` container, we'll have separate `div` elements for each image.
```
```
We'll also need to add some JavaScript code to apply the blur effect when hovering over individual images.
```
const imageContainers = document.querySelectorAll('.image-container');
imageContainers.forEach((container) => {
container.addEventListener('mouseover', () => {
const imgSrc = container.getAttribute('data-src');
const img = new Image();
img.src = imgSrc;
img.onload = () => {
container.style.filter = 'blur(4px)';
};
});
container.addEventListener('mouseout', () => {
container.style.filter = '';
});
});
```
**Transitioning Between Blurry and Focused Images**
To make our image gallery more interactive, we can add a transition effect when hovering over individual images. We'll use the `transition` property and set it to `0.3s` with the `linear` timing function.
```
.image-container {
width: 100%;
height: 200px;
}
.image-container:hover {
transition: filter 0.3s linear;
}
```
When an image is hovered over, we'll apply a blur effect using the `filter` property. When the mouse leaves the image container, we'll reset the filter to its original state.
By experimenting with different styles and effects, you can create a unique and interactive image gallery that showcases your favorite images in a new and exciting way.