Change css for hover over text box - html

The original idea came from the following
http://freshdesignweb.com/demo/2012/09/css3-hover-effects/
It is a simple hover over image then text relevant to that image drops below it.
I want to modify the area in which the text displays to add rich snippet code, a buy it now button, and an add to cart button. I am having two issues 1) any img scr added between the li automatically appears in the image box and 2) anywhere you click on the image or box takes you to another page since it is an anchor.
the css
.our_menu{width:970px; margin:0 auto;}
ul,li{margin:0;padding:0;list-style:none}
.menu .item{float:left;position:relative}
.menu .item a{background-color:#FFF;color:#000000;display:block;overflow:hidden;position:absolute;box-shadow:0 0 7px 0 #CCC;-moz-box-shadow:0 0 7px 0 #CCC;-webkit-box-shadow:0 0 7px 0 #CCC}
.menu .item a:hover{z-index:2;-webkit-transition:height .2s ease-in-out;-moz-transition:height .2s ease-in-out;-o-transition:height .2s ease-in-out;-ms-transition:height .2s ease-in-out;transition:height .2s ease-in-out}
.menu .item a h3{border:0;font-family:"Times New Roman",sans-serif;font-size:17px;margin:0 0 .5em 0;padding:0;text-transform:uppercase;}
.menu .item a p{color:#432;font-size:16px;}
.our_menu .menu{float:left;margin:0 0 50px 0}
.our_menu .menu .item{background-position:9px -791px;height:170px;padding:0 0 0 7px;width:316px}
.our_menu .menu .item a{height:25px;padding:114px 0 0 14px;top:10px;width:295px;text-decoration:none;}
.our_menu .menu .item a:hover{height:550px;padding-top:179px}
.our_menu .menu .item a img{clip:rect(0px,283px,96px,0px);height:164px;position:absolute;top:14px;width:283px}
.our_menu .menu .item a:hover img{clip:auto}
#media only screen and (max-width: 967px) {
.our_menu{ width:660px;margin:0 auto;}
}
#media only screen and (max-width: 620px) {
.our_menu{ width:330px;margin:0 auto;}
}
Original html
<div class="our_menu">
<ul class="menu">
<li class="item">
<a href="#">
<h3>Appetizers</h3>
<p> Start a meal off right with your favorite from our menu of signature appetizers. Can't choose just one? You don't have to</p>
<img src="images/2.jpg" alt="" height="164" width="283">
</a>
</li>
The following is the rich snippet code I need to use to make the text in the box.
<span itemscope itemtype="http://schema.org/Product">
<img itemprop="image" src="http://www.example.com/images/hello.jpg" />
<h3 itemprop="name">Name of Product Here</h3>
<a itemprop="url" href="http://www.example.com/index.html"></a>
<span itemprop="offers" itemscope itemtype="http://schema.org/Offer"><h3 itemprop="price" class="price">$2.00</h3></span>
<p>
<span itemprop="description">Widget</span><br/>
UPC: 1234567890
</p>
<span>
The following is what I had working up until I wanted to add the buy it now button and add to cart button.
<a class="paypal"><img src="images/cart.gif" alt=""></a><a class="paypal"><img src="images/buynow.gif" alt=""></a>
<div class="our_menu">
<ul class="menu">
<li class="item">
<a itemprop="url" href="http://www.example.com/">
<span itemscope itemtype="http://schema.org/Product">
<img itemprop="image" src="images/hello.jpg" height="164" width="283"/>
<h3 itemprop="name">Product Name</h3>
<span itemprop="offers" itemscope itemtype="http://schema.org/Offer"><h3 itemprop="price" class="price">$2.00</h3></span>
<p>
<span itemprop="description">Widget</span><br/>
UPC: 074804800012<br/>
</p>
</a>
</li>
I created a jsFiddle thanks for the suggestion.
http://jsfiddle.net/3CmGN/
In the fiddle when you hover over the image a box containing text drops down. I want this effect as is. The issue I am having is I do not want the image as a anchor tag and want to add an "add to cart" and "buy it now" button under the UPC in the example.

Related

Why is the border only adding around the first <li> item despite all <li> items being in the <aside> element

Here is the HTML and then the CSS. As you can see the aside is covering all the li items. The CSS is using the aside tag to add the border around all of these elements, but it is only adding a border around the first li item. I have tried adding a separate aside element around each li to overcome this but this didn't work. I have inspected using chrome dev tools and couldn't understand why this is happening.
<aside>[enter image description here][1]
<h5><strong>Related posts</strong></h5>
<ul>
<li class="related-post">
<img
src="img/mantyping.jpg"
alt="mantyping"
width="100"
height="70"
/>
<div>
<a href="Howtolearnwebdevelopment.html" class="related-link"
>How to learn web development</a
>
<p class="related-author"><strong>By Jonas Schmed</strong></p>
</li>
</div>
<li class="related-post">
<img
src="img/csspower.jpg"
alt="lightning"
width="100"
height="70"
/>
<div>
<a href="Unknownpowersofcss.html" class="related-link"
>The unknown powers of css</a
>
<p class="related-author"><strong>By Jim Dillon</strong></p>
</li>
</div>
<li class="related-post">
<img
src="img/javascriptcode.png"
alt="javascript code"
width="100"
height="70"
/>
<div>
<a href="javascriptisawesome.html" class="related-link"
>Why Javascript is awesome</a
>
<p class="related-author"><strong>By Matilda</strong></p>
</li>
</div>
</ul>
</aside>
aside {
background-color: #f7f7f7;
border-top: 5px solid #1098ad;
border-bottom: 5px solid #1098ad;
padding: 50px;
width: 500px;
}````
[1]: https://i.stack.imgur.com/1hIls.png
I am not sure if you are looking forward to adding a border to all list items or want to add a border to the entire aside. In this solution, I'm showing how you can add borders to each list of items. If you want to add a border to the entire <aside>, just replace the .related-post class with aside. Be careful about the code formatting with correct opening and closing tags, else it may break the UI.
/* aside { */
.related-post {
background-color: #f7f7f7;
border: 5px solid #1098ad;
padding: 50px;
width: 500px;
list-style-type: none; /* It removes the bullet */
}
<aside>
<h5>
<strong>Related posts</strong>
</h5>
<ul>
<li class="related-post">
<img src="https://image.shutterstock.com/image-photo/smiling-young-man-sit-table-600w-1939452445.jpg" alt="mantyping" width="100" height="70" />
<div>
How to learn web development
<p class="related-author">
<strong>By Jonas Schmed</strong>
</p>
</div>
</li>
<li class="related-post">
<img src="https://image.shutterstock.com/image-vector/vector-illustration-abstract-electric-lightning-600w-1706216764.jpg" alt="lightning" width="100" height="70" />
<div>
The unknown powers of css
<p class="related-author">
<strong>By Jim Dillon</strong>
</p>
</div>
</li>
<li class="related-post">
<img src="https://image.shutterstock.com/image-photo/digital-technology-software-development-concept-600w-2111828198.jpg" alt="javascript code" width="100" height="70" />
<div>
Why Javascript is awesome
<p class="related-author">
<strong>By Matilda</strong>
</p>
</div>
</li>
</ul>
</aside>
Hope it helps.

Hover image issue

I have a link in text on this page, https://melodylakerart.com/product/sun-on-skin-mask-duplicate-1/ which when hovered over produces a pop up image.
As you can see, the text is broken - all the text between "sensitive' and 'off" should be on one line (including the link)
How do I get rid of the weird line breaks?
CSS is:
.hover_img a {
position: relative;
}
.hover_img a span {
position: absolute;
display: none;
z-index: 99;
}
.hover_img a:hover span {
display: block;
}
.hover_img a:hover span {
display: block;
width: 350px;
}
HTML is:
Sensitive ears? Add an
<div class="hover_img">
<a href="#">adjustable silicone strap
<span>
<img src="https://melodylakerart.com/wp-content/uploads/2020/06/Hanwell-Rainbow-Mask-1.jpg" alt="image" height="100" />
</span>
</a>
<div>
to take the pressure off
The addon is doing something strange with the internal div. It wraps the content in a p tag and pushes the div outside. Best to remove it as not needed and move the class name to the a tag (except)..... Change the a to a span because then you wont have the clickable behaviour.
Change the html to:
Sensitive ears? Add an <span class="hover_img">adjustable silicone ear protector strap <span><img src="https://melodylakerart.com/wp-content/uploads/2020/06/Mask-extenders-2.jpg" alt="image" height="100"></span></span>to take the pressure off.
Modify the Css:
span.hover_img { position:relative; color:#f66f61; }
span.hover_img span { position:absolute; display:none; z-index:99; }
span.hover_img:hover span {display: block;width: 350px;}
you have some problemes with the HTML tags organisation
try to replace the the full <div class="hover_img"> with this code
<div class="hover_img">
<p>
<span>Sensitive ears? Add an </span>
<a href="#">adjustable silicone strap
<span>
<img src="https://melodylakerart.com/wp-content/uploads/2020/06/Hanwell-Rainbow-Mask-1.jpg" alt="image" height="100" />
</span>
</a>
<span>to take the pressure off</span>
</p>
<p class="form-row form-row-wide wc-pao-addon-wrap wc-pao-addon-22252-0-0">
<label><input type="checkbox" class="wc-pao-addon-field wc-pao-addon-checkbox" name="addon-22252-0[]"
data-raw-price="1.50" data-price="1.5" data-price-type="quantity_based"
value="face-mask-strap-extension-loop-ear-protector"
data-label="Face Mask Strap Extension Loop Ear Protector"> Face Mask Strap Extension Loop Ear Protector
(+<span class="woocommerce-Price-amount amount"><span
class="woocommerce-Price-currencySymbol">£</span>1.50</span>)</label>
</p>
<div class="clear"></div>
</div>

How to make clickable gif and make it link to somewhere?

So I have an ambitious idea on something I want to do specifically and want to know the best way to carry it out or if it's even possible.
I want it so when I hover over one of the tabs it plays a gif animation (like some arrow or something) once then leaves it in that last frame (so it doesn't continuously loop then is clickable.
I doubt my code will be any help at all but I'll leave it here anyway (I know it's messy and that I should fix it but I'm sorta new to this.)
<!DOCTYPE html>
<html lang="en-US">
<html>
<style>
head {
background-color: white;
}
span.mainbar {
display: inline-block;
margin-left:10px;
margin-top:3px;
}
span.text {
display: inline-block;
float:right;
margin-right:25px;
margin-top: 27px;
}
span.bar
{
display: inline-block;
float:right;
margin-right:25px;
margin-top: 20px;
}
span.facebook {
display: inline-block;
float:right;
margin-right:30px;
margin-top: 22px;
}
span.instagram{
display: inline-block;
float:right;
margin-right:22px;
margin-top: 22px;
}
span.twitter{
display: inline-block;
float:right;
margin-right:30px;
margin-top: 16px;
}
</style>
<head>
<title> The Project </title>
<link rel="shortcut icon" href="images/favicon.ico"/>
<span class="mainbar">
<a href="Homepage.html">
<img src="images/Temp Text Logo.png" alt="Main Logo" style=";border:0;">
</a>
</span>
<Span class="twitter">
<a href="https://www.twitter.com"target="_blank">
<img src="images/twitter.png" alt="twitter page"
style="width:50px;height50px:;border:0;">
</a>
</span>
<Span class="instagram">
<a href="https://www.instagram.com"target="_blank">
<img src="images/instagram.png" alt="instagram page" style=";border:0;">
</a>
</span>
<Span class="facebook">
<a href="https://www.facebook.com"target="_blank">
<img src="images/facebook.png" alt="facebook page" style=";border:0;">
</a>
</span>
<span class="bar">
<img src="images/bar.png" alt="bar" style=";border:0;">
</a>
</span>
<span class="text">
<a href="about.html">
<img src="images/about.png" alt="about" style=";border:0;">
</a>
</span>
<span class="text">
<a href="shop.html">
<img src="images/shop.png" alt="shop" style=";border:0;">
</a>
</span>
<span class="text">
<a href="Homepage.html">
<img src="images/home.png" alt="Home" style=";border:0;">
</a>
</span>
</head>
<body>
<hr>
</hr>
</body>
</html>
Tab example pic
All you need to do to make an image clickable is to wrap the image in a hyperlink parent:
<a href="http://www.google.com">
<img src="http://placehold.it/100">
</a>
As for only allowing the link to be clickable after the animation has played, it would theoretically be possible through JavaScript, but I wouldn't recommend that. The only way to do it would be with a timeOut, and you would possibly encounter a state where the timing gets out of sync.
Instead of this, I would recommend using a sprite map instead of a GIF.
Hope this helps! :)
You can't control animated gif without javascript/jquery control.
With 2 image, one static and one animated and control the start of animation with jquery, like this solution: Stop a gif animation onload, on mouseover start the activation
Using jquery plugin like this: http://rubentd.com/gifplayer/

Hovering Multiple Divs when targeting one

Hello Stack Overflow Pros
Id like to hover multiple divs when i hover the image.
There is a nav bar on top of different images, when i hover the
image i want to trigger the navigation above.
Here some code:
You can see that the nav is underlined. I want it to trigger, when i clicking on the image.
Thanks a lot for your help!
#nav_start_container {
float:left;
position:relative;
margin-left:60px;
}
#nav_start_container ul li {
min-width:136px;
float:left;
position:relative;
margin:0;
}
.nav_start {
min-width:136px;
display: inline-block;
color: #495d7f;
text-decoration: none;
font-size: 15px;
font-weight: 550;
margin-bottom:20px;
text-align:center;
}
.nav_start:hover {
text-decoration: underline;
background: #fff !important;
color: #495d7f;
-webkit-transition: all 0.1s ease-in-out;
-moz-transition: all 0.1s ease-in-out;
-o-transition: all 0.1s ease-in-out;
-ms-transition: all 0.1s ease-in-out;
transition: all 0.1s ease-in-out;
}
#current {
text-decoration: underline !important;
background: #fff !important;
color: #495d7f !important;
}
.bannerbild {
margin:0;
}
.bannerbild:hover {
padding-top:7px;
position:absolute;
}
<div id="nav_start_container">
<ul id="nav">
<li>
<a href="portrait.html">
<span class="nav_start">test2</span>
<img src="images/1a.jpg" alt="…" class="bannerbild" />
</a>
</li>
<li>
<a href="portrait.html">
<span class="nav_start">test2</span>
<img src="images/1b.jpg" alt="…" class="bannerbild" />
</a>
</li>
<li>
<a href="portrait.html">
<span class="nav_start">test2</span>
<img src="images/1c.jpg" alt="…" class="bannerbild" />
</a>
</li>
<li>
<a href="portrait.html">
<span class="nav_start">test2</span>
<img src="images/1d.jpg" alt="…" class="bannerbild" />
</a>
</li>
<li>
<a href="portrait.html">
<span class="nav_start">test2</span>
<img src="images/1e.jpg" alt="…" class="bannerbild" />
</a>
</li>
<li>
<a href="portrait.html">
<span class="nav_start">test2</span>
<img src="images/1f.jpg" alt="…" class="bannerbild" />
</a>
</li>
</ul>
<div class="clear"></div>
</div>
You could combine the required elements for each menu item in the link.
<li>
<a href="test2.html">
<span class="link-text">test2</span>
<img src="images/1b.jpg" alt="…" class="banner-image" />
</a>
</li>
Now, if you set an :hover definition to the link, it will work if you mouse over the link text or the image. You also shouldn't repeat all the main navigation links (they will be read twice by assistive technologies and search engine bots…)

Center link text in <li> tag

I have an image and text both with links inside of a <li> tag. The <ul> is styled to create columns out of the images and content.
Question: How do I center the copy under the image and add a small margin below the image to give it some separation?
HTML:
<ul class="display-posts-listing">
<li class="listing-item one-fourth first">
<a class="image" href="http://websitex.com/sept-15-2014/">
<a class="title" href="http://websitex.com/sept-15-2014/">Sept 15, 2014</a>
</li>
</ul>
CSS:
ul.display-posts-listing li img{display:block;margin:0px auto;}
ul.display-posts-listing li a.title{margin:0px auto;font:bold 14px arial;margin-top:30px;color:white;text-decoration:none;}
ul.display-posts-listing li a.title:hover{color:orange;}
In order to center text try using the following CSS code.
text-align:center
Adding margin to the bottom of the image should give you the separation you're seeking. Alternately the margin-bottom property can be used.
margin: 0 0 10px 0;
example:
ul.display-posts-listing li .img{display:block;margin: 0 0 10px 0;}
ul.display-posts-listing li a.title{margin:0px auto;font:bold 14px arial;margin-top:30px;color:white;text-decoration:none;text-align:center;}
both your HTML aqnd CSS are weird, change it to this:
<div class="container mainbody">
<ul class="display-posts-listing">
<li class="listing-item one-fourth first">
<img class="image" src="http://i.stack.imgur.com/OrkwY.jpg?s=128&g=1" alt="" />
<a class="title" href="http://websitex.com/sept-15-2014/">Sept 15, 2014</a>
</li>
</ul>
and CSS to something like this:
ul{width:200px;}
ul{width:200px; text-align:center; list-style-type:none}
li img{display:block;margin:0px auto; margin-bottom:20px;}
ul li a{margin:0px auto;font:bold 14px arial;margin-top:30px;color:#f00;text-decoration:none;}
ul.display-posts-listing li a.title:hover{color:orange;}
See fiddle here
i note you use
<a class="image" href="http://websitex.com/sept-15-2014/">
in this way i think your css code should be a.image
ul.display-posts-listing li a.image{display:block;margin:0px auto;}
or also,, make big <li> with position:relative and text position:absolute;
you can control it's position by ex: top:10px;right:10px; and other side