When I apply the blur filter to my markup the edges are not being blurred. I would like the entire region to be blurred.
HTML
<div class="container">
<div class="inner">
<div class="image">
</div>
</div>
</div>
CSS
.container {
width: 300px;
height: 250px;
}
.inner {
width: 100%;
height: 100%;
position: relative;
}
.image {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: url(/images/400x300.jpg) no-repeat center center fixed;
background-size: fill;
}
.image:before {
left: 0;
right: 0;
bottom: 0px;
content: "text";
position: absolute;
height: 20%;
width: 100%;
background: url(/images/400x300.jpg) no-repeat center center fixed;
background-size: fill;
-webkit-filter: blur(12px);
filter: blur(12px);
}
Codepen:
http://codepen.io/aaronbalthaser/pen/qNOYdE
The Codepen shows the blurred region. It is kind of like a footer but as you can see the edges are not blurred. Any ideas?
Thanks
You can set overflow: hidden and stretch a little bit the blurred image. I have set width to 110%, height to 35%, left, right and bottom to -5% (the added percentage to width and height). Hope this is what you want.
html,
body{
width: 100%;
height: 100%;
overflow: hidden;
margin: 0;
padding: 0;
}
body {
display: flex;
align-items: center;
justify-content: center;
}
.container {
width: 300px;
height: 250px;
}
.inner {
width: 100%;
height: 100%;
position: relative;
overflow: hidden;
}
.image {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: url(http://attic24.typepad.com/.a/6a00e551101c548834017d3d4fde82970c-500wi) no-repeat center center fixed;
background-size: fill;
}
.image:before {
left: -5%;
right: -5%;
bottom: -5%;
content: "";
position: absolute;
height: 35%;
width: 110%;
background: url(http://attic24.typepad.com/.a/6a00e551101c548834017d3d4fde82970c-500wi) no-repeat center center fixed;
background-size: fill;
-webkit-filter: blur(8px);
filter: blur(8px);
overflow: hidden;
}
<div class="container">
<div class="inner">
<div class="image">
</div>
</div>
</div>
Related
I need help to find the script to use hover on different classes sharing theirs string start like that ( i didn't copy img but it's a picture within the div by the .image_produit tag classes):
.image_produit1
{
background: url('Pic1.jpg') no-repeat;
background-position: center;
background-size: contain;
top: 0px;
}
.image_produit2
{
background: url('Pic2.jpg') no-repeat;
background-position: center;
background-size: contain;
top: 0px;
}
.image_produit:hover img
{
visibility:visible;
}
Here is what you are looking for and I don't recommend:
div {
position: relative;
width: 100px;
height: 100px
}
div h1 {
position: relative;
z-index: 2;
font-size: 15px;
color: blue
}
div img {
position: absolute;
top: 0;
width: 100%;
height: 100%;
z-index: 1;
visibility: hidden;
}
.image_produit1 {
background: url('https://placekitten.com/200/200') no-repeat;
background-position: center;
background-size: contain;
top: 0px;
}
.image_produit2 {
background: url('https://placekitten.com/300/300') no-repeat;
background-position: center;
background-size: contain;
top: 0px;
}
div[class^="image_prod"]:hover img {
visibility: visible;
}
<div class='image_produit1'>
<h1>Product A</h1>
<img src="https://placekitten.com/100/100">
</div>
<div class='image_produit2'>
<h1>Product B</h1>
<img src="https://placekitten.com/100/100">
</div>
Here is the correct way to implement this:
.product {
position: relative;
width: 100px;
height: 100px
}
.product h1 {
position: relative;
z-index: 3;
font-size: 15px;
color: blue
}
.product img {
position: absolute;
top: 0;
width: 100%;
height: 100%;
z-index: 1;
}
.product img.seconday {
z-index: 2;
visibility: hidden;
}
.product:hover img.seconday {
visibility: visible;
}
<div class='product'>
<h1>Product A</h1>
<img src="https://placekitten.com/200/200">
<img src="https://placekitten.com/100/100" class='seconday'>
</div>
<div class='product'>
<h1>Product B</h1>
<img src="https://placekitten.com/300/300">
<img src="https://placekitten.com/100/100" class='seconday'>
</div>
i want to use z-index for text and overlay.
https://jsfiddle.net/osm2rkbx/1/
it is my code.
.mainArea {
background: url('https://c.wallhere.com/photos/94/68/1920x1000_px_landscape_photography_reflections_river-1002111.jpg!d');
height: 50vh;
width: 100vw;
position: relative;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
.mainArea p {
display: flex;
height: 50vh;
font-size: 1.5rem;
font-weight: 800;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
text-shadow: 2px 2px 4px #000000;
z-index: 999999 !important;
}
.mainAreaOverlay {
position: absolute;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.9);
top: 0;
left: 0;
z-index: 1;
}
<div class="mainArea">
<div class="container">
<div class="col-md-12 text-center ">
<p>its the text..</p>
</div>
</div>
<div class="mainAreaOverlay"></div>
</div>
when i use z-index for text, its not working. It seems pale. How can i see text with white. İf you help me i will be glad, thanks.
Put z-index:-1 in mainArea class and update z-index:-1 to mainAreaOverlay class.
Old mainArea class:
.mainArea {
background: url('https://c.wallhere.com/photos/94/68/1920x1000_px_landscape_photography_reflections_river-1002111.jpg!d');
height: 50vh;
width: 100vw;
position: relative;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
Updated:
.mainArea {
background: url('https://c.wallhere.com/photos/94/68/1920x1000_px_landscape_photography_reflections_river-1002111.jpg!d');
height: 50vh;
width: 100vw;
position: relative;
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
z-index:-1;
}
Old mainAreaOverlay class:
.mainAreaOverlay {
position: absolute;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.9);
top: 0;
left: 0;
z-index: 1;
}
Updated:
.mainAreaOverlay {
position: absolute;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
top: 0;
left: 0;
z-index: -1;
}
I am working on a website hobbinternational.com, and I need the video in the home page to cover the whole screen and the header to be transparent. I tried a lot but couldnt find a solution. Can anyone help?
Add position: fixed; into .page-header
For others, here is an example of a video in the background
.bg-video-wrap {
position: relative;
overflow: hidden;
width: 100%;
height: 100vh;
background: url(https://designsupply-web.com/samplecontent/vender/codepen/20181014.png) no-repeat center center/cover;
}
video {
min-width: 100%;
min-height: 100vh;
z-index: 1;
}
.overlay {
width: 100%;
height: 100vh;
position: absolute;
top: 0;
left: 0;
background-image: linear-gradient(45deg, rgba(0,0,0,.3) 50%, rgba(0,0,0,.7) 50%);
background-size: 3px 3px;
z-index: 2;
}
h1 {
text-align: center;
color: #fff;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
z-index: 3;
max-width: 400px;
width: 100%;
height: 50px;
}
<div class="bg-video-wrap">
<video src="https://designsupply-web.com/samplecontent/vender/codepen/20181014.mp4" loop muted autoplay>
</video>
<div class="overlay">
</div>
<h1>Fullscreen video background
</h1>
</div>
https://codepen.io/designsupply/pen/zmEWBm
I'm trying to add a fade effect to a banner but I can't properly calc the size of image to adjust the fade properly.
For example. if I have an image 1000x400 I need to adjust the calc to be calc(100% - 1010px); but if the image is 1200x400 I can't change dynamically the size to calc(100% - 1210px);
.container {
width: 100%;
min-height: 25rem;
background-color: coral;
display: block;
overflow: hidden;
position: relative;
}
.background-image {
width: 100%;
height: 100%;
left: 0;
top: 0;
position: absolute;
background-image: url("https://placeimg.com/1000/400/any");
background-repeat: no-repeat;
background-position: right;
background-size: auto 100%;
}
.background-image:after {
content: "";
width: calc(100% - 1000px);
height: 120%;
position: absolute;
top: -30px;
left: 0;
overflow: hidden;
box-shadow: 50px 0 100px 100px coral;
}
<div class="container">
<div class="background-image"></div>
</div>
You can try it on codepen: https://codepen.io/Gabrielr472/pen/jONKNdO
If you can use css variables you can try this solution:
<div class="container">
<div class="background-image" style="--width: 1220px"></div>
</div>
and in css
width: calc(100% - var(--width));
and if you need to modify it in js:
elem.style.setProperty('--width', '1220px');
https://codepen.io/Xesenix/pen/qBWKoPY
How can I add a linear radiant to a background image with a specified height?
Codepen
<div class="bg-img"></div>
<h1>This should not be covered</h1>
html, body {
width: 100%;
height: 100%;
}
.bg-img {
width: 100%;
height: 60%; # works with 100%, but not anything less
background: url('http://unsplash.it/1200x800') center center no-repeat;
background-size: cover;
&:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-image: linear-gradient(to bottom right,#002f4b,#dc4225);
opacity: .6;
}
}
add position:relative to .bg-img so absolute pseudo refers to it for coordonates and positioning.
.bg-img {
width: 100%;
height: 60%; # works with 100%, but not anything less
background: url('http://unsplash.it/1200x800') center center no-repeat;
background-size: cover;
position:relative;
https://codepen.io/gc-nomade/pen/ZXKdbv
html,
body {
width: 100%;
height: 100%;
}
.bg-img {
width: 100%;
height: 60%;
background: url("http://unsplash.it/1200x800") center center no-repeat;
background-size: cover;
position: relative;
}
.bg-img:before {
content: '';
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-image: linear-gradient(to bottom right, #002f4b, #dc4225);
opacity: .6;
}
<div class="bg-img"></div>
<h1>This should not be covered</h1>
Other option is to use rgba() colors and set both gradient and image as background images
html, body {
width: 100%;
height: 100%;
}
.bg-img {
width: 100%;
height: 60%;
background:linear-gradient(to bottom right, rgba(0,47,75,0.6), rgba(220,66,37,0.6)), url("http://unsplash.it/1200x800") center center no-repeat;
background-size: cover;
}
<div class="bg-img"></div>
<h1>This should not be covered</h1>