Создание всплывающей подсказки CSS за пределами родительских границ - PullRequest
0 голосов
/ 17 апреля 2019

У меня есть требование для иконки со стилизованной всплывающей подсказкой в ​​пределах <thead> из table.По сути, моя всплывающая подсказка появляется, как и должна, когда пользователь наводит курсор на значок, однако нижняя половина текста подсказки находится под данными <tbody>.

Я вполне уверен, что моя проблема основана исключительно на css и не имеет никакого отношения к тому факту, что таблица имеет стиль DataTables.z-index, похоже, не является проблемой, так как я пытался играть с этим безуспешно.Я думаю, это то, что всплывающая подсказка не хочет, чтобы ее можно было отображать за пределами родительского элемента <thead>, поскольку она запускается в <thead>.

. Я создал TryIt Editor , отображающийпроблема, здесь .

И, поскольку я не знаю, как долго действуют эти TryIt Editor URL-адреса (я полагаю, не навсегда), я также привожу некоторый примеркод, здесь:

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Hover Over Issue Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js" type="text/javascript"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" type="text/javascript"></script>
  <script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" type="text/javascript"></script>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/jquery.dataTables.min.css">
  <script>
    $(document).ready(function() {
        $('#styledtable').DataTable({
            "destroy" : true,
            "scrollY" : 300,
            "scrollCollapse" : true,
            "paging" : true,
            "autoWidth" : true,
            "ordering" : true,
            "searching" : false,
            "order" : [ [ 0, 'asc' ] ],
            "pageLength" : 20,
            "lengthChange" : false,
            "pagingType" : "full_numbers",
            "dom" : '<"top"ip>rt<"bottom"fl><"clear">'
        });
    });
   </script>

   <style>
      .mySpecialTooltip {
            position: relative;
            display: inline-block;
            float: right; 
            top: 0px; 
            right: 0px; 
            cursor: pointer;
      }

      .mySpecialTooltip span {
          visibility: hidden;
          width: 200px;
          background-color: black;
          color: white;
          text-align: left;
          padding: 5px 5px;
          border-radius: 6px;
          white-space: normal;
          font-weight: normal;
          font-size: 12px;
          position: absolute;
          z-index: 2;
          top: 100%;
          left: 50%;
          margin-left: -200px;
      }

      .mySpecialTooltip:hover span {
          visibility: visible;
      }
   </style>
</head>
<body>

<div class="container">
  <h2>Hover Over Issue Example</h2>
  <p>I need the hover overs on the top right column icons to show up entirely. Hover over the <b>small orange exclamation mark icon</b> which looks like <img src="https://cdn3.iconfinder.com/data/icons/tiny-icons/warning.png"/> above the <b>email</b> header for an example of the problem.</p>            
  <table class="table" id="styledtable">
    <thead>
      <tr>
        <th style="border: 0px; !important"></th>
        <th style="border: 0px; !important"></th>
        <th style="border: 0px; !important">
          <div class="mySpecialTooltip">
            <img src="https://cdn3.iconfinder.com/data/icons/tiny-icons/warning.png" style="cursor: pointer;"/>
                <span>
                    This is some hover over text. It can be long - long enough that it needs to be able to 
                    float over the data in the top rops of the table. So I will just keep typing to ensure
                    that this box is very long. This is probably long enough.
                </span>
          </div>
        </th>
      </tr>
      <tr>
        <th>Firstname</th>
        <th>Lastname</th>
        <th>Email</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>john@example.com</td>
      </tr>
      <tr>
        <td>Mary</td>
        <td>Moe</td>
        <td>mary@example.com</td>
      </tr>
      <tr>
        <td>July</td>
        <td>Dooley</td>
        <td>july@example.com</td>
      </tr>
    </tbody>
  </table>
</div>

</body>
</html>

Любая помощь будет принята с благодарностью!

1 Ответ

3 голосов
/ 17 апреля 2019

Похоже, это действительно имеет отношение к Datatables.

element.style на class="dataTables_scrollHead" имеет overflow: hidden.Если вы удалите это, у вас будет ожидаемая функциональность.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...