Advertisement
petar_bonov

admin 3: banner preview

May 25th, 2023
492
0
18 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.52 KB | None | 0 0
  1. <style>
  2. table td:first-child {
  3.     white-space: nowrap;    
  4. }
  5.  
  6. table tr:first-child td {
  7.     writing-mode: vertical-lr;
  8.     transform: rotate(-180deg);
  9.     text-align: left;
  10. }
  11. table tr:first-child td b {
  12.     margin: 5px 2px 0 2px;
  13.     display: inline-block;
  14.     font-weight: normal;
  15.     letter-spacing: 0.1px;
  16. }
  17.  
  18. table .banner-preview {
  19.     display: none;
  20.     position: absolute;
  21.     bottom: 105%;
  22.  
  23.     writing-mode: horizontal-tb;
  24.     transform: rotate(-180deg) translateX(50%);
  25.  
  26.     background: white;
  27.     border: 1px solid #888;
  28.     padding: 5px;
  29. }
  30.  
  31. table .banner-preview span {
  32.     display: inline-block;
  33.     color: black;
  34.     margin-top: 5px;
  35.     font-size: 14px;
  36. }
  37.  
  38. table a:hover .banner-preview {
  39.     display: block;
  40. }
  41. </style>   
  42.  
  43. <script>
  44. const BASE_FOLDER = "https://st.gsmarena.com/imgroot/static/banners/self/";
  45.  
  46. window.addEventListener("DOMContentLoaded", function () {
  47.     const links = document.querySelectorAll("table a");
  48.     for (const link of links) {
  49.         const match = link.innerText.match(/\[[^\]]+\](.+)/);
  50.         if (!match) continue;
  51.  
  52.         const container = document.createElement("div");
  53.         container.classList = "banner-preview";
  54.  
  55.         const image = document.createElement("img");
  56.         image.src = BASE_FOLDER + match[1];
  57.  
  58.         const text = document.createElement("span");
  59.         text.innerText = link.innerText;
  60.  
  61.         container.appendChild(image);
  62.         container.appendChild(text);
  63.         link.appendChild(container);
  64.     }
  65. });
  66. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement