Hover effect not showing in child div - html

I have four categories in my solutions page, Oil&gas, utilities, Inteligent building,
Industrial Engineering.
I have put a hover effect on each category there is a main div
called pic_categry(while hover the background colour change). And I have'
also put an hover effect in child div of pic_categry called pic_catgry_img1. My
problem is when I hovering the parent div(pic_categry) the hover effect of
pic_catgry_img1 is not working its working only hover that div. How can I display both hover effect when hovering parent div (pic_categry).
HTML:
<div id="wrapper4"> <a href="oil_n_gas.php">
<div class="pic_categry">
<div class="pic_catgry_img1"></div>
<div class="pic_catgry_title">Oil N Gas</div>
</div>
</a> <a href="smart_meter.php">
<div class="pic_categry">
<div class="pic_catgry_img3"></div>
<div class="pic_catgry_title">Utilities</div>
</div>
</a> <a href="inteligent.php">
<div class="pic_categry">
<div class="pic_catgry_img2"></div>
<div class="pic_catgry_title">Intelligent Building</div>
</div>
</a> <a href="industrial_engineering.php">
<div class="pic_categry align_tab">
<div class="pic_catgry_img4"></div>
<div class="pic_catgry_title">Industrial Engineering </div>
</div>
</a>
</div>
CSS:
.pic_categry {
width: 233px;
height: 239px;
float: left;
text-align: center;
color: #425B97;
margin-bottom: 20px;
padding-top: 10px;
padding-right: 3px;
padding-bottom: 5px;
padding-left: 3px;
margin-right:23px;
}
.pic_categry:hover {
background-color:#e8e8e8;
border-radius:4px;
color:#263a87 !important;
}
.pic_catgry_title {
font-family:'Varela', sans-serif;
font-size:20px;
text-align:center;
padding-bottom: 10px;
}
.pic_catgry_title:hover {
color:#263a87;
text-decoration:none !important;
}
.pic_catgry_img1 {
width: 157px;
height: 128px;
margin: 0px auto;
background-image: url(../images/new/ind_oil.png);
background-repeat: no-repeat;
background-position: left top;
}
.pic_catgry_img1:hover {
background-image: url(../images/new/ind_oil.png);
background-repeat: no-repeat;
background-position: left bottom;
}
.pic_catgry_img2 {
width: 157px;
height: 128px;
margin: 0px auto;
background-image: url(../images/new/ind_smart.png);
background-repeat: no-repeat;
background-position: left top;
}
.pic_catgry_img2:hover {
background-image: url(../images/new/ind_smart.png);
background-repeat: no-repeat;
background-position: left bottom;
}
.pic_catgry_img3 {
width: 157px;
height: 128px;
margin: 0px auto;
background-image:url(../images/new/ind_utlts.png);
background-repeat: no-repeat;
background-position: left top;
}
.pic_catgry_img3:hover {
background-image: url(../images/new/ind_utlts.png);
background-repeat: no-repeat;
background-position: left bottom;
}
.pic_catgry_img4 {
width: 157px;
height: 128px;
margin: 0px auto;
background-image:url(../images/new/ind_heavy.png);
background-repeat: no-repeat;
background-position: left top;
}
.pic_catgry_img4:hover {
background-image: url(../images/new/ind_heavy.png);
background-repeat: no-repeat;
background-position: left bottom;
}

Just change your code like this:
.pic_catgry_img1:hover{
background-image: url(../images/new/ind_oil.png);
background-repeat: no-repeat;
background-position: left bottom;
}
to
.pic_categry:hover .pic_catgry_img1{
background-image: url(../images/new/ind_oil.png);
background-repeat: no-repeat;
background-position: left bottom;
}
so you can apply hover effects changes on child div while mouse enters parent div.

change the background color and use your desired image
.pic_categry > .pic_catgry_img1:hover{background-color:#FF0000;}

try
.pic_categry:hover .pic_catgry_img1{
background-position: left bottom; //only need this
}
from #Atrem Fitiskin 's comment
change only dependent properties (in this case, only
background-position).

Related

CSS - make background image a link

I have placed a background image inside a div but would like it to be an active link to another page, and also maybe light up when hovered over. Here is the HTML & the CSS, any help would be greatly appreciated! thanks...
<div class="col-sm-4 img1">Football</div>
.img1 {
background-image: url(https://....);
background-repeat: no-repeat;
background-size: cover;
EDIT: full code;
.img1 {
background-image: url(https://images.unsplash.com/photo-1472108482137-8df36ccf0d7b?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1050&q=80);
background-repeat: no-repeat;
background-size: cover;
font-weight: bolder;
font-size: xx-large;
}
.img2 {
background-image: url(https://cdn.pixabay.com/photo/2015/05/28/16/37/sport-788105_960_720.jpg);
background-repeat: no-repeat;
background-size: 100%;
background-size: cover;
font-weight: bolder;
font-size: xx-large;
}
.img3 {
background-image: url(https://images.unsplash.com/photo-1528543606781-2f6e6857f318?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=701&q=80);
background-size: 80%;
background-repeat: no-repeat;
background-size: cover;
font-weight: bolder;
font-size: xx-large;
}
<!-- Containers center and horizontally pad your content -->
<div class="container-fluid">
<!-- create row inside container / row is wrapper for column-->
<div class="row">
<!-- now create 3 columns with small breakpoint -->
<div class="col-sm-4 brdcol img1"> Water Sports</div>
<div class="col-sm-4 brdcol img2">Football</div>
<div class="col-sm-4 brdcol img3">Hiking</div>
<!-- columns centred in page with parent container -->
</div>
</div>
All you need to do to have a clickable image - is to wrap your div element(the one with background image) with anchor tag, like this:
<div class="col-sm-4 img1">Football</div>
You need a single anchor tag with some CSS.
<a class="photo" href="website.net/link"></a>
CSS
.photo {
background-image: url('http://www.thinksnaps.com/wp-content/uploads/2014/07/images-background.jpg');
background-size: 300px;
background-repeat: no-repeat;
background-position: center;
border-radius: 50%;
background-clip: border-box;
transition: background-size 0.2s;
transition-timing-function: cubic-bezier(.07,1.41,.82,1.41);
display: block;
width: 190px;
height: 190px;
text-decoration: none;
cursor: pointer;
overflow: hidden;
text-indent: 100%;
white-space:nowrap;
}
.photo:hover {
background-size: 500px;
}

Add Shadow Effect on Hover to DIV boxes

I'm currently trying to figure out a way to make it so that upon hovering over each separate box on the front page of my website (http://thefloodplains.com/), a shadow animation occurs for that specific box. I want it to look very similar to what can be found at this page: http://tobiasahlin.com/blog/how-to-animate-box-shadow/. I've used this page as a guide in an attempt to set up a hover shadow effect.
Here's the CSS/HTML specifically for the div boxes on my web page (http://thefloodplains.com/):
.col-md-4 {
color:#00A5D1;
height:300px;
}
.col-md-3 {
color:#00A5D1;
height:300px;
box-shadow: 2 2px 3px rgba(0, 0, 0.1, 0.1);
-webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.col-md-4:hover {
background-color: #FFE097;
}
.col-md-3:hover {
-webkit-transform: scale(1.25, 1.25);
transform: scale(1.25, 1.25);
}
.col-md-4 h3 {
position: relative;
top: 40%;
transform: translateY(-50%);
}
.col-md-4 {
color:#00A5D1;
height:300px;
border: 1px solid #FF8B6F;
position: relative;
}
.col-md-3 {
height:300px;
position: relative;
}
.col-md-4:after {
content: '';
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: block;
background: #FFE097;
opacity: 0;
}
.col-md-3:after {
content: "";
position: absolute;
z-index: -1;
top: 0;
right: 0;
left: 0;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
opacity: 0;
-webkit-transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
transition: all 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.col-md-4:hover:after {
opacity: .5;
}
.col-md-3:hover:after {
opacity: 1;
}
.col-md-4 h3 {
position: relative;
z-index: 1;
top: 40%;
transform: translateY(-50%);
}
Anything with the class ".col-md-3" is where I have attempted to add in the hover-shadow effects (in much the same way that I already have the current hover-color effects set up). The following code is the rest of the CSS/HTML of my front page:
<style>
h3 {
font-size:36px;
font-style: bold;
text-align:center;
font-family:'Buernard', Garamond, "Buenard", "EB Garamond",'EB Garamond';
}
img {
max-width: 100%;
max-height: 100%;
}
#div1 {
background-image: url('AboutIcon.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div2 {
background-image: url('ArticlesIcon.png');
background-position: center center; //center the image in the div
background-size: contain; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div3 {
background-image: url('CodingBrackets2.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div4 {
background-image: url('ContactIcon.png');
background-position: center center; //center the image in the div
background-size: contain; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div5 {
background-image: url('FSMusicArt.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div6 {
background-image: url('AudioProduction4.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div7 {
background-image: url('Violin3.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div8 {
background-image: url('GalleryImage2.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
#div9 {
background-image: url('Handshake2.png');
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
background-repeat: no-repeat;
background-size: 100%;
}
div {
background-image:url(../images/please-dont-use-spaces.jpg); //add the background image
background-position: center center; //center the image in the div
background-size: cover; //cover the entire div
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<a href="About.html" title="About the site and Author"><div class="col-md-4" id='div1'>
<h3>About</h3>
</div></a>
<a href="Articles.html" title="Original Articles and Content"><div class="col-md-4" id='div2'>
<h3>Articles</h3>
</div>
<a href="CodingCorner.html" title="Coding Corner - Code for a Variety of Projects"><div class="col-md-4" id="div3">
<h3>Coding Corner</h3>
</div></a>
</div>
<div class="row">
<a href="Contact-Social.html" title="Contact The Floodplains & The FloodShark"><div class="col-md-4" id="div4">
<h3>Contact & Social</h3>
</div></a>
<a href="TheFloodSharkMain.html" title="The FloodShark Music and Media"><div class="col-md-4" id="div5">
<h3>
The FloodShark
Music
</h3>
</div></a>
<a href="FloodplainProductions.html" title="Floodplain Productions - virtual record label"><div class="col-md-4" id="div6">
<h3>Floodplain Productions</h3>
</div></a>
</div>
<div class="row">
<a href="ClassicalCorner.html" title="Classical Corner - A nook dedicated to sharing and categorizing classical music"><div class="col-md-4" id="div7">
<h3>Classical Corner</h3>
</div></a>
<a href="Gallery.html" title="Images, Photographs, and Album Art"><div class="col-md-4" id="div8">
<h3>Gallery</h3>
</div></a>
<a href="Contribute-Support.html" title="Contribute to The Floodplains!"><div class="col-md-4" id="div9">
<h3>Contribute / Support</h3>
</div></a>
</div>
</div>
</body>
I tried adding "col-md-3" to the div's as a second class in the above code along with "col-md-4," which controls the color hover effect. The problem is, I don't think this method works, but I'm not really sure what does. As of right now, I'm using the "col-md-4" color hover effect - which is working - but getting a shadow effect to work simultaneously is something I have yet to figure out.
So currently - upon hovering - the boxes turn to that transparent shade of orange/yellow. Is there a way that I can get the shadow animation AND the color-change hovers to work together at the same time? So basically I just need a hover animation added to what is already here at http://thefloodplains.com/.
Thank you in advance for your time.
Create a new class for the effect i.e. hovernow add the following code:
body {
background-color: white;
}
.hovernow {
background-color: red;
width: 100px;
height: 100px;
margin: 10px;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
transition: box-shadow 0.3s ease-in-out;
}
.hovernow:hover {
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.8);
}
<div class="hovernow">
</div>
Then add this class .hovernow to the div's which you like the hover effect to apply to.
Are you looking for this, Fiddle
I have added the style for .col-md-4. Please check the code...

positioning multiple background images

This is my code.I want to move that yellow circle to right (about 25px) .how can I give that style to the second image only.
.img_home
{
background-repeat: no-repeat;
height: 1000px;
background-image: url(http://www.spidycode.com/testing/revibe/images/Circle1.png),url(http://www.spidycode.com/testing/revibe/images/Circle2.png);
}
<div class="img_home"></div>
Try this
.img_home
{
background-repeat: no-repeat;
height: 1000px;
background: url(http://www.spidycode.com/testing/revibe/images/Circle1.png) 25px top no-repeat,url(http://www.spidycode.com/testing/revibe/images/Circle2.png) no-repeat;
}
<div class="img_home"></div>
simply add background-position: 25px 0px, 0px 0px;
Try this
.img_home
{
background-repeat: no-repeat;
height: 1000px;
background: url(http://www.spidycode.com/testing/revibe/images/Circle1.png) 25px 0 no-repeat,url(http://www.spidycode.com/testing/revibe/images/Circle2.png) no-repeat;
}
<div class="img_home">
You could do with setuping parameters with background:
background: url repeat posX posY
.img_home
{
height: 1000px;
background: url(http://www.spidycode.com/testing/revibe/images/Circle1.png) no-repeat,url(http://www.spidycode.com/testing/revibe/images/Circle2.png) no-repeat 200px 0px;
}
<div class="img_home"></div>

Onmouseout and OnmouseOver image with CSS Sprite

I have the following image and i want to turn it to CSS Sprite:
<img height="32" width="139" border="0" onmouseout="this.src='/images/top_menu/nav03.gif';" onmouseover="this.src='/images/top_menu/nav04.gif';" src="/images/top_menu/nav03.gif" />
My CSS is
.sprite-top_menu {
background-image: url(top_menu.png);
background-repeat: no-repeat;
/*display: block;*/
}
.sprite-nav03-top_menu {
width: 139px;
height: 32px;
background-position: 0 -32px;
}
.sprite-nav04-top_menu {
width: 139px;
height: 32px;
background-position: -139px -32px;
}
What is the best way to do it ?
<img> tags don't lend themselves very well for sprites, I recommend doing something like this:
<div class="sprite-top_menu"></div>
CSS
.sprite-top_menu {
background: url(top_menu.png) no-repeat;
width: 139px;
height: 32px;
background-position: 0 -32px;
}
.sprite-top_menu:hover {
background-position: -139px -32px;
}

CSS/HTML border radius issue with fixed backgrounds in Firefox

I do not really understand what happens with some basic HTML/CSS code:
The HTML:
<div class="class1">
<div class="class2">
hello
</div>
</div>
The CSS:
.class1
{
height:300px;
background: url('https://www.planwallpaper.com/static/images/kartandtinki1_photo-wallpapers_02.jpg') center no-repeat;
background-size:100% 100%;
background-attachment:fixed;
padding:60px;
}
.class2
{
background: url('https://www.planwallpaper.com/static/images/i-should-buy-a-boat.jpg') center no-repeat;
background-size: 100% 100%;
background-attachment: fixed;
border-radius: 100px;
line-height:100px;
color:white;
}
I also did a codepen to "show it live", here.
My issue is that I get some strange "black" at the border radius, and I do not know why. Here are some pics:
At the left I get the expected result with IE11, but at the left I get a strange result with Firefox (latest vers.).
My question is, how can I fix this so both browsers show me the result at the left picture (i.e. get rid of the black)?
Thanks!
You can use this code
body {
margin: 0;
padding: 0;
}
.class1 {
height:969px;
background: url('https://d19m59y37dris4.cloudfront.net/directory/1-3/img/photo/photo-1501621965065-c6e1cf6b53e2.jpg');
background-repeat: no-repeat;
background-position: center;
background-size: 100% 100%;
background-attachment:fixed;
padding:60px;
}
.class2 {
background: url('https://d19m59y37dris4.cloudfront.net/directory/1-3/img/photo/new-york.jpg');
background-size: 100% 100%;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
border-radius: 100px;
line-height:100px;
color:white;
}
<div class="class1">
<div class="class2">hello</div>
</div>