i want when the user hover on the image or the text and the image scale.i have tried this but only one scale
.top3 , .top1 {
transition: all 1s ease;
}
.top3:hover ,.top1:hover {
transform: scale(1.17);
}
<div class="top3" id="DSC0123"><img src="images/DSC0123.png"></div>
<div class="top3" id="Layer4"><img src="images/Layer4.png"></div>
<div class="top3" id="DSC0416"><img src="images/DSC0416.png"></div>
<div class="top3" id="IMG0541"><img src="images/IMG0541.png"></div>
<div class="top3 top3" id="DSC0331"><img src="images/DSC03311.png"></div>
<div class="top1 top3" id="Food">Food</div>
<div class="top1 top3" id="portrait">Food</div>
<div class="top1 top3" id="LANSCAPES">Food</div>
<div class="top1 top3" id="kids">Food</div>
<div class="top1 top3" id="SPORTS">Food</div>
Use display on <a> and apply hover on <a>, like:
.top3 , .top1 {
transition: all 1s ease;
}
.top3 a, .top1 a {
display: inline-block;
transition: all 1s ease;
}
.top3:hover a ,.top1:hover a {
transform: scale(1.17);
transform-origin: center;
}
Have a look at the snippet below:
.top3 , .top1 {
transition: all 1s ease;
}
.top3 a, .top1 a {
display: inline-block;
transition: all 1s ease;
}
.top3 a:hover ,.top1 a:hover {
transform: scale(1.5);
transform-origin: center;
}
<div class="top3" id="DSC0123"><img src="images/DSC0123.png"></div>
<div class="top3" id="Layer4"><img src="images/Layer4.png"></div>
<div class="top3" id="DSC0416"><img src="images/DSC0416.png"></div>
<div class="top3" id="IMG0541"><img src="images/IMG0541.png"></div>
<div class="top3 top3" id="DSC0331"><img src="images/DSC03311.png"></div>
<div class="top1 top3" id="Food">Food</div>
<div class="top1 top3" id="portrait">Food</div>
<div class="top1 top3" id="LANSCAPES">Food</div>
<div class="top1 top3" id="kids">Food</div>
<div class="top1 top3" id="SPORTS">Food</div>
Hope this helps!
If I understand correctly, you want an image to scale up/down on hover, but not the text. You can do this without duplicating links and with fewer, more robust code. I've made an example to demonstrate, and added borders for ease. You can do whatever you like on hover, of course. I kept it simple.
a {
display: block;
width: 300px;
height: 300px;
border: solid 1px red;
}
a img {
width: 300px;
height: 200px;
}
a span {
width: 300px;
height: 100px;
border: solid 1px green;
}
a:hover {
width: 600px;
height: 600px;
}
a:hover span {
width 600px;
}
a:hover img {
width: 600px;
height: 500px;
}
<img src="http://img05.deviantart.net/c135/i/2011/134/7/0/bridge_by_kzonedd-d3gcetc.jpg" alt="old wooden bridge" /><span>text</span>
The user wants BOTH to scale (the img and the text)
You should put the text div inside the image div, like this:
<div class="top3" id="DSC0123">
<img src="http://www.w3schools.com/css/trolltunga.jpg" />
<div class="top1 top3" id="Food">
Food
</div>
</div>
https://jsfiddle.net/933ex7pv/2/ (working fiddle)
Add transform-origin: 0 0; (or some other values that you like) to make it scale in the center.
Related
I don't know how to make text in the photo, and make a link in the whole photo. I've made a darkening effect which I don't want to change, I just want to add text to it. I really want to keep the current dimensions and, above all, responsiveness.
There is link to codepen: 'https://codepen.io/pawe-dejda/pen/XyPzpK'
body, html {
height: 100%;
}
.caption {
position: absolute;
left: 0;
top: 50%;
width: 100%;
text-align: center;
color: #000;
}
.responsive {
width: 100%;
max-width: 88px;
height: auto;
position: center;
}
.tz-gallery .row > div {
padding: 2px;
margin-bottom: 4px;
}
.tz-gallery .lightbox img {
width: 100%;
border-radius: 0;
position: relative;
}
#media(max-width: 768px) {
body {
padding: 0;
}
}
.fade {
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
}
.fade:hover {
opacity: 0.5;
}
<link rel="stylesheet" href="https://www.w3schools.com/w3css/3/w3.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="http://dejda.e-kei.pl/nuar/css/style.css">
<div class="w3-container w3-padding-64 w3-black">
<div class="w3-content">
<div class="tz-gallery">
<div class="row no-gutters">
<div class="col-sm-6 col-md-4">
<a class="lightbox fade" href="http://dejda.e-kei.pl/nuar/images/mieszkanie-w-kamienicy-lodz/mieszkanie-w-kamienicy-lodz5.jpg">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg">
</a>
</div>
<div class="col-sm-6 col-md-4">
<a class="lightbox fade" href="http://dejda.e-kei.pl/nuar/images/mieszkanie-w-kamienicy-lodz/mieszkanie-w-kamienicy-lodz5.jpg">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg">
</a>
</div>
<div class="col-sm-6 col-md-4">
<a class="lightbox fade" href="http://dejda.e-kei.pl/nuar/images/mieszkanie-w-kamienicy-lodz/mieszkanie-w-kamienicy-lodz5.jpg">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg">
</a>
</div>
</div>
</div>
</div>
</div>
If i understand correctly, you want to be able to post links (link can be a-href, h1, h2, span etc') on top of your picture. To do so, do the following:
1. write a container div. for example:
<div>
text
</div>
set its style (CSS) to the background picture you want. Make sure the div's sizes fit the picture size. Then, inside the div you can simply write down the tag you wish (text). for example:
< span >
text
< /span >
Now things get interesting. In order to position the text inside the div? => set the div's position to relative (position:relative;) and set the span position to absolute. then play around with the top / left / bottom / right of the absoloute position, and text would appear whereever you want it to.
Here's an updated codepen
https://codepen.io/kelvinsusername/pen/YROYZM
It adds a container with some text in it but makes it opaque, then on hover instead of making it less visible (like the image) it makes it more visible.
.fade:hover .description {
opacity: 1;
}
.description {
position: absolute;
z-index: 100;
opacity: 0;
color: #fff;
font-size: 20px;
}
.tz-gallery .row>div {
padding: 2px;
margin-bottom: 4px;
}
.tz-gallery .lightbox img {
width: 100%;
border-radius: 0;
position: relative;
}
.img-text-box {
position: absolute;
bottom: 0;
background: rgba(0, 0, 0, 0.479);
color: #ffffff;
width: 100%;
padding: 20px;
font-family: Arial;
font-size: 17px;
}
.fade {
opacity: 1;
transition: opacity .25s ease-in-out;
-moz-transition: opacity .25s ease-in-out;
-webkit-transition: opacity .25s ease-in-out;
color: #e9e9e9;
}
.fade:hover {
opacity: 0.5;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="tz-gallery">
<div class="container">
<div class="row">
<div class="col-md-4">
<a class="lightbox fade" href="">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg" alt="">
<div class="img-text-box">
<p>Be brave js is cool</p>
</div>
</a>
</div>
<div class="col-md-4">
<a class="lightbox fade" href="">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg" alt="">
<div class="img-text-box">
<p>Readability counts.</p>
</div>
</a>
</div>
<div class="col-md-4">
<a class="lightbox fade" href="">
<img src="http://dejda.e-kei.pl/nuar/images/thumbnails/mieszkanie-w-kamienicy-lodz.jpg" alt="">
<div class="img-text-box">
<p>If the implementation is hard to explain, it's a bad idea.</p>
</div>
</a>
</div>
</div>
</div>
</div>
I have an image and text below it wrapped in one "a" tag. Hovering over the white box with text in it turns the box grey. Hovering over the image and it has an opacity effect.
How can I make the box turn grey and the image opacity happen at the same time when hovered over. At the moment these happen seperately. This is not a huge problem but it'd look better if they happened together.
Here's a screenshot - https://imgsafe.org/image/ef3964b27c
This is my HTML;
<div class="w3-third w3-container w3-margin-bottom">
<a href="#" style="display:block">
<img src="Images/MCR.png" style="width:100%" class="w3-hover-opacity">
<div class="w3-container w3-white">
<p><b>PSB2 and COM4</b></p>
<p><b> </b></p>
</div>
</a>
</div>
Since your snippet is different from the image you provided, I created a simple snippet that changes the opacity of the image and changes the border color (if that is what you mean by box) to gray
.wrapper {
height: 200px;
width: 250px;
border: 3px solid green;
}
.wrapper:hover {
border: 3px solid gray;
}
.wrapper:hover img {
opacity: 0.5;
}
<div class="wrapper">
<a href="#">
<img src="http://via.placeholder.com/250x150" />
</a>
</div>
Try This:
.w3-third {
border: 5px solid lightgreen;
display: inline-block;
position: relative;
text-align: center;
}
p {
margin: 0;
}
a {
color: #000;
text-decoration: none;
}
.w3-third:hover .w3-white {
background-color: gray;
}
.w3-third:hover img {
opacity: 0.2;
}
<div class="w3-third w3-container w3-margin-bottom">
<a href="#" style="display:block"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQEnn9dYYZlciBKfaHCw17-dUgRPX3nq5_6-kV1ua-LIsId5g43uA">
<div class="w3-container w3-white">
<p><b>PSB2 and COM4</b></p>
<p><b> </b></p>
</div></a>
</div>
now try this one with edited code
.w3-white {
margin-top: -20px;
width: 40%;
}
.w3-container:hover img {
opacity: 0.5;
}
.w3-container:hover .w3-white {
background-color: grey;
}
<div class="w3-third w3-container w3-margin-bottom">
<a href="#" style="display:block"><img src="http://webneel.com/daily/sites/default/files/images/daily/09-2013/1-diwali-greetings.preview.jpg" style="width:40%" class="w3-hover-opacity">
<div class="w3-container w3-white">
<p><b>PSB2 and COM4</b></p>
<p><b> </b></p>
</div>
</a>
</div>
Try to put you image and text into a single container and add simple transition. check below snippet.
.img-container {
width: 250px;
border: 2px solid blue;
}
.img-container p {
padding: 10px 0;
margin:0;
transition: all 0.5s ease;
}
.img-container img{
transition: all 0.5s ease;
}
.img-container:hover img {
opacity: 0.5;
}
.img-container:hover p {
background-color: grey;
}
<div class="img-container">
<a href="#">
<img src="http://via.placeholder.com/250x150" />
<p>Some text</p>
</a>
</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 am trying do a transition, that it comes out below
with a delay but I do not get it.
I only want to use CSS, no jquery or js.
Hover works,but not the transition.
Anyone can help me?
Edit: Some like this: link. The examples below
.tools-link {
text-align: center;
}
.tools {
margin: 15px 0;
text-align: center;
height: 280px;
overflow: hidden;
}
.tool-dedicaciones-slide-title {
height: 50px;
margin: 20px 0 5px;
width: 100%;
top: 50%;
transform: translateY(25%);
}
.tool-dedicaciones-slide {
padding: 10px 10%;
background-color: #fff;
height: 100%;
}
.tool-dedicaciones-slide:hover {
position: absolute;
top: 0;
transition: all .4s ease-in-out .1s;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="col-xs-12 col-sm-6 col-md-15 tools tool-dedicaciones">
<a class="remove-underline tools-link" href="">
<!-- <img src="/assets/img/tools/01-maiap-02.png" class="image-dedicaciones"/> -->
<div style="background-color: #725d98; height: 200px; "></div>
<div class="tool-dedicaciones-slide">
<div class="tool-dedicaciones-slide-title" >Dedicacion#s</div>
<div class="tool-dedicaciones-slide-description">
<p>Herramienta para el control y la gestión de dedicaciones profesionales. Autentificación y autorización en servicios terceros. Control de caducidad del Token de sesión. BDD encriptada.</p>
</div>
</div>
</a>
</div>
Not sure what you are trying to apply the transition to, but generally you have do define the property in both the "normal" state and the hover state.
Example:
<style>
.box {
width:500px;
height:500px;
background-color:blue;
transition:0.5s all 0.5s;
}
.box:hover {
background-color:red;
}
</style>
<div class="box"></div>
https://jsfiddle.net/7zszjbw0/
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;
}