Hover effect for popular post widget in blogger - html

I'm very much a newbie, but I'm been trying to figure out how to get a hover effect for my thumbnails for the popular posts widget in Blogger.
I have relatively large thumbnails and I want to have the title of the post appear on hover.
Like this
Can anyone help me with this? I've been trying to find a solution online, but have so far found nothing.

Acutally the below can be simple achieved using display: block; and none but you won't be able to transit the element, hence, inorder to transit the element, we will hide it by using opacity: 0; and on hover we change it to 1, and you can make the background opaque using rgba() and the smoothness using transition. Also, don't forget to make the parent element position: relative; as it holds an absolute positioned child element.
I've made the below example from scratch, you can take a look...
Demo
div.wrap {
position: relative;
display: inline-block;
}
div.wrap img {
display: block;
}
.title {
opacity: 0;
background: rgba(255,255,255,.5);
padding: 5px;
-moz-transition: all .5s;
-webkit-transition: all .5s;
transition: all .5s;
position: absolute;
top: 50%;
right: 0;
}
div.wrap:hover .title {
opacity: 1;
}

try this:
suppose you have Html Markup like this:
<div class="thumbnail">
Iam the main content
<div class="onhover">
i am onhover content
</div>
</div>
css:
.thumbnail{
width:200px;
height:100px;
background-color:Red;
}
.thumbnail:hover .onhover {
display: block;
}
see the demo
so basically, what you want is to affect another element(with certain selector), when some other element is hovered, basic syntax is :
sourceSelector:hover targetSelector{ /*whatever css you want to apply*/}

Related

How to shift iframe towards right side?

I'm currently working on the feature in which whenever a user hovers over a link, instant preview is shown below the link. Like this -
What I wanted to do is, whenever a user hovers over a link, iframe should shift towards right, just like in Google Instant preview.
<div class="title" (mouseover)="overTitle()" (mouseleave)="overTitle()">
{{item.title}}
<div class="box">
<iframe width="400px" height="400px" [src]="myUrlList[i]"></iframe>
</div>
</div>
CSS file -
.box {
display: none;
width: 100%;
}
a:hover + .box, .box:hover{
display:block;
position: absolute;
z-index:100;
}
I tried using align="right" in div tag, but nothing happens. Also in .box class in CSS, I tried using float: right;, but nothing happens. It will be very much helpful if someone can help me. :)
Check something like that, without JS, pure CSS.
https://jsfiddle.net/fxdhcrxj/2/
I just use opacity and visibilityto animate fade in and out, you can use any other methods, like JS fade In out etc.
In CSS if you want catch next element use ~
CSS:
.title{
// for proper position absolute element inside
position: relative;
}
// We catch nexy element .box, and when some one hover over box
.title a:hover ~.box, .title .box:hover{
//display: inline;
visibility: visible;
opacity: 1;
}
// As i use element to bottom 0, I must translated it 100% below of his height.
.title .box{
//display: none;
visibility: hidden;
opacity: 0;
transition: visibility 0.2s ease-in-out, opacity 0.2s ease-in-out;
position: absolute;
z-index: 10;
background: #fff;
bottom:0;
left:0;
transform: translateY(100%);
}
HTML:
<div class="title" >
TITL0E
<div class="box">
<iframe width="400px" height="400px" src="https://www.w3schools.com"></iframe>
</div>
</div>
Important Note:
If you want put lot of Iframes, on page use Lazy load on them.
Simply just replace src attr when someone hover over title or use scripts e.g
http://dinbror.dk/blog/blazy/ otherwise your page will load really slow and make lot of freezes etc.
For better mobile support you may also use focus on element, not only hover
Here you go: http://codepen.io/ruchiccio/pen/vxVoKd
a:hover + .box, .box:hover {
display:block;
position: absolute;
right:0;
top:0;
z-index:100;
}
You need to have right:0; set for the box. Also, your .box was set for a 100% width which is why the iframe didn't know where to go. You have to options: Either set the box width to 400px, which is the same as the iframe (which is what I did in my codepen):
.box {
display: none;
width: 400px;
}
OR you may leave the 100% width but then add text-align:right; to the .box class. Both work.
.box {
display: none;
width: 100%;
text-align: right;
}

Line below link on hover

How can I add a short line below link ? The line should be visible only on hover.
I tried with border-bottom, but that way the line is 100% of the link width and I want the line to be shorter than the link .
Here is a example image of the effect that I try to make.
You can try using ::after pseudo element:
a {
position: relative;
text-decoration: none;
}
a:hover::after {
content: "";
position: absolute;
left: 25%;
right: 25%;
bottom: 0;
border: 1px solid black;
}
<a href='#'>Demo Link</a>
This is something I just thought of, check it out see what you think. So we use :after and create a line under the text. This only works if the parent has a width (for centering).
HTML:
<div>Test</div>
CSS:
div {
width: 30px;
}
div:hover:after {
content: "";
display: block;
width: 5px;
border-bottom: 1px solid;
margin: 0 auto;
}
DEMO
Updated CSS:
div {
display: inline-block;
}
Not sure why I didnt think of this but you can just use inline-block to get it to center without the parent having a width.
DEMO HERE
Here is a link using the same method, just incase you got confused.
DEMO HERE
So I have now be told I should even point out the most obvious thing so here is an update just for the people that don't know width can be a percentage.
width: 70%;
Changed the width from 5px to 70% so it will expand with the width of the text.
DEMO HERE
Edit:
Ruddy's solution has the same result and is more elegant so based on that, I used it recently with addition of transition, making it a bit more eye catching and I thought it would be useful to share here:
a {
display: inline-block;
text-decoration:none
}
a:after {
content: "";
display: block;
width: 0;
border-bottom: 1px solid;
margin: 0 auto;
transition:all 0.3s linear 0s;
}
a:hover:after {
width: 90%;
}
jsfiddle link
(Original answer below)
Check this i just came up with, playing in the fiddle:
<a class="bordered" href="#">I am a link, hover to see</a>
a.bordered {
text-decoration:none;
position: relative;
z-index : 1;
display:inline-block;
}
a.bordered:hover:before {
content : "";
position: absolute;
left : 50%;
bottom : 0;
height : 1px;
width : 80%;
border-bottom:1px solid grey;
margin-left:-40%;
}
Depending on the percentages, you may play with a.bordered:hover:before margin and left position.
Simply use this class:
.link:hover {
background-image:url("YOUR-SMALL-LINE-BOTTOM.png")
}
like this, the line will appear when you hover over the element. And you can specify in the image, how small or big the line has to be.
Try creating another Div for border. And adjust the width of that div according to your choice. I hope this will help.
what about this?
a {text-decoration:none;position:relative;}
a:hover:before {content:"_";position:absolute;bottom:-5px;left:50%;width:10px;margin:0 0 0 -5px;}
check this fiddle for more: http://jsfiddle.net/h7Xb5/
use underline or if u want the line to be much shorter try scalar vector graphics(svg) with this you can have custom lines.
<svg id="line "height="40" width="40">
<line x1="0" y1="0" x2="700" y2="20" style="stroke:rgb(125,0,0);stroke-width:2" />

Hiding and revealing text css

I know this question has been asked a hundred times and I have read every last one of them.
I have an image that is also a link. When the image is hovered it shows a new image and I have a small paragraph description I would like to pop up next to the image when the link is hovered over as well. Simple, right?
What i'm doing makes sense to me, and is the answer to this question. What am I doing wrong? This seems very straightforward.
How to show text on image when hovering?
I will paste my relevant code. Comparing to the posted link answer, I have the class project1 instead of imgWrapper and novelDescrip instead of imgDescription
HTML
<div class="project1">
<img id="novel" src="img/newnovel.png" onmouseover="this.src='img/newnovelblue.png'" onmouseout="this.src='img/newnovel.png'" />
<p class="novelDescrip" >A website for a local musician to market, stream, and distribute music and merchandise.</p>
</div>
CSS
.project1 p {
width: 25%;
margin: 20px 15px 0 0;
float: right;
}
.novelDescrip {
position: absolute;
top:0;
bottom: 0;
left: 0;
right: 0;
visibility: hidden;
opacity: 0;
-webkit-transition: visibility opacity 0.2s;
}
.project1:hover .novelDescrip {
visibility: visible;
opacity: 1;
}
EDIT
Here is my problem now, the text hides and reveals but the hover is activated anytime my mouse is hovering in the area enclosed by the rectangle I drew on this image. Any ideas on why this is happening?
You don't need the the positions. top:0;left: 0; with absolute positioned div will always show up on top left corner of the browser. also added display:inline for the novelDescrip for the div to show-up next to the image.
.project1 p {
width: 25%;
margin: 20px 15px 0 0;
float: right;
}
.novelDescrip {
position: absolute;
visibility: hidden;
opacity: 0;
-webkit-transition: visibility opacity 0.2s;
display:inline;
}
.project1:hover .novelDescrip {
visibility: visible;
opacity: 1;
}
Hope this is what you are looking for.
My be this will solve your problem
img {
height:30%;
width:30%;
}
.project1 p
{
width: 65%;
float: right;
display:none;
margin-left:5px;
}
.project1:hover .novelDescrip
{
display:block;
}
Live Demo

Pure CSS Image Hover Without Using Background Images

I'm trying to make a pure CSS image change on hover / rollover without using background images. So far I have one image and when you rollover that image, another image appears. Here is the CSS:
#hidden {
display: none;
}
#visible:hover + #hidden {
display: block;
}
So, when you rollover the #visible div, the #hidden div appears. Here is the jsFiddle: http://jsfiddle.net/MNyzd/1/
This works great, but it is not exactly what I want to accomplish. I would like the images to swap. So when you rollover #visible, it should disappear instead of remaining visible. My first initial idea was to make the #visible div to display:none on hover (#visible:hover display:none;), but this did not work.
So does anyone have any idea how I would successfully turn this into a traditional image hover / swap using this method? Any help would be appreciated and again, here is the jsFiddle... http://jsfiddle.net/MNyzd/1/
Use a container where you do the hover on:
http://jsfiddle.net/MNyzd/8/
.hidden {
display: none;
}
.container:hover .visible
{
display: none;
}
.container:hover .hidden {
display: block;
}
See also this answer: Hide / show content via CSS:hover (or JS if need be)
Like this?
jsFiddle
div {
cursor:pointer;
overflow:hidden;
width:300px;
}
div > img:nth-child(2), div:hover > img:nth-child(1) {
display:none;
}
div:hover > img:nth-child(2) {
display:block;
}
http://jsfiddle.net/MNyzd/4/
EDIT: The code:
#hidden {
display: none;
position: absolute;
top: 8px;
left: 8px;
}
#visible:hover + #hidden {
display: block;
}
#hidden, #visible {
width:300px;
height:300px;
}
<div id="visible"><img src="http://b.vimeocdn.com/ps/372/159/3721596_300.jpg"></div>
<div id="hidden"><img src="http://yuccan.com/wp-content/uploads/2013/04/cool-eez-spaced2.png"></div>

Possible to add image caption with css pseudo content?

I am looking for the easiest, most maintainable way to do this:
These are text slugs that will be appended to certain images throughout the site. They all say this same thing, but the images are varied and come from a CMS.
I know how I would do it with the image set to position relative and a div with "there's a better way" in an absolutely positioned child div.
However, since that requires HTML added to every image that gets this treatment, I was looking for a way to do this with a css class using the :before pseudo element. So far, applying the class to a wrapping link has no effect:
<img src="imagepath" alt="">
.tabw img:before {
content: 'theres a better way';
color: red;
font-size: 18px;
}
Is this sort of thing possible? Having the whole thing in CSS means all I have to do is have the CMS apply the class attribute when needed.
Yeah, ::before and ::after don't work on images. But you can apply them to the wrapper
link:
a{
position: relative;
}
a, a > img{
display:inline-block;
}
a::before{
content: 'theres a better way';
position: absolute;
left: 0;
top: 0;
width: 80%;
height: 20px;
left: 10%;
background: #000;
opacity: 0.4;
color: red;
font-size: 18px;
}
demo
If you want the text added in the HTML, you'll have to put a real element with it in your link (and apply the same rules to it, but without content)
I'll do it like this with jQuery :
Html
<div class="thumb">
<img src="http://www.zupmage.eu/up/NvBtxn7LHl.png" alt="cover"/>
<div class="caption">My caption</div>
</div>
Css
.thumb {
position:relative;
width:230px;
height:230px;
}
.thumb img {
max-width:100%;
}
.thumb .caption {
display:none;
position:absolute;
top:0;
height:20px;
line-height:20px;
width:100%;
text-align:center;
background:rgba(255,255,255,0.5);
}
JQuery
$('.thumb').hover(function() {
$(this).find('.caption').fadeIn();
}, function() {
$(this).find('.caption').hide();
});
See fiddle
NOTE TO ANYONE FINDING THIS THREAD: In Firefox 21 and IE 9/10 this did not work right with oversized images. It forced the images to 100% even if globally set to max-width: 100%
I had to follow the answer I selected above but set the A tag to display:block instead of display:inline-block to fix.