html - CSS Hover Caption Issue -
- i have site background seperated 4 divs each take 25% of page
the goal have overlay fade in when hovered on (which applied first image - #nw)
the problem cannot text class .caption show up
the code below:
css
.overlaytext {font-family: 'raleway', sans-serif;} body { height:100%; margin:0; padding:0; } div.bg { position:fixed; width:50%; height:50% } #nw { top:0; left:0; background-image: url('clevelandnight.jpg'); background-size:cover;} #ne { top:0; left:50%; background-image: url('news1.jpg'); background-size:cover;} #sw { top:50%; left:0; background-image: url('drinks1.jpg'); background-size:cover;} #se { top:50%; left:50%; background-image: url('clevelandday.jpg'); background-size:cover;} .overlay { background:rgba(0,0,0,.75); opacity:0; height:100%; -webkit-transition: .4s ease-out; -moz-transition: .4s ease-out; -o-transition: .4s ease-out; -ms-transition: .4s ease-out; transition: .4s ease-out; } #nw:hover .overlay { opacity: 1; height:100%; } .caption { font-color:white; z-index:100; }
html
<html> <head> <link href='http://fonts.googleapis.com/css?family=raleway' rel='stylesheet' type='text/css'> <title>craig cleveland</title> <link href='stylesheet2.css' rel='stylesheet' type='text/css'> </head> <body> <div id='nw' class='bg'> <div class='overlay'> </div> <span class='caption'>hello world</span> </div> <div id='ne' class='bg'> <div class='overlay'> <span class='caption'>hello world</span> </div> </div> <div id='sw' class='bg'> <div class='overlay'> <span class='caption'>hello world</span> </div> </div> <div id='se' class='bg'> <div class='overlay'> <span class='caption'>hello world</span> </div> </div> </body> </html>
1) in html markup, 4 divs not same, change first 1 another:
<div id='nw' class='bg'> <div class='overlay'> <span class='caption'>hello world</span> </div> </div>
2) in css, used id uppercase, in html in lowercase, change them:
#nw { top:0; left:0; background-image: url('clevelandnight.jpg'); background-size:cover;} #ne { top:0; left:50%; background-image: url('news1.jpg'); background-size:cover;} #sw { top:50%; left:0; background-image: url('drinks1.jpg'); background-size:cover;} #se { top:50%; left:50%; background-image: url('clevelandday.jpg'); background-size:cover;}
3) wrote hover
first element (nw
), change work all:
.bg:hover .overlay { opacity: 1; height:100%; }
Comments
Post a Comment