Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [Java][CSS]tooltip w tabeli
Forum PHP.pl > Forum > Przedszkole
mazyl
Witam!

mam spory problem z umieszczeniem tooltipa na stronie,

cały kod tooltipa wygląda tak:


  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Simple JQuery Tooltips turtorial</title>
  5.  
  6. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
  7. <script type="text/javascript">
  8.  
  9. $(document).ready(function() {
  10.  
  11. //Select all anchor tag with rel set to tooltip
  12. $('a[rel=tooltip]').mouseover(function(e) {
  13.  
  14. //Grab the title attribute's value and assign it to a variable
  15. var tip = $(this).attr('title');
  16.  
  17. //Remove the title attribute's to avoid the native tooltip from the browser
  18. $(this).attr('title','');
  19.  
  20. //Append the tooltip template and its value
  21. $(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');
  22.  
  23. //Set the X and Y axis of the tooltip
  24. $('#tooltip').css('top', e.pageY + 10 );
  25. $('#tooltip').css('left', e.pageX + 20 );
  26.  
  27. //Show the tooltip with faceIn effect
  28. $('#tooltip').fadeIn('500');
  29. $('#tooltip').fadeTo('10',0.8);
  30.  
  31. }).mousemove(function(e) {
  32.  
  33. //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
  34. $('#tooltip').css('top', e.pageY + 10 );
  35. $('#tooltip').css('left', e.pageX + 20 );
  36.  
  37. }).mouseout(function() {
  38.  
  39. //Put back the title attribute's value
  40. $(this).attr('title',$('.tipBody').html());
  41.  
  42. //Remove the appended tooltip template
  43. $(this).children('div#tooltip').remove();
  44.  
  45. });
  46.  
  47. });
  48.  
  49. </script>
  50.  
  51. <style>
  52. body {font-family:arial;font-size:12px;text-align:center;}
  53. div#paragraph {width:300px;margin:0 auto;text-align:left}
  54. a {color:#aaa;text-decoration:none;cursor:pointer;cursor:hand}
  55. a:hover {color:#000;text-decoration:none;}
  56.  
  57. /* Tooltip */
  58.  
  59. #tooltip {
  60. position:absolute;
  61. z-index:9999;
  62. color:#fff;
  63. font-size:10px;
  64. width:180px;
  65.  
  66. }
  67.  
  68. #tooltip .tipHeader {
  69. height:8px;
  70. background:url(images/tipHeader.gif) no-repeat;
  71. }
  72.  
  73. /* IE hack */
  74. *html #tooltip .tipHeader {margin-bottom:-6px;}
  75.  
  76. #tooltip .tipBody {
  77. background-color:#000;
  78. padding:5px;
  79. }
  80.  
  81. #tooltip .tipFooter {
  82. height:8px;
  83. background:url(images/tipFooter.gif) no-repeat;
  84. }
  85.  
  86. </style>
  87.  
  88. </head>
  89.  
  90. <body>
  91.  
  92. <div id="paragraph">
  93. A paragraph typically consists of a unifying main point, thought, or idea accompanied by supporting details. The non-fiction paragraph usually begins with the general and moves towards the more specific so as to advance an argument or point of view. Each <a rel="tooltip" title="A paragraph typically consists of a unifying main point, thought, or idea accompanied by <b>supporting details</b>">paragraph</a> builds on what came before and lays the ground for what comes next. Paragraphs generally range three to seven sentences all combined in a single paragraphed statement. In prose fiction successive details, for example; but it is just as common for the point of a prose paragraph to occur in the middle or the end. A paragraph can be as short as one word or run the length of multiple pages, and may consist of one or many <a rel="tooltip" title="Testing of Sentences">sentences</a>. When dialogue is being quoted in fiction, a new paragraph is used each time the person being quoted changed.
  94. </div>
  95.  
  96. </body>
  97. </html>


chiałbym to umiescic w tabeli, która dane pobiera z mysql

całość wygląda tak:

  1. <td><div id="paragraph"><a rel="tooltip" title="Wiek: <?php echo $p['wiek']; ?> <br>Wykształcenie: <?php echo $wyk['wyksztalcenie']; ?>"><?php echo $p['nazwisko']; ?>
  2. </a></div>
  3. </td>


jednak tooltip wyświetla się całkowicie na dole strony, im niższy rekord z tabeli tym coraz niżej, po klilku tooltip całkowicie zanika.

wie ktoś jak to naprawić ?
Tuminure
Po podmienieniu Twoim tekstem tego co jest w body, tooltip działa poprawnie. Prawdopodobnie namieszałeś coś w swoim CSSie.
mazyl
probowałem na wszelkie możliwe sposoby i niestety nie działa.


gotowy kod działa w 100% ale przy wstawieniu go do tabeli tooltip wyświetla sie na dole strony.
Tuminure
Najprościej by było, gdybyś pokazał cały plik z próbą implementacji tego skryptu.
mazyl
góra strony gdzie znajduje się skrypt:

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <link href="style.css" rel="stylesheet" type="text/css" />
  6. <script src="js/jq.js" type="text/javascript"></script>
  7. <link rel="stylesheet" href="css/nivo-slider.css" type="text/css" media="screen" />
  8. <script type="text/javascript" src="js/jquery.nivo.slider.js"></script>
  9. <script src="js//jquery.js" type="text/javascript"></script>
  10. <script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
  11.  
  12. <script type="text/javascript">
  13.  
  14.  
  15.  
  16. $(document).ready(function() {
  17.  
  18.  
  19.  
  20. //Select all anchor tag with rel set to tooltip
  21.  
  22. $('td[rel=tooltip]').mouseover(function(e) {
  23.  
  24.  
  25.  
  26. //Grab the title attribute's value and assign it to a variable
  27.  
  28. var tip = $(this).attr('title');
  29.  
  30.  
  31.  
  32. //Remove the title attribute's to avoid the native tooltip from the browser
  33.  
  34. $(this).attr('title','');
  35.  
  36.  
  37.  
  38. //Append the tooltip template and its value
  39.  
  40. $(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');
  41.  
  42.  
  43.  
  44. //Set the X and Y axis of the tooltip
  45.  
  46. $('#tooltip').css('top', e.pageY + 10 );
  47.  
  48. $('#tooltip').css('left', e.pageX + 20 );
  49.  
  50.  
  51.  
  52. //Show the tooltip with faceIn effect
  53.  
  54. $('#tooltip').fadeIn('500');
  55.  
  56. $('#tooltip').fadeTo('10',0.8);
  57.  
  58.  
  59.  
  60. }).mousemove(function(e) {
  61.  
  62.  
  63.  
  64. //Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
  65.  
  66. $('#tooltip').css('top', e.pageY + 10 );
  67.  
  68. $('#tooltip').css('left', e.pageX + 20 );
  69.  
  70.  
  71.  
  72. }).mouseout(function() {
  73.  
  74.  
  75.  
  76. //Put back the title attribute's value
  77.  
  78. $(this).attr('title',$('.tipBody').html());
  79.  
  80.  
  81.  
  82. //Remove the appended tooltip template
  83.  
  84. $(this).children('div#tooltip').remove();
  85.  
  86.  
  87.  
  88. });
  89.  
  90.  
  91.  
  92. });
  93.  
  94.  
  95.  
  96. </script>
  97. <title>Tytuł Twojej strony</title>
  98.  
  99. </head>
  100.  
  101. <body>
  102. <div id="pojemnik">
  103. <div id="logo">
  104. </div>
  105. <div id="header">



plik w którym się znajduje tabela:

  1. <?php
  2. //włączamy bufor
  3.  
  4. //pobieramy zawartość pliku ustawień
  5. require_once('var/ustawienia.php');
  6.  
  7. //startujemy lub przedłużamy sesję
  8.  
  9. //dołączamy plik, który sprawdzi czy napewno mamy dostęp do tej strony
  10. require_once('test_zalogowanego.php');
  11.  
  12. //pobieramy nagłówek strony
  13. require_once('gora_strony.php');
  14.  
  15. //pobieramy zawartość menu
  16. require_once('menu.php');
  17.  
  18.  
  19. echo "<h2>Lista Ofert Pracy: </h2><div id='lefter'>";
  20. $_GET['zatrudnij'] = (int)$_GET['zatrudnij'];
  21.  
  22. if(!empty($_GET['zatrudnij']) && isset($_GET['pracownik'])){
  23. $wyplata = mysql_fetch_array(mysql_query("select zarobki from pracownicy where md5(id) = '".$_GET['pracownik']."'"));
  24. $fir = mysql_fetch_array(mysql_query("select id, gracz, rozbudowa, pracownicymax from firmy where id = '".$_GET['zatrudnij']."'"));
  25. $ilupracuje = mysql_num_rows(mysql_query("select id from pracownicy where firma = '".$fir['id']."'"));
  26. if($_GET['zatrudnij'] < 1){
  27. echo "<p class='error'>Nie ma takiej firmy</p><br class='clear'>";
  28. } elseif($uzytkownik['gracz'] != $fir['gracz']) {
  29. echo "<p class='error'>Ta Firma nie nalezy do ciebie</p><br class='clear'>";
  30. } elseif($wyplata['zarobki'] > $uzytkownik['kasa']) {
  31. echo "<p class='error'>Nie posiadasz wystarczajaco pieniędzy by zatrudnić tego pracownika</p><br class='clear'>";
  32. } elseif($fir['pracownicymax'] <= $ilupracuje) {
  33. echo "<p class='error'>Twoja Firma osiagnęła Maksymalną liczbę pracowników</p><br class='clear'>";
  34. } elseif(empty($_GET['pracownik'])){
  35. echo "<p class='error'>Nie wybrano pracownika</p><br class='clear'>";
  36. } else {
  37.  
  38. mysql_query("update pracownicy set firma = '".$_GET['zatrudnij']."' where md5(id) = '".$_GET['pracownik']."'");
  39. mysql_query("update economy_gracze set kasa = kasa - '".$wyplata['zarobki']."' where gracz = '".$uzytkownik['gracz']."'");
  40. if(mysql_affected_rows() == 0){
  41. echo "<p class='error'>Błędne dane</p><br class='clear'>";
  42. } else {
  43. echo "<p class='note'>Zatrudniono Pracownika</p><br class='clear'>";
  44. }
  45. }
  46. }
  47. function skroc($tekst,$ile) {
  48. $znaki = strlen($tekst);
  49. if ($znaki>=$ile) {
  50. $tnij = substr($tekst,0,$ile);
  51. $skrocone = $tnij."...";
  52. }
  53. else {
  54. $skrocone = $tekst;
  55. }
  56. return $skrocone;
  57. }
  58. ?>
  59. <style>
  60. /* Tooltip */
  61. #tooltip {
  62. position:absolute;
  63. z-index:9999;
  64. color:#fff;
  65. font-size:10px;
  66. width:180px;
  67. }
  68. #tooltip .tipHeader {
  69. height:8px;
  70. background:url(images/tipHeader.gif) no-repeat;
  71. }
  72. /* IE hack */
  73.  
  74. *html #tooltip .tipHeader {margin-bottom:-6px;}
  75. #tooltip .tipBody {
  76. background-color:#000;
  77. padding:5px;
  78. }
  79. #tooltip .tipFooter {
  80. height:8px;
  81. background:url(images/tipFooter.gif) no-repeat;
  82. }
  83. </style>
  84. <div id="paragraph">
  85. <table><tr>
  86. <td>Lp.</td>
  87. <td>Imie i nazwisko</td>
  88.  
  89. <td>Typ</td>
  90. <td>Wyd.</td>
  91. <td>Wyplata/dzień</td>
  92. <td width='200px' >Akcja</td>
  93. </tr>
  94.  
  95. <?php
  96. $i = 1;
  97. $pracownicy = mysql_query("select * from pracownicy where firma = 0 order by zarobki asc");
  98. while($p = mysql_fetch_array($pracownicy)) {
  99.  
  100. $typ =mysql_fetch_array(mysql_query("select * from typyfirm where id = '".$p['typ']."'"));
  101. $wyk =mysql_fetch_array(mysql_query("select * from wyksztalcenie where id = '".$p['wyksztalcenie']."'"));
  102. ?>
  103. <tr>
  104. <td><?php echo $i++; ?> </td>
  105. <td rel="tooltip" title="Wiek: <?php echo $p['wiek']; ?> <br>Wykształcenie: <?php echo $wyk['wyksztalcenie']; ?>"><?php echo $p['nazwisko']; ?>
  106. </td>
  107. <td><?php echo $typ['typ']; ?> </td>
  108. <td><?php echo $p['wydajnosc']; ?> </td>
  109. <td><?php echo $p['zarobki']; echo $waluta;?> </td>
  110. <td><?php
  111. $zatrudnij = mysql_query("select id, nazwa from firmy where gracz = '".$uzytkownik['gracz']."'");
  112. while($z = mysql_fetch_array($zatrudnij)) {
  113. $nazwa = skroc ($z['nazwa'],15);
  114. echo "<br><a href='oferty_pracy.php?zatrudnij=".$z['id']."&pracownik=".md5($p['id'])."'>Zatrudnij do ".$nazwa."</a>";
  115. }
  116. ?></td>
  117. </tr>
  118.  
  119. <?php
  120. }
  121.  
  122. echo "</table></div>";
  123.  
  124.  
  125.  
  126.  
  127. //pobieramy zawartość prawego bloku
  128. require_once('prawy_blok.php');
  129.  
  130. //pobieramy stopkę
  131. require_once('dol_strony.php');
  132.  
  133. //wyłączamy bufor
  134. ?>


wie ktoś jak rozwiązać ten problem?
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.