How can I make text appear on an image? - html

Is there a way to make a text appear on an embed image?
[That text appears when the cursor hovers over the image]

https://css-tricks.com/text-blocks-over-image/
You can use the :hover selector in the css to make your text appear when the mouse hovers over the image

Without any examples, yes. Your image and text should be different entities, in that CSS should be able to reference them distinctly. Then you can just do something like this.
#your-text-elements-id:hover {
visibility: "visible"
}
#your-text-elements-id {
visibility: "hidden"
}

you can use the below code to make text appear on cursor hover the image
.texthover {
width:100%;
display:block;
position:relative;}
.texthover .overlay {
position:absolute;
top:25%;
height:50%;
padding:10px;
display:none;
}
.texthover:hover .overlay {
display:block;
}
<div class="texthover"><br />
<img src="https://lh3.googleusercontent.com/U2R2BfwOe-ZiqI1gSgmTpZPDkWBNacaO8_HZkKkVee-wHlHV505gmX91DZnq-dYbzY96" height="50%" width="50%"/>
<div class="overlay"><br />
<h1>Ashok Purohit</h1></div>
</div>

Related

Centered text with background color all the way right

I was asked to code an unusual shape background color on some centered text.
The text should be centered and it's background color should continue all the way right of the parent element.
Here is the desired output :
I have never seen anything like this so I don't even know where to start. Thank you for your help!
You can use a pseudo element to make the black background continue on the right :
DEMO
HTML :
<div>
<span>Some text with</span><br/>
<span>unusual background</span><br/>
<span>color</span>
</div>
CSS :
div{
float:right;
padding-right:150px;
text-align:center;
position:relative;
}
span{
display:inline-block;
background:#000;
color:#fff;
line-height:1.4em;
margin:0;
}
span:after{
content:'';
position:absolute;
width:200px;
height:1.4em;
right:0;
background:inherit;
z-index:-1;
}
I don't understand well your problem, but try to mix these concepts:
HTML:
<div id="parent">
<p id="son">Some text with unusual background color</p>
</div>
JS:
<script type="text/javascript">
document.getElementsById("parent").style.background="red";
document.getElementsById("son").style.background="blue";
</script>
try to change the son and the parent colors.

css hover -> change z-image: doesn't work in IE

The following works in some browsers but not in IE:
Expected result: By default, Blue div covers image... however mouse hover over any visible part of image brings entire image forward (in front of blue div).
http://jsfiddle.net/NUz3M/
CSS:
.container { position:relative; }
.bigpic { position:relative;width:300px;height:300px; }
.bigpic img { z-index:2; position:relative; }
.bigpic img:hover { z-index:10; }
.shade { z-index:3;
position:absolute; top:20%;left:0;
width:100%; height:200px;
background-color:blue; }
HTML:
<table>
<tr>
<td class="container" >
<div class="bigpic">
<img src="http://s8.postimg.org/xhqgtehlh/sample.jpg" />
</div>
<div class="shade"></div>
</td>
</tr>
</table>
Any ideas? suggestions? Trying to stay away from Javascript for this.
Thanks!
This is based on information from the link by #showdev. If the parent z-index is changed on hover instead of the image, it works.
.bigpic:hover { z-index:10;} rather than .bigpic img:hover { z-index:10;}
jsfiddle.net/sMg7a/1/
You do need to make a little more effort reading the links given in your comments.
P.S. Tested in IE 10.0(.9200.16721)

Singe image navigation with mapped links. Can I opaque each portion of image on hover?

I have an image we're using for navigation at the top of a website. I used to set links for each section of the banner. I want to an achieve an opaque effect on hover for each part of the image. Is this possible? Thanks much, Dane.
You could slice the image into seperate images; one for each roll over, the image would still appear to be one image but would have different sections; for the hover you could then either use javascript or have it replace the image with another that appeared opaque
This site shows both the JS method and the CSS method...
http://www.webvamp.co.uk/blog/coding/css-image-rollovers/
just repeat it for each part of the image
You can have a div over each section. Each div would call a javascript event. This even can change the div's style. Something like this:
<javascript>
function changeCss(getId){
var getDiv = document.getElementById(getId)
getDiv.className ="myHover"
}
</javascript>
<styles>
.plain{
width:150px;
height:200px;
position:absolute;
top:0;
left:0;
z-index:1000;
background-color: #666699;
}
.myHover{
width:150px;
height:200px;
position:absolute;
top:0;
left:0;
z-index:1000;
background-color: #666699;
filter: alpha(opacity=80);
}
</styles>
<div onMouseOver="changeCss(this.id)" id="wait" class="plain">
<img src=""/>
</div>
This is just free hand and has not been tested. Give it a try and let me know if there are any issues.

Text Link is Hiding my Image Link

I have a image where text/link is overlayed on top. My problem is that sometimes the text in the foreground will hide the link in the image in the background. I assume this is because the text box forms an invisible rectangle around the text, thus creating a region that appears it should belong to the image but is actually being covered by the text. I am wondering if it is possible that when I mouse over this region, I will be linking to my image link as oppose to my text link (see illustration).
http://jsfiddle.net/WHpMr/
Try this, i.e. put your tag inside : http://jsfiddle.net/WHpMr/3/
HTML:
<div class="ad">
<span class="link middle right">my text link abcdefg<br>meow<br>meow<br>meow</span>
<img src="http://www.placekitten.com/320/200">
</div>
CSS:
.ad {
position: relative;
height: 200px;
width: 320px;
}
.link {
position: absolute;
padding: 20px;
pointer-events: none;
}
.inline-link {
pointer-events: all;
}
.top { top:0%; }
.middle { top:33%; }
.bottom { top:66%; }
.left { text-align:left; left:0%; }
.center { text-align:center; margin:0 auto; width:100%; }
.right { text-align:right; right:0%; }
You are correct in thinking that. The element will create a block containing the content. You could use the Map Element if you are hell bent on doing that.
If you make each line its own link, that will minimize the problem. If you really want to go all out, you can make each word its own link. But you're getting into stuff that's easier to do with some JS automation instead of manually in the HTML.
EDIT: Here's an attempt at a vanilla JS solution that works for your simple example, at least:
http://jsfiddle.net/aLN2d/35/

How to connect an image rollover with a link rollover?

how do you set up a link/image so when you hover an image, a link on the page turns to the hover state and vice versa?
Similar to what this site has:
http://www.adrianlawrence.co.nz/
Any help would be great!
Thanks!
You can attach an event listener to one (image or link) to listen for mouseover. Have that fire a function which will find the element of the matching ID (image and link matching, ie image id = "image1", link id = "link1") and change the CSS.
Pure CSS and HTML can definitely be used to create an effect similar to the website you linked to.
Check out this fiddle.
Place both your link text and your image within one a element.
Give each of your images a distinct ID.
Use CSS to position your image absolutely (or relatively, your call) at the desired location.
The HTML:
<a href="www.google.com">
Hello there.
<img id="img1" src="[SOURCE]" alt="Be Happy!" />
</a>​
The CSS:
/* The Important Stuff */
#img1 {
position:absolute;
bottom:20px;
right:45px;
}
a:hover {
text-decoration:none;
}
a:hover img {
opacity:.8;
}
/* The Unimportant Stuff */
body {
background-color:black;
}
a {
color:white;
}