I have 3 divs. I am trying to place the #cover div behind the #cover-overlay div which should be behind the #user-stuff div. I can't seem to get my z-index to work quite right. What am I doing wrong?
JSFIDDLE: http://jsfiddle.net/BafSL/1/
My CSS:
#cover {
position: relative;
height: 350px;
width: 920px;
/* background: url('http://images.nationalgeographic.com/wpf/media-
live/photos/000/621/cache/praia-dos-tres-irmaos-beach-portugal_62194_990x742.jpg') no-
repeat center center; */
background: url('https://sphotos-b.xx.fbcdn.net/hphotos-
ash4/486464_10150990114607410_529660447_n.jpg') no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
z-index: 0;
}
#cover-overlay {
position: absolute;
top: 0px;
-webkit-background-clip: border-box;
-webkit-background-origin: padding-box;
-webkit-background-size: auto;
background-attachment: scroll;
background-clip: border-box;
background-color: rgba(0, 0, 0, 0);
background-image: -webkit-linear-gradient(bottom, rgba(0, 0, 0, 0) 0px, rgba(0, 0, 0,
0.54902) 100%);
background-origin: padding-box;
background-size: auto;
bottom: 50px;
color: rgb(51, 51, 51);
display: block;
font-family: Arial, sans-serif;
font-size: 14px;
height: 200px;
line-height: 16px;
position: absolute;
text-align: center;
text-shadow: rgb(255, 255, 255) 0px 1px 0px;
width: 100%;
z-index: 10;
}
#user-stuff {
margin: 0px 0px 0px 0px;
padding: 40px 0px 20px 10px;
height: auto;
width: 400px;
z-index: 20;
}
z-index only works on positioned elements, so you need to add a position to your user-stuff div.
#user-stuff {
margin: 0px 0px 0px 0px;
padding: 40px 0px 20px 10px;
height: auto;
width: 400px;
position:relative;
z-index: 20;
}
jsFiddle example
There is no position in #user-stuff:
#user-stuff {
margin: 0px 0px 0px 0px;
padding: 40px 0px 20px 10px;
height: auto;
width: 400px;
z-index: 20;
position: relative;
}
Related
In the following fiddle I successfully have made the spotlight stay in the same place (horizontally centered) except for when my zoom factor is too large. In other words, when I zoom in my spot light does not stay in the center of the horizontal view port.
Please note the use of .spotlight-2:before to fill the left portion of the shadow on the viewport. This is what I needed to prevent non shaded region from appearing.
How do I make the spotlight stay in center horizontally and not shift to the right when zooming in closely in the browser?
Fiddle
https://jsfiddle.net/u0onf23y/
Resulting Output
https://jsfiddle.net/u0onf23y/embedded/result/
CSS
td .div{
height: 400px;
}
.extend-full {
padding-left: 3000px;
margin-left: -3000px;
padding-right: 3000px;
margin-right: -3000px; }
.spotlight-2{
top: 0px;
margin-left:-80px;
float: left;
display: block;
background: radial-gradient(10px 10px at 560px 400px, transparent 0, transparent 150px, rgba(0, 0, 0, 0.5) 160px);
background: -moz-radial-gradient(10px 10px at 560px 400px, transparent 0, transparent 150px, rgba(0, 0, 0, 0.5) 160px);
background: -webkit-radial-gradient(10px 10px at 560px 400px, transparent 0, transparent 150px, rgba(0, 0, 0, 0.5) 160px);
background: -o-radial-gradient(10px 10px at 560px 400px, transparent 0, transparent 150px, rgba(0, 0, 0, 0.5) 160px);
margin-left: 0px;
height: 100%;
position: fixed;
width: 100%;
min-width: 100vw;
min-height: 100vh;
z-index: 10;
};
position: absolute;
width: 100%;
z-index: 10; }
.account-settings-confirm-container-overlay {
z-index: 10;
background-color: white !important;
height: 99px;
position: absolute;
margin-top: 10px;
width: 250px;
font-size: 12px;
box-shadow: 0px 1px 1px 1px rgba(0, 0, 0, 0.1); }
.spotlight-2:before {
content: "";
position: absolute;
display: block;
left: -100%;
height: 100%;
width: 100%;
background: rgba(0,0,0,0.5);
}
Try flexbox. See example fullpage http://codepen.io/rhroyston/full/qadGgd/
html, body {
height: 100%;
margin: 0;
}
#viewport{
height:100%;
display: flex;
align-items: center;
justify-content: center;
z-index: 1;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4);
}
.a{
box-shadow: 0px 0px 5px grey inset;
margin: auto;
padding: 20px;
background-color: #fefefe;
border-radius: 50%;
}
<div id="viewport">
<div class="box">
<div class="a"></div>
</div>
</div>
I used a cover image to fill the sidebar, but there's a black line appearing between the cover image that is not filled with the body and cover body itself. You can see it in action here. I'm pretty sure it's not the border or anything.
Thanks!
HTML
<aside id="sidebar">
<div class="cover-img">
<div class="cover-body">
<div class="logo" style="margin-bottom:30px;">
CSS
.cover-img {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-position: center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
-webkit-box-shadow: 1px 0 1px rgba(0,0,0,0.15);
-moz-box-shadow: 1px 0 1px rgba(0,0,0,0.15);
box-shadow: 1px 0 1px rgba(0,0,0,0.15);
}
.cover-body {
position: absolute;
bottom: 0;
padding: 50px 10% 10%;
width: 100%;
height: 100%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
.cover-body:before {
content: '';
position: absolute;
top: -80px;
right: 0;
bottom: 0;
left: 0;
background-repeat: repeat-x;
background-image: -webkit-linear-gradient(bottom,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.3) 25%,rgba(0,0,0,0) 100%);
background-image: -moz-linear-gradient(bottom,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.3) 25%,rgba(0,0,0,0) 100%);
background-image: -ms-linear-gradient(bottom,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.3) 25%,rgba(0,0,0,0) 100%);
background-image: -o-linear-gradient(bottom,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.3) 25%,rgba(0,0,0,0) 100%);
background-image: linear-gradient(to top,rgba(0,0,0,0.5) 0,rgba(0,0,0,0.3) 25%,rgba(0,0,0,0) 100%);
}
.cover-body {
padding-top: 20px !important;
padding-bottom: 0 !important;
}
You have a box-shadow on .about-blog-author that's what's doing it:
-webkit-box-shadow: 0 -1px 0 rgba(0,0,0,0.3);
-moz-box-shadow: 0 -1px 0 rgba(0,0,0,0.3);
box-shadow: 0 -1px 0 rgba(0,0,0,0.3);
Remove it or change -1px to 0
Its your box-shadow that you specify in the .cover-image class. You can remove it or adjust your code and designs accordingly so that you don't see it there.
Try removing the box-shadow property, and you'll see that that line disappears.
I'm trying to add shadow to the parent object where an child <img> element is positioned inside it. I wan the inset shadow to overlap the image.
My HTML code is:
<section class="highlights">
<img src="images/hero.jpg" alt="" />
</section><!-- End section.highlights -->
and CSS:
.highlights {
height: 360px;
padding: 0;
position: relative;
overflow: hidden;
opacity: 0.9;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
z-index:1;
}
.highlights img {
height: auto;
width: 100%;
margin: 0 auto;
display: block;
position: relative;
}
.highlights {
-webkit-box-shadow: inset 0 0 10px 0 rgba(0, 0, 0, 0.2);
box-shadow: inset 0 0 10px 0 rgba(0, 0, 0, 0.2);
}
The shadow is not appearing for me. What did I do wrong?
The problem is that the image is rendered over the top of the inset box-shadow.
There are 2 possible ways I can think of doing this, one using opacity on the <img> to push it behind the shadow and the second way to position the inset shadow over the top of the image. I prefer the second approach because the full opacity of the image can be retained.
Note: I have made the border large and red for demonstration.
Solution 1 demo
HTML
<section class="highlights">
<img src="http://lorempixel.com/500/360/city/1/" alt=""/>
</section>
CSS
.highlights {
height: 360px;
padding: 0;
position: relative;
overflow: hidden;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.highlights img {
height: auto;
width: 100%;
margin: 0 auto;
display: block;
opacity: .9;
}
.highlights {
-webkit-box-shadow: inset 0 0 10px 0 rgba(0, 0, 0, 0.2);
box-shadow: inset 0 0 25px 25px red;
}
Solution 2 demo
CSS
.highlights {
height: 360px;
padding: 0;
position: relative;
overflow: hidden;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.highlights img {
height: auto;
width: 100%;
margin: 0 auto;
display: block;
}
.highlights::before {
-webkit-box-shadow: inset 0 0 10px 0 rgba(0, 0, 0, 0.2);
box-shadow: inset 0 0 25px 25px red;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
content: "";
}
I'm trying to float two divs and set background images to them. But the desired look I couldn't get.
This is what I wanna do
But this is what I get
My HTML
<div class="orange_bk">Outstanding</div> <div class="black_bk">Play</div>
css
.orange_bk{
float: left;
background: url(../images/Outstanding%20button.png);
background-position: 8px -10px;
width: 45%;
height: 33px;
background-repeat: no-repeat;
line-height: 23px;
text-align: center;
font-size: 15px;
}
.black_bk{
float: right;
background: url(../images/Play%20Button.png);
background-position: 8px -10px;
width: 45%;
height: 33px;
background-repeat: no-repeat;
line-height: 23px;
text-align: center;
font-size: 15px;
}
These are the two images I used
You could ditch the images altogether and use background: #fb892b; for the orange and set a gradient over the top. Also use border-radius for the rounded corners
Quick jsfiddle using gradients and border-radius
.orange_bk, .black_bk {
color:#fff;
float: left;
background: #fb892b;
width: 50%;
height: 33px;
line-height: 2em;
text-align: center;
font-size: 15px;
border-radius:.25em 0 0 .25em;
padding:.25em 0;
font-weight:bold;
font-family: sans-serif;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(255, 255, 255, 0.25)), to(rgba(255, 255, 255, 0.00)));
background-image: -webkit-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.00));
background-image: -moz-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.00));
background-image: -o-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.00));
background-image: -ms-linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.00));
background-image: linear-gradient(top, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.00));
}
.black_bk {
float: right;
background: #000;
border-radius: 0 .25em .25em 0
}
Try to set line-height to be the same as the height of the background (33px).
Also both divs have width: 45%; ..what do you want to do with the rest of 10% that the element that contains these elements has ?
You can tidy this code up a lot and keep it much simpler. E.g. wrap an element around those two divs and do something like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style media="all">
.wrap {
width: 598px;
overflow: hidden;
}
.wrap div {
width: 50%;
line-height: 58px;
text-align: center;
font-size: 15px;
}
.orange_bk {
float: left;
background: url(../images/Outstanding%20button.png) no-repeat 0 0;
}
.black_bk{
float: right;
background: url(../images/Play%20Button.png) no-repeat 0 0;
}
</style>
</head>
<body>
<div class="wrap">
<div class="orange_bk">Outstanding</div> <div class="black_bk">Play</div>
</div>
</body>
</html>
The orange div is simply to long for your orange BG. Try adding a max-width for .orange_bk!
You should also set id to display:block and add a padding-top, so that the text is vertically centered
Try this:
* {
margin: 0;
padding: 0;
}
body {
color: white;
}
.orange_bk{
float: left;
background: url(r55XB.png);
width: 50%;
height: 26px;
padding-top: 7px;
background-repeat: no-repeat;
text-align: center;
font-size: 15px;
}
.black_bk{
float: right;
background: url(tRfQv.png);
width: 50%;
height: 26px;
padding-top: 7px;
background-repeat: no-repeat;
text-align: center;
font-size: 15px;
}</style>
Using percentage values with a non-repeating background makes it look awkward when the window is sized normally so you may want to change something related to that.
.main{width:400px;}
.orange_bk{
float: left;
background: url(r55XB.png);
/*background-position: 8px -10px;*/
width: 45%;
height: 58px;
background-repeat: no-repeat;
line-height: 58px;
text-align: center;
font-size: 15px;
text-shadow: 2px 2px 2px #000;
color:#FFF;
}
.black_bk{
float: left;
background: url(tRfQv.png);
background-position: -119px 0px;
width: 45%;
height: 58px;
background-repeat: no-repeat;
line-height: 58px;
text-align: center;
font-size: 15px;
text-shadow: 2px 2px 2px #000;
color:#FFF;
}
try this solution.....
and also please modify the images into same size
Hi im just starting out and i have a small problem, for some reason i cant get the header and the menuholder to align, the menuholder appears slightly below the header, i need it to be inside the header
#header {
max-height: 50px;
width: 100%;
background: url(../img/bgpattern.png) repeat-x;
position: fixed;
box-shadow: 0px 0px 10px 5px rgb(139, 141, 143);
z-index: 5;
}
#menuholder {
height:50px;
width: 900px;
margin-right: auto;
margin-left: auto;
}
thanks for any feedback.
Is this what you have in mind?
<div id="header">
<div id="menuholder">
This is my menu
</div>
</div>
#header {
max-height: 50px;
width: 100%;
background: url(../img/bgpattern.png) repeat-x;
box-shadow: 0px 0px 10px 5px rgb(139, 141, 143);
}
#menuholder {
text-align: center;
padding: 15px 0;
margin: 0 auto;
}