I am having a bit of a problem, I have to add caption to my image which has a transparent background of opacity say 0.65 and color black, I have added a caption which has no background effects yet, help needed ASAP.
Thank You in advance.
Here's my code
<div class="img-wrap"> <div style="300 px; font-size:20px; text-align:center;background-color= "ff0066;">
<img src="/gadgets.jpg" alt="alternate text" width="220px" height="200px" style="padding-bottom:1.0em;">
Gadgets and Accessories
</div>
<div class="img-info">
<h3>Gadgets & Accessories</h3>
Tablets<br>
Headphones<br>
External Optical Drives<br>
Flexible Keyboards<br>
<h3>More...</h3>
</div>
</div>
The classes img-wrap and img-info contain styling code for some transitions for mouse hover effect, do I need to create a separate class for the caption thing?
I think you're looking for something like this:
FIDDLE
Markup
<div class="img-wrap">
<img src="http://placehold.it/220x200" alt="alternate text" width="220px" height="200px" />
<a class="caption" href="#">Gadgets and Accessories</a>
</div>
CSS
.img-wrap
{
position:relative;
height: 200px;
overflow:hidden;
}
.caption
{
width:220px;
font-size:20px;
text-align:center;
background-color: rgba(0,0,0,.7);
position:absolute;
left:0;
bottom:-25px;
color:#fff;
visibility:hidden;
transition: all, 0.3s ease 0.2s;
}
img
{
width: 220px;
height: 200px;
display:inline-block;
}
img:hover + .caption
{
visibility:visible;
bottom: 2px;
transition: all, 0.3s ease 0.2s;
}
Related
I am not good in designing part like HTML and CSS but I made a card using html and CSS and I am using PHP for fetching data form the database, I had fixed every thing in my HTML and CSS code, but the problem is that when the data is fetched from the database the top icons are moved.
I don't understand why this is happening, since there are 20-25 cards being fetched from the database the icons adjust themselves according to the names on the card.
I had used margin and padding but they both doesn't work in my CSS code.
<p style="font-size:14px; font-weight:bold; text-transform: uppercase; position:absolute:top:0px;">
New Star Tent House
<!--icons-->
<img src="icons/fav.png" style="position:relative; top:-4px; left:110px; width:20px; height:20px; -webkit-transition:all 2s .2s; -moz-transition:all 2s .3s; transition:all 2s .3s" /></a>
<img src="icons/location.png" style="position:relative; top:-4px; left:110px; width:25px; height:25px;" />
I want the icons to be fixed at every card, no matter whether the name is long or short.
This image is showing the icons position where I want
This image is showing the change in icons position with respect to name
try this:
Remove the left: from image tag. Add a span or div to contain both of the images, and add float:right to the span so that will always stay on right.
<p style="font-size:14px; font-weight:bold; text-transform: uppercase; position:absolute:top:0px;">
New Star Tent House
<!--icons-->
<span style="float:right; display:inline-block"><img src="icons/fav.png" style="position:relative; top:-4px; width:20px; height:20px; margin-right:10px; -webkit-transition:all 2s .2s; -moz-transition:all 2s .3s; transition:all 2s .3s" /></a>
<img src="icons/location.png" style="position:relative; top:-4px; width:25px; height:25px;" /></span>
Try This code
.icons a {
display: inline-block;
vertical-align: middle;
}
span {
display: inline-block;
vertical-align: middle;
}
.icons {
float: right;
}
.main-div {
background: #075E54;
padding: 8px 20px;
}
<div class="main-div" style="font-size:14px; font-weight:bold; text-transform: uppercase; position:relative;overflow:hidden;">
<span>New Star Tent House</span>
<!--icons-->
<div class="icons">
<a href="#"><img src="icons/fav.png" style=" width:20px; height:20px; -webkit-transition:all 2s .2s; -moz-transition:all 2s .3s; transition:all 2s .3s" />
</a>
<a href="#">
<img src="icons/location.png" style="width:25px; height:25px;" />
</a>
</div>
</div>
I have two images. One over the other.
When I resize the browser window, the images must be placed at the same position. How do I achieve that?
Here is my html code:
<div id="stars-container">
<div id="star-1" class="stars"
data-1000p="position:absolute;opacity:0;"
data-1010p="position:absolute;opacity:1;"
>
<img src="img/stars/1.png" alt="">
</div>
</div><!-- end of stars-container -->
<!-- Pegasus bg starts -->
<div class="pegasus"
data-1000p="opacity:0;"
data-1270p="opacity:1;">
<img src="img/stars/horse1.png">
</div>
<!-- Pegasus bg ends -->
</div>
</div>
And here is its CSS:
#stars-container{
height:60%;width:50%;display:block;
position:relative;
top:14%;left:20%;z-index:9;
}
.stars{
position:relative;
z-index:9;
}
.stars img{
position:absolute;
width:100%;
}
#star-1{top:25%;left:30%;}
#star-2{top:20%;left:33.5%;}
#star-3{top:25%;left:35%;}
#star-4{top:30%;left:39%;}
#star-5{top:29.5%;left:41.5%;}
#star-6{top:35%;left:42.5%;}
#star-7{top:35%;left:51.5%;}
#star-8{top:30%;left:52.5%;}
#star-9{top:44%;left:48.5%;}
#star-10{top:55.5%;left:47.1%;}
#star-11{top:53%;left:42%; }
#star-13{top:56%;left:37.5%;}
#star-14{top:62%;left:33%;}
#star-15{top:54%;left:42%;}
#star-16{top:49.5%;left:37%;}
#star-17{top:52%;left:33%;}
#star-18{top:51.5%;left:30%;}
.pegasus{
width:50%;height:50%;
position:relative;left:20%;
top:-40%;
}
.pegasus img{
position:absolute;
width:100%;
}
So, basically there is an image of image of pegasus below the group of 18 stars. I am doing it for a parallax website.
You could add style tag to html code.
style="position:fixed;width:36px; height:36px; left:60px;top:50px"
For you the important parameters are left(x) and top(y).
You can use following code
<style>
.image1{
background : url('<path to image1>') no-repeat;
}
.image2{
background : url('<pat to image2>') no-repeat;
}
</style>
<div class="image1">
<a class="image2" href="#" style="left: 10px; top: 92px;"></a>
</div>
Above code will set image 1 as background image. I have used anchor tag for image above image1. You can use your own tag eg. img. Important thing is style that should be used is left and top. This will locate the image2 on top of image1 from 10px left and 92px top with repect to div's top, left = (0,0)
Try image cross fading.
More Info and demo :here
or fiddle
#cf {
position:relative;
height:281px;
width:450px;
margin:0 auto;
}
#cf img {
position:absolute;
left: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;
}
#cf img.top:hover {
opacity:0;
}
<div id="cf">
<img class="bottom" src="http://addnectar.co.in/ovenfresh/ovenfresh/admin/files/products/Sunny-29-07-2014-img-06-07-40.jpg" />
<img class="top" src="http://addnectar.co.in/ovenfresh/ovenfresh/admin/files/products/Sunny-29-07-2014-img-07-45-01.jpg" />
</div>
I have developed an CSS and HTML code to create some kind of accordion multi-banner. I'm not using javascript at all.
Every thing works fine,except for I issue I can not resolve:
Start point is the first image "expanded"
If you hover over some other image, the former hovered one srinks,and the current also expand. Remainig ones accomodate their witdh
PROBLEM: if you hover fast from left to rigth to the last image you come to a point where you can over a greyed on (wrapper background) and all iamges remain then collapsed.
A must should be that,always, no matter what, there's at least one image expanded to show let's say an ad,product to choose...
How can I resolve that? The reason I'm not using width:auto is that it currently doesn't make any transitions with that value set.
CODE at http://jsfiddle.net/7NR4Y/
<style type="text/css">
#wrapper div.sector {
width:50px;
height:250px;
background-position:top center;
background-repeat:no-repeat;
float:left;
max-width:300px;
opacity:0.5;
overflow:hidden;
-webkit-transition:all 1s ease-out; /* Chrome y Safari */
-o-transition:all 1s ease-out; /* Opera */
-moz-transition:all 1s ease-out; /* Mozilla Firefox */
-ms-transition:all 1s ease-out; /* Internet Explorer */
transition:all 1s ease-out; /* W3C */
}
#wrapper #first{
width:300px;
max-width:300px;
min-width:50px;
opacity:1;
}
#wrapper:hover div.sector{
width:50px;
max-width:100%;
opacity:0.5;
}
#wrapper:hover #first{
width:50px;
max-width:100%;
}
#wrapper div.sector:hover{
width:300px !important;
opacity:1;
}
</style>
<body>
<div id="wrapper" style="width:500px; height:250px; background-color:#CCC; overflow:hidden; position:relative;">
<div id="first" class="sector" title="Imagen 1"><img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRTpTF_3Pjjnsum_miN1hicvsPb-44qUm4Qban2_MfzEHevwK0_" /></div>
<div class="sector" title="Imagen 2"><img src="http://1.bp.blogspot.com/-dazqpbQnahc/UaxhFz6mwgI/AAAAAAAAGJQ/pVhtFcqEBiY/s640/Ideal-landscape.jpg" /></div>
<div class="sector" title="Imagen 3"><img src="http://2.bp.blogspot.com/-XegWV6RbUmg/UKIA7m7XgDI/AAAAAAAAAtA/6yQKXMkTjmA/s640/village-vector-the-dock-pixels-tagged-beach-landscape-512305.jpg" /></div>
<div class="sector" title="Imagen 4"><img src="http://i.telegraph.co.uk/multimedia/archive/01842/landscape-rainbow_1842437i.jpg" /></div>
<div class="sector" title="Imagen 5"><img src="http://c.dryicons.com/files/graphics_previews/sunset_landscape.jpg" /></div>
</div>
I have added the following to your CSS
a:last-child div.sector {
position: relative;
overflow: visible !important;
}
a:last-child div.sector:after {
content: "";
position: absolute;
left: 100%;
top: 0px;
height: 100%;
width: 100px;
background-color: green;
}
This creates a pseudo element after the last div of your series.
This pseudo will receive the hover state and transmit it to the element. This, way, even if the cursor goes in the zone of the wrapper that gets exposed sometimes, it will still get it selected.
I have it green so that you can se what is happening, of course in production make it transparent.
fiddle
Disregard all the previous answer !
All you need is
a:last-child div.sector {
overflow: visible !important;
}
fiddle 2
I have these social media icons, when the mouse hovers on one icon its should fade into a other icon. I thought of something like this:
HTML:
<div class="socials">
<img src="../images/fb.png" id="fb1" />
<img src="../images/fb-hover.png" id="fb2" />
<img src="../images/twitter.png" id="twitter1" />
<img src="../images/twitter-hover.png" id="twitter2" />
<img src="../images/insta.png" id="insta1"/>
<img src="../images/insta-hover.png" id="insta2" />
</div>
CSS:
/*This is for letting them stack on each other*/
#fb2, #twitter2, #insta2 {
display:none;
position:absolute;
}
/*Fade animation*/
#fb1:hover, #twitter1:hover, #insta1:hover {
opacity: 0.0;
transition: opacity .55s ease-in-out;
-moz-transition: opacity .55s ease-in-out;
-webkit-transition: opacity .55s ease-in-out;
}
Or check this jsfiddle.
The fading out works correctly. But the 'background' image (so the '...-hover.png' image) won't show up. How do I make this work?
Thanks!
If you set display to block on your #fb2, #twitter2, and #insta2, you can see the problem - it's the positioning. In your solution you would need to absolutely position each hover icon under the normal icon. I don't think it can be flexible.
So, I propose a more flexible solution.
Introduce this syntax:
<div class="socials">
<div class="icon">
<img src="http://sillyquark.com/images/fb.png" class="normal" />
<img src="http://sillyquark.com/images/fb-hover.png" class="hover" />
</div>
<div class="icon">
<img src="http://www.sillyquark.com/images/twitter.png" class="normal" />
<img src="http://www.sillyquark.com/images/twitter-hover.png" class="hover" />
</div>
<div class="icon">
<img src="http://www.sillyquark.com/images/insta.png" class="normal" />
<img src="http://www.sillyquark.com/images/insta-hover.png" class="hover" />
</div>
</div>
Put each icon in a div with a class of of .icon and inside put two images.
Set the .icon div's position to relative to allow absolute positioning relative to the .icon, instead of the body element. Set each icon's top and left to 0px, and add transitions to all images. Also, add width to .icon and img.
.icon{
float: left;
position: relative;
width: 45px;
height: 45px;
padding: 20px;
}
.icon img{
transition: opacity .55s ease-in-out;
-moz-transition: opacity .55s ease-in-out;
-webkit-transition: opacity .55s ease-in-out;
opacity: 1.0;
position: absolute;
width: 45px;
top: 0;
left: 0;
}
This is how you switch opacities. In normal conditions, set .icon .normal's opacity to 1.0, and .icon .hover's opacity to 0.0. On hover, do the oposite.
.icon .hover { opacity: 0.0; }
.icon:hover .hover { opacity: 1.0; }
.icon:hover .normal { opacity: 0.0; }
Check out this fiddle for the demo http://jsfiddle.net/uUk6N/3/
I'm trying to put a vignette on an image link, that when hovered over dissipates. The current code I'm using works fine in Firefox, but in chrome, the transition effect doesn't run.
If you were to remove the thumbnail image, the background has the same effect and does show the transition on it.
Is this a bug?
<article>
<div class="thumbnail">
<img src="images/download.jpg" alt="" />
</div>
<div class="article-text">
<h3>Article Header</h3>
<div class="author">
Author Name here. Date Posted Here.
</div>
<p>Lorem ipsum</p>
<div class="meta">
<ul class="meta-items">
<li>Arbitrary Number</li>
</ul>
<a class="button" href="#">
<span>Read More</span>
</a>
</div>
</div>
</article>
The full css/html can be seen on JSfiddle:
http://jsfiddle.net/aSTKK/
No, it is not a bug. Transitions on pseudo-elements only work in Firefox (personally, I'd like to see them working in other browsers in the future), though there is a way to emulate them for some properties. If you remove the thumbnail image, you see the transition on the element itself (which is below the image when you have it), not on the pseudo-element.
Possible solution: you could make the image semitransparent and change its opacity to 1 on hover (see this gallery of examples I did a while ago, especially row 3, column 3).
Something like this (I've changed the shadow on the pseudo-element to red in order to make it more visible).
Relevant CSS:
.thumbnail {
width:48%;
height:200px;
float:left;
padding:0;
background:#37779f;
box-shadow: inset 0 0 230px 40px rgba(0, 0, 0, 0.5);
-webkit-transition: 1.3s;
-moz-transition: 1.3s;
transition: 1.3s;
overflow:hidden;
text-align:center;
}
.thumbnail a{
position:relative;
max-width:100%;
float:left;
}
.thumbnail:hover{
box-shadow:inset 0 0 115px 20px rgba(0,0,0,0.5);
}
.thumbnail a:after{
content:'';
position:absolute;
top:0;
bottom:0;
left:0;
right:0;
box-shadow:inset 0 0 115px 20px rgba(255,0,0,1);
}
.thumbnail img {
width:100%;
height:auto;
opacity: .3;
-webkit-transition: 1.3s;
-moz-transition: 1.3s;
transition: 1.3s;
}
.thumbnail:hover img {
opacity: 1;
}