how to use z-index in overlay and text - css

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;
}

Related

Script in CSS to apply hover on many sibling classes (sharing string first part)

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>

Video Background Full Screen in Wordpress

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

CSS filter blur not blurring edges

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>

Center responsive ratio div

I want to create web app for my home automation system but i have a problem with the img of my house.
What i want is to have center (verticaly and horizontaly) image of my house, responsive and still at the image's ratio.
First i try :
body {
color: #000;
background: #3A3D50;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
.container {
width: 100%;
margin: 0 auto;
}
.rect {
width: 100%;
height: 0;
padding-bottom: 50%;
text-align: left;
background-image: url('http://www.bashihq.com/wp-content/uploads/2015/08/3d-house-floor-plans-modern-3d-floor-plans-are-also-a-great-way-for-architects-realtors-and-at-house-floor.jpg');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
position:relative;
}
<div class="container">
<div class="rect">
</div>
</div
Work great but didn't verticaly centered.
So i try to add some absolute positioning :
body {
color: #000;
background: #3A3D50;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
.container {
width: 100%;
height: 50%;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.rect {
width: 100%;
height: 0;
padding-bottom: 50%;
text-align: left;
background-image: url('http://www.bashihq.com/wp-content/uploads/2015/08/3d-house-floor-plans-modern-3d-floor-plans-are-also-a-great-way-for-architects-realtors-and-at-house-floor.jpg');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
position:relative;
}
<div class="container">
<div class="rect">
</div>
</div>
But how center .rect into .container ?
Thank a lot.
Edit :
I forget to precise, i need to place div on my image that keep location.
body {
color: #000;
background: #3A3D50;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
.container {
width: 100%;
height: 50%;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.rect {
width: 100%;
height: 0;
padding-bottom: 50%;
text-align: left;
background-image: url('http://www.bashihq.com/wp-content/uploads/2015/08/3d-house-floor-plans-modern-3d-floor-plans-are-also-a-great-way-for-architects-realtors-and-at-house-floor.jpg');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
position:relative;
}
.rect2 {
width: 3%;
padding-bottom: 3%;
position: absolute;
top: 40%;
left: 31.5%;
background-color: blueviolet;
border-radius: 100px;
}
.rect4 {
width: 3%;
padding-bottom: 3%;
position: absolute;
top: 25%;
left: 60%;
background-color:rgba(0, 0, 0, 0.6);
border-radius: 100px;
}
.rect3 {
width: 50%;
height:50%;
background-image: url('images/light.png');
background-repeat: no-repeat;
background-size: contain;
position: absolute;
top: 25%;
left:32%;
}
code
<body>
<div class="container">
<div class="rect">
<div class="rect2"><div class="rect3"></div></div>
<div class="rect4"><div class="rect3"></div></div>
</div>
</div>
</body>
You can use transform:translate (CSS3)
CSS
body {
color: #000;
background: #3A3D50;
text-align: center;
font-family: Arial, Helvetica, sans-serif;
}
.container {
width: 100%;
height: 50%;
margin: auto;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
.rect {
position: relative;
display: block;
height: 350px; // Adjust your needs
width: 100%;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
background-image: url('http://www.bashihq.com/wp-content/uploads/2015/08/3d-house-floor-plans-modern-3d-floor-plans-are-also-a-great-way-for-architects-realtors-and-at-house-floor.jpg');
background-repeat: no-repeat;
background-size: contain;
background-position: center;
}
DEMO HERE

Some CSS sprites not showing on Firefox, Chrome and IE?

I am using css-sprites on a few pages of a website as navigation buttons, with a part of the image darkening when hovered over. All these buttons have text on them. Before I had just written the text onto the image and things worked fine, but I wanted to add the text to my html so that it renders better for anyone that zooms in to the page. Doing this however has now caused the images for the sprites not to appear in Firefox, Chrome and IE (still works fine in Safari).
Obviously I assumed that adding the text to the code had caused this but now even when I remove the text, the images still don't show up. I'm really having trouble figuring out why this is, especially as I have 2 other pages that use sprites and they are still working fine. The only difference is that i hadn't attempted to move the text into my code on those pages.
Any suggestions are really appreciated
Code for the broken sprites:
.row5
{
width: 940px;
height: 220px;
position: absolute;
left: 10px;
top: 1215px;
}
.box1
{
background: url(http://www.sungblue.com/Images/box1sprite.jpg) 0 0;
background-repeat: no-repeat;
width: 306px;
height: 200px;
position: absolute;
top: 10px;
}
.boxtext
{
font-family: elron;
color: rgba(255,255,255,1.00);
font-size: 18px;
width: 306px;
height: 18px;
position: absolute;
top: 175px;
left: 0px;
text-align: center;
}
.box1:hover
{
background-position: 0 -201px;
}
.box2
{
background: url(http://www.sungblue.com/Images/box2sprite.jpg) 0 0;
background-repeat: no-repeat;
width: 306px;
height: 200px;
position: absolute;
top: 10px;
left: 317px;
}
.box2:hover
{
background-position: 0 -201px;
}
.box3
{
background: url(http://www.sungblue.com/Images/box3sprite.jpg) 0 0;
background-repeat: no-repeat;
width: 306px;
height: 200px;
position: absolute;
top: 10px;
left: 634px;
}
.box3:hover
{
background-position: 0 -201px;
}
.row6
{
width: 940px;
height: 220px;
position: absolute;
left: 10px;
top: 1425px;
}
.box4
{
background: url(http://www.sungblue.com/Images/box4sprite.jpg) 0 0;
background-repeat: no-repeat;
width: 306px;
height: 200px;
position: absolute;
top: 10px;
}
.box4:hover
{
background-position: 0 -201px;
}
.box5
{
background: url(http://www.sungblue.com/Images/box5sprite.jpg) 0 0;
background-repeat: no-repeat;
width: 306px;
height: 200px;
position: absolute;
top: 10px;
left: 317px;
}
.box5:hover
{
background-position: 0 -201px;
}
.box6
{
background: url(http://www.sungblue.com/Images/box6sprite.jpg) 0 0;
background-repeat: no-repeat;
width: 306px;
height: 200px;
position: absolute;
top: 10px;
left: 634px;
}
.box6:hover
{
background-position: 0 -201px;
}
<div class='row5'>
<a href='http://www.sungblue.com/weddings.html'>
<div class='box1'>
<div class='boxtext'>WEDDINGS</div>
</div>
</a>
<a href='http://www.sungblue.com/prewedding.html'>
<div class='box2'>
<div class='boxtext'>ENGAGEMENT SHOOTS</div>
</div>
</a>
<a href='http://www.sungblue.com/contact.html'>
<div class='box3'>
<div class='boxtext'>CONTACT</div>
</div>
</a>
</div>
<div class='row6'>
<a href='http://sungbluephotography.zenfolio.com'>
<div class='box4'>
<div class='boxtext'>CLIENT AREA</div>
</div>
</a>
<a href='http://www.sungblue.com/prices.html'>
<div class='box5'>
<div class='boxtext'>PRICING</div>
</div>
</a>
<a href='http://sungbluephotography.zenfolio.com/blog/'>
<div class='box6'>
<div class='boxtext'>BLOG</div>
</div>
</a>
</div>
And here's the code from my other page where my sprites are working:
.row3
{
width: 940px;
height: 288px;
position: absolute;
left: 10px;
top: 335px;
text-align: center;
}
.box1
{
background-image: url(http://www.sungblue.com/Images/weddingbox1sprite.jpg);
width: 465px;
height: 288px;
position: absolute;
top: 0px;
left: 0px;
}
.boxtext
{
width: 465px;
height: 18px;
position: absolute;
left: 0px;
top: 260px;
font-family: elron;
font-size: 18px;
color: rgba(255,255,255,1.00);
text-align: center;
}
.box1:hover
{
background-position: 0 -289px;
}
.box2
{
background-image: url(http://www.sungblue.com/Images/weddingbox2sprite.jpg);
width: 465px;
height: 288px;
position: absolute;
top: 0px;
left: 475px;
}
.box2:hover
{
background-position: 0 -289px;
}
.row4
{
width: 940px;
height: 288px;
position: absolute;
left: 10px;
top: 633px;
text-align: center;
}
.box3
{
background-image: url(http://www.sungblue.com/Images/weddingbox3sprite.jpg);
width: 465px;
height: 288px;
position: absolute;
top: 0px;
left: 0px;
}
.box3:hover
{
background-position: 0 -289px;
}
.box4
{
background-image: url(http://www.sungblue.com/Images/weddingbox4sprite.jpg);
width: 465px;
height: 288px;
position: absolute;
top: 0px;
left: 475px;
}
.box4:hover
{
background-position: 0 -289px;
}
The problem is with the images themselves. Since they have .jpg extensions, the browsers try to treat them as JPEG files, which they are not. They are PNG files.
Solution: rename them to .png, or convert them to actual JPEG files.

Resources