user3353475
user3353475

Reputation: 83

Hover over text to show more text?

How can you hover over a certain word, and to the right it will show more words?

<div id="footer">
<center>
<p>Copyright 2014</p>
</center>
<center><a href="http://www.scriptiny.com/2010/09/fading-slideshow-script/" style="position:absolute; margin-top:20px; margin-left:-35px; text-decoration:none; color:gray; z-index:20;">Tinyfader.js</a> <p style=" margin-top:-38px;padding-top:20px; padding-left:572px; opacity:0; color:red; ">Released under Creative Commons License</p>

<center><a href="http://jquery.org/license" style="position: absolute; text-decoration:none; color:gray; margin-top:0px; margin-left:-50px; z-index:20;">Jquery-1.5.min.js</a> <p style="margin-top:-20px; padding-left:642px; opacity:0; color:red;">Dual licensed under the MIT or GPL Version 2 licenses</p>

<center><a href="http://jquery.org/license" style="position: absolute; text-decoration:none; color:gray; margin-top:0px; margin-left:-80px; z-index:20;">Jquery-ui-1.8.9.custom.min.js</a><p style="margin-top:-20px; padding-left:642px; opacity:0; color:red;">Dual licensed under the MIT or GPL Version 2 licenses</p>

<center><p style="margin-top:-18px;"><a href="http://sizzlejs.com/" style="position: absolute; text-decoration:none; color:gray; margin-top:-2px; margin-left:-25px; z-index:20;">Sizzle.js</a></center><p style="margin-top:-16px; padding-left:615px; opacity:0; color:red;">Released under the MIT, BSD, and GPL Licenses.</p>
</div>
</div>

Upvotes: 3

Views: 22884

Answers (4)

AbdulAhmad Matin
AbdulAhmad Matin

Reputation: 1146

Also you can use bootstrap tooltips see more here. Bootstrap Tooltips.

$(function () {
  $('[data-toggle="tooltip"]').tooltip()
})
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">

<span data-toggle="tooltip" data-placement="top" title="hover here to see more text. this is bootstrap Tooltip on the top">
  hover here to see more text...
</span>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ho+j7jyWK8fNQe+A12Hb8AhRq26LrZ/JpcUGGOn+Y7RsweNrtN/tE3MoK7ZeZDyx" crossorigin="anonymous"></script>

Upvotes: 0

John
John

Reputation: 7329

Here's something you might find interesting and usable although it's not exactly what you asked for. You can add a title attribute to your element to show text in a sort of tooltip fashion. You'll want to put a span around it if you just want one word.

<p title="Here I am to save the day!">Superman</p>

Fiddle

Upvotes: 7

petebolduc
petebolduc

Reputation: 1263

Jason's css is the best way... just wanted to point out that you are using too much repetative css code and that in is a better practice to NOT use inline css but should have all css on a style sheet and link to it in your head tags.

Your page will load faster. Check out this article: Programming Performance Rules

Upvotes: 1

Jason
Jason

Reputation: 52523

Very easy with CSS. Here's a Fiddle demo.

HTML:

<p>My main text <span class="extra">My hidden text!</span></p>

CSS:

.extra { 
    display: none;
}

p:hover .extra {
    display: inline-block;
}

Upvotes: 12

Related Questions