When hover on the .calltoaction, the background image supposed to scale to 105%. How can I target by CSS? I'm using foundation.css for my html. A codepen has been created as well: http://codepen.io/rezasan/pen/dpyoYO
HTML:
<div id="tiles">
<div class="row">
<div class="medium-6 columns nopadleftright tile-img" style="background-image:url('http://placehold.it/300x300');"></div>
<div class="medium-6 columns nopadleftright text-center">
<div class="v-align">
<h1 class="preheader text-center">EXPERIENCES</h1>
<h1>A Magical Location</h1>
<p>Text</p>
<div class="calltoaction">ABOUT</div>
</div>
</div>
<div class="row">
<div class="medium-6 columns nopadleftright text-center">
<div class="v-align">
<h1 class="preheader text-center">EXPERIENCES</h1>
<h1>A Magical Location</h1>
<p>Text</p>
<div class="calltoaction">ABOUT</div>
</div>
</div>
<div class="medium-6 columns nopadleftright tile-img" style="background-image:url('http://placehold.it/300x300');"></div>
CSS:
#tiles .row .medium-6 {
width:45%;
float:left;
height: 185px;
background-color: #fff;
padding:0 10px;
}
#tiles .row .tile-img{
background-repeat: no-repeat;
background-position: center center;
-webkit-background-size: 100%;
-moz-background-size: 100%;
-o-background-size: 100%;
background-size: 100%;
transition: background-size .3s ease-in-out;
-moz-transition: background-size .3s ease-in-out;
-ms-transition: background-size .3s ease-in-out;
-o-transition: background-size .3s ease-in-out;
-webkit-transition: background-size .3s ease-in-out;
}
#tiles .calltoaction a:hover + .tile-img {
background-size: 105%;
}
You can't do that by pure CSS, because it doesn't work that way (you can't target a parent in your case). However you could achieve this by a little jQuery function:
$('.calltoaction a').hover(function(){
$('.tile-img').css('background-size', '105%');
});
https://jsfiddle.net/wx38rz5L/2777/
Use background-size:105% on hover
#tiles .row .tile-img:hover {
background-size:105%;
}
Related
I have an image in HTML (aaa.jpg) and when I hover I need it to switch to another image (t1.jpg) indicated in css
.single-member .thumb .overlay-member #1 {
background: url(../img/t1.jpg) no-repeat center center/cover;
text-align: center;
padding: 30px;
opacity: 0;
-webkit-transition: all 0.3s ease 0s;
-moz-transition: all 0.3s ease 0s;
-o-transition: all 0.3s ease 0s;
transition: all 0.3s ease 0s;
}
<div class="row">
<div class="col-lg-3 col-sm-6">
<div class="single-member">
<div id="1">
<div class="thumb relative" style="background: url(img/aaa.jpg);">
<div class="overlay overlay-member d-flex flex-column justify-content-end align-items-center">
<div class="line"></div>
<div class="social d-flex align-items-center justify-content-center">
<i class="fa fa-linkedin"></i>
</div>
</div>
</div>
</div>
<div class="desc text-center">
<h5 class="text-uppercase">XXX</h5>
<p>ZZZ</p>
</div>
</div>
</div>
The above code works fine, but it works for using the same image for all. I need to use different images for people, so I repeated the code in html and css but changing the id. Then it is showing only the image stated in HTML file, flipping to the css ones.
.card {
width: 130px;
height: 195px;
position: relative;
display: inline-block;
margin: 50px;
}
.card .img-top {
display: none;
position: absolute;
top: 0;
left: 0;
z-index: 99;
}
.card:hover .img-top {
display: inline;
}
<div class="card">
<img src="https://www.tutorialrepublic.com/examples/images/card-front.jpg" alt="Card Back">
<img src="https://www.tutorialrepublic.com/examples/images/card-back.jpg" class="img-top" alt="Card Front">
</div>
First of all you needs to make some changes in your HTML
You can't use number ID as a css selector like #1 have to replaced with #one
REF: #1 should not use
and you can simply change image by css :hover selector.
Hope this will help you.
.single-member #one {
background: url(https://via.placeholder.com/728x90.png?text=normal) no-repeat center center/cover;
text-align: center;
padding: 30px;
opacity: 1;
-webkit-transition: all 0.3s ease 0s;
-moz-transition: all 0.3s ease 0s;
-o-transition: all 0.3s ease 0s;
transition: all 0.3s ease 0s;
}
.single-member #one:hover {
background: url(https://via.placeholder.com/728x90.png?text=hover) no-repeat center center/cover;
}
<div class="row">
<div class="col-lg-3 col-sm-6">
<div class="single-member">
<div id="one">
<div class="thumb relative">
<div class="overlay overlay-member d-flex flex-column justify-content-end align-items-center">
<div class="line"></div>
<div class="social d-flex align-items-center justify-content-center">
<i class="fa fa-linkedin"></i>
</div>
</div>
</div>
</div>
<div class="desc text-center">
<h5 class="text-uppercase">XXX</h5>
<p>ZZZ</p>
</div>
</div>
</div>
I suggest to use Jscript in HTML it will be of one line
<img src='FirstImage.png' onmouseover="this.src='ChangedImage.png';" onmouseout="this.src='FirstImage.png';" />
I am trying to create an overlay that will cover an entire div/card. I have three cards that I want to rollover black when active. For some reason, I can't get the entire div to be selected.
HTML:
<div class="item ">
<div class="overlay">
<img src="http://placehold.it/600x350">
<h2>Title</h2>
<p> Text</p>
</div><div class="overlay"> </div>
</div>
and CSS:
.item {
padding: 0px 0;
margin: 1%;
border-radius: 2px;
flex: 1 250px;
height: auto;
text-align: center;
background: linear-gradient(0deg, #efefef, #ffffff);
}
.overlay {
position: relative;
background-color: rgba(0,0,0,0)
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
.overlay:hover {
opacity: 1;
background-color: rgba(0,0,0,1);
}
CODEPEN EXAMPLE
div.item has a certain size and shape. Style it as relative so that the next thing will work
Make div.overlay position:absolute - that will overlay it, but it has no size, so it will still be invisible.
Then, make div.overlay the full height of its parent (div.item).
When made visible (at :hover) it will be 100% height/width of .item, and will overlay it.
body {background-color: #C70025;}
img {width: 100%;}
#container {width:90%;margin:0 auto;display:flex;flex-wrap:wrap;
justify-content:space-between;}
.item {color:#000;padding:0px 0;margin:1%;border-radius:2px;flex:1 250px;height:auto;text-align:center;background:linear-gradient(0deg, #efefef, #ffffff);}
.item{position:relative;}
.overlay {
position:absolute;
top:0;left:0;right:0;bottom:0;
background-color: rgba(0,0,0,0);
-webkit-transition: opacity 1s ease-in-out;
-moz-transition: opacity 1s ease-in-out;
-o-transition: opacity 1s ease-in-out;
transition: opacity 1s ease-in-out;
}
.overlay:hover {
opacity: 1;
background-color: rgba(0,0,0,1);
}
<div id="container">
<div class="item ">
<img src="http://placehold.it/600x350">
<h2>Title</h2>
<p> Text</p>
<div class="overlay"> </div>
</div>
<div class="item">
<img src="http://placehold.it/600x350">
<h2> Title </h2>
<p>Text</p>
<div class="overlay"> </div>
</div>
<div class="item">
<img src="http://placehold.it/600x350">
<h2> Title </h2>
<p>Text</p>
<div class="overlay"> </div>
</div>
</div>
I have built a hover effect for my gallery. The gallery is within a Bootstrap Grid.
The hover itself works fine, but in some screen sizes the overlay goes over the gallery images.
Has anybody an idea or a solution or a hint for this problem?
Here an example:
demo
HTML:
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/300x300" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/300x300" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/300x300" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
</div>
</div>
CSS:
.box {
position: relative;
cursor: pointer;
width: 100%;
min-height: 100%;
overflow: hidden;
margin-bottom: 30px;
}
.box .overbox {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 100;
background-color: rgba(204, 36, 42, 0.75);
color: #fff;
opacity: 0;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
.box:hover .overbox {
opacity: 1;
}
.box .title {
font-size: 22px;
line-height: 131%;
font-weight: 400;
text-align: center;
padding-top: 95px;
}
#media (max-width: 991px) {
.box .title {
padding-top: 43px;
}
}
.box .tagline {
position: absolute;
bottom: 0px;
padding-top: 16px;
padding-bottom: 16px;
width: 100%;
display: flex;
justify-content: center;
font-size: 16px;
font-weight: 400;
font-style: italic;
border-top: 1px solid rgb(255, 255, 255);
}
.box_client {
position: relative;
width: 100%;
height: 100%;
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
-ms-filter: grayscale(100%);
-o-filter: grayscale(100%);
filter: grayscale(100%);
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
}
.box_client:hover {
background: rgb(235, 234, 233);
-webkit-filter: grayscale(0%);
-moz-filter: grayscale(0%);
-ms-filter: grayscale(0%);
-o-filter: grayscale(0%);
filter: grayscale(0%);
}
.img-responsive {
margin: 0 auto;
}
the overlay goes over the gallery images because you overlay has width:100%; and when the image is smaller than the width of its container the overlay goes over the gallery image because of the width of image
you have 2 options you can make the image width:100% or you can change the style of .box class and remove width:100%; and make its display:inline-block;
.box {
position: relative;
cursor: pointer;
// width: 100%; // remove this
display:inline-block; // add this
min-height: 100%;
overflow: hidden;
margin-bottom: 30px;
}
The Bootstrap column is growing and shrinking while the image has the same fixed size. So .responsive-image is smaller than its parent div. There are a few solutions:
1) Remove the image in the html and have it as a background-image
.box {
background: url(image-url) cover no-repeat;
}
2) Make the image 100% width
.response-image {
width: 100%;
}
3) Or as Ahmed Salama suggests, remove the width: 100% and add display: inline-block;
Your placeholder is smaller then the parent div element, which fits into the whole witdh of it's parent. Thats caused by the class img-responsive, that itself fits the the image to "max-width: 100%". You should use a bigger image or fit it to the size to your parent box, what is not recommended.
In this pen, i changed the placeholdersizes to 767px x 767px: http://codepen.io/pure180/details/OXpNxM/
HTML:
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/767x767" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/767x767" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
<div class="col-md-4 col-sm-4">
<a href="http://www.google.com">
<div class="box">
<img class="img-responsive" src="http://placehold.it/767x767" />
<div class="overbox">
<div class="title overtext">Client</div>
<div class="tagline overtext">Tag</div>
</div>
</div>
</a>
</div>
</div>
</div>
I fixed with this
.box {
position: relative;
cursor: pointer;
max-width: 300px;
min-height: 100%;
overflow: hidden;
margin: 0 auto;
margin-bottom: 30px;}
Here's my approach: https://jsfiddle.net/5f285ask/3/
.box {
position: relative;
display: inline-block;
}
.box .overbox {
background-color: rgba(204, 36, 42, 0.75);
height: 100%;
left: 0;
opacity: 0;
position: absolute;
top: 0;
-webkit-transition: all 300ms ease-out;
-moz-transition: all 300ms ease-out;
-o-transition: all 300ms ease-out;
-ms-transition: all 300ms ease-out;
transition: all 300ms ease-out;
width: 100%;
}
.box:hover .overbox {
opacity: 1;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="col-md-4 col-sm-4">
<div class="box">
<a href="#">
<img alt="" src="http://placehold.it/300x300" class="img-responsive">
<div class="overbox">
overbox content
</div>
</a>
</div>
</div>
I have created a video player controls but I want to know how can I make it responsive as to make only the scrubber move but the play button or volume button to stay in the same place and keep the same distance?
CSS
#videoControls{
height:8%;
top:92%;
width:100%;
background-color:#d92a2e;
background-color: rgba(0,0,0,0.4);
position:relative;
-webkit-transition: top .5s ease-in;
-moz-transition: top .5s ease-in;
-ms-transition: top .5s ease-in;
-o-transition: top .5s ease-in;
transition: top .5s ease-in;
}
[class^="col-"] ,[class*= " col-"]{
position: relative;
top: 50%;
float: left;
}
.col-80{
width: 80%;
}
.col-7-5{
width: 32px;
padding-left: 10px;
padding-right: 10px;
text-align: center;
}
.col-7-6{
width: 7.5%;
}
.col-5{
width: 5%;
}
HTML
<div class='controls' id='videoControls'>
<div class='col-5'>
<div class='btnGrp'>
<div id='play' class='playBtn'></div>
<div id='pause' class='pauseBtn'></div>
</div>
</div>
<div class='col-80'>
<div id='scrubber'>
<div id='track'></div>
<div id='handle' class='draggable'></div>
<div id='handle2' class=''></div>
</div>
</div>
<div class='col-7-5'>
<div class='btnGrp'>
<div id='mute' class='muteBtn'></div>
<div id='unmute' class='unmuteBtn'></div>
</div>
</div>
<div class='col-7-6'>
<div id='timeDisplay'>
<span id='currentTime'></span>
/
<span id='duration'></span>
</div>
</div>
</div>
I have created the Responsive design if you have multiple div when you re-size the browser?
Following is my html structure:
<div id="div-wrap">
<div class="column-1-7"> ... </div>
<div class="column-2-7"> ... </div>
<div class="column-3-7"> ... </div>
</div>
Below is my css structure:
#div-wrap {
white-space: nowrap;
max-width: 100%;
}
.column-1-7,.column-2-7,.column-3-7 {
width: calc(100% / 3);
display: inline-block;
text-align: center;
}
.column-1-7{
background: #ffcc00;
}
.column-2-7{
background: #ffff00;
}
.column-3-7{
background: #ffccff;
}
I want to set background image and it is not working.
I dont know what the problem is but it just not working please help me out.
html code is:
<div class="main">
<div class="header clearfix">
<div class="container">
<div class="left-header">
<div class="logo"></div>
<div class="fb-like" data-href="https://www.facebook.com/pages" data-layout="button_count" data-action="like" data-show-faces="true" data-share="false"></div>
</div>
</div>
</div>
My css is:
.logo{
background: url("img/logo.png") no-repeat center center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
width: 201px;
margin-left: 10px;
height: 76px;
margin-top: 19px;
transition:all .3s;
-webkit-transition:all .3s;
-moz-transition:all .3s;
-ms-transition:all .3s;
-o-transition:all .3s;
}
And my image size is 231*86px hope u will find the answer and post it
Just add http:// before the image locating in your webserver like this http://img/logo.png and it will start working.