鱼C论坛

 找回密码
 立即注册
查看: 1546|回复: 5

[已解决]网页的自适应显示请求,有偿寻求帮助

[复制链接]
发表于 2024-8-22 23:49:36 | 显示全部楼层 |阅读模式
10鱼币
大家好,

我使用 Bootstrap 开发了一个网页,但遇到的问题是网页无法根据不同电脑的分辨率进行【自适应显示】。
我想有偿寻求帮助解决这个问题,网页里就三个模块,很简约的。如果您在这方面有经验,麻烦加我一下 QQ:1556434735,非常感谢。
本人急需解决这个问题,真心请教,期待您的回复。谢谢!

网址:http://mrdp.net/


最佳答案
2024-8-22 23:49:37
服务器有点不稳定,现在直接上本地的代码,希望大佬看看,谢谢:



  1. 以下是index.html文件中的代码。

  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5.     <meta charset="UTF-8">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Reverse Dictionary</title>
  8.     <style>
  9.         body {
  10.             display: flex;
  11.             flex-direction: column;
  12.             align-items: center;
  13.             justify-content: start;
  14.             height: 100vh;
  15.             margin: 0;
  16.         }
  17.         #title {
  18.             margin-top: 20px;
  19.             text-align: center;
  20.         }
  21.         iframe {
  22.             width: 100%;
  23.             height: 100%;
  24.             border: none;
  25.         }
  26.         h1 {
  27.             font-size: 50px;
  28.         }
  29.     </style>
  30. </head>
  31. <body>
  32.     <div id="title">
  33.         <h1>Mongolian Reverse Dictionary</h1>
  34.     </div>
  35.     <!-- Including search.html using iframe -->
  36.     <iframe src="/search" name="searchFrame"></iframe>
  37. </body>
  38. </html>
复制代码






  1. 以下是search.html文件中的代码:

  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5.     <meta charset="UTF-8">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Mongolian Reverse Dictionary</title>
  8.     <link  rel="stylesheet">
  9.     <link rel="stylesheet" >
  10.     <style>
  11.         @font-face {
  12.             font-family: 'MongolianFont';
  13.             src: url('/static/fonts/MQG8F02.ttf') format('truetype');
  14.         }
  15.         body {
  16.             display: flex;
  17.             flex-direction: column;
  18.             writing-mode: vertical-lr;
  19.             -webkit-writing-mode: vertical-lr;
  20.             -moz-writing-mode: vertical-lr;
  21.             -o-writing-mode: vertical-lr;
  22.             font-family: 'MongolianFont', sans-serif;
  23.         }
  24.         .content-wrapper {
  25.             display: flex;
  26.             flex-direction: row;
  27.             align-items: flex-start;
  28.         }
  29.         .search-container {
  30.             transform: rotate(90deg);
  31.             transform-origin: left top;
  32.             margin-left: 200px;
  33.             margin-top: 15px;
  34.         }
  35.         #search-box {
  36.             writing-mode: horizontal-tb;
  37.             width: 87vh;
  38.             height: 1.5cm;
  39.         }
  40.         #results {
  41.             writing-mode: horizontal-tb;
  42.             margin-top: -65px;
  43.             margin-left: 7.2cm;
  44.             display: flex;
  45.             flex-direction: column;
  46.         }
  47.         .item {
  48.             writing-mode: vertical-lr;
  49.             font-size: 25px;
  50.         }
  51.         .word-box {
  52.             padding: 5px;
  53.         }
  54.         #search-button {
  55.             padding-top: 20px;
  56.             padding-bottom: 20px;
  57.             padding-left: 5px;
  58.             padding-right: 5px;
  59.         }
  60.         .flex-column {
  61.             display: flex;
  62.             flex-direction: column;
  63.         }
  64.         .flex-row {
  65.             display: flex;
  66.             flex-direction: row;
  67.         }
  68.         .item-container {
  69.             display: flex;
  70.             flex-direction: column; /* Adjust direction for vertical alignment */
  71.             align-items: center; /* Center items for consistent appearance */
  72.         }
  73.         .order-number {
  74.             margin-bottom: 5px; /* Space between order number and word box */
  75.             font-size: 25px;
  76.         }
  77.         .word-box {
  78.             /* Styles remain unchanged, ensure it's suitable for vertical text */
  79.             display: inline-block; /* Adjust display to accommodate vertical text */
  80.             padding: 5px;
  81.             writing-mode: vertical-lr; /* Ensure text orientation is vertical */
  82.             flex-grow: 1;
  83.             font-size: 25px;
  84.             cursor: pointer;
  85.         }
  86.         .translation-layer {
  87.             position: absolute;
  88.             display: none;
  89.             background-color: white;
  90.             border: 1px solid #ccc;
  91.             z-index: 1000;
  92.             padding: 10px;
  93.             box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  94.         }
  95.         .translation-box {
  96.             background-color: white;
  97.             padding: 20px;
  98.             writing-mode: horizontal-tb;
  99.             display: flex; /* Ensure it's still a flex container */
  100.             flex-direction: column; /* Stack children vertically */
  101.             justify-content: space-between; /* Space out children */
  102.             height: 100%; /* Ensure it takes full height */
  103.         }
  104.     </style>
  105. </head>
  106. <body>
  107.     <div class="content-wrapper">
  108.         <div class="search-container">
  109.             <input type="text" id="search-box" class="form-control" placeholder="&#6177;&#6199;&#6178;&#6188;&#6182; &#6182;&#6189;&#6177;&#8239;&#6198;&#6178;&#6184;&#8239;&#6178;&#6198;&#6177;&#6184; &#6195;&#6182;&#6199;&#6192;&#6182;&#6191;&#6177;&#6191;&#8239;&#6178; &#6179;&#6199;&#6179;&#6189;&#6180;&#6191;&#6180;&#6189;&#6176;&#6199;&#6176;&#6178;&#6146; &#6177;&#6192;&#6177;&#6186;&#6177;&#6191; &#128269; &#6195;&#6176;&#6199;&#6180;&#6186;&#6196;&#6178;&#8239;&#6198;&#6178; &#6195;&#6176;&#6199;&#6180;&#6197;&#6180; &#6197;&#6178;&#6193;&#6178;&#6198;&#6158;&#6177;&#8239;&#6198;&#6178; &#6182;&#6197;&#6177;&#6189;&#6177;&#6199;&#6177;&#6178;">
  110.             <button class="btn btn-primary" id="search-button">
  111.                 <i class="fa fa-search"></i>
  112.             </button>
  113.         </div>
  114.         <div id="results" class="d-flex flex-column">
  115.             <!-- Predefined columns for results -->
  116.             <div id="column1" class="flex-row"></div>
  117.             <div id="column2" class="flex-row"></div>
  118.             <div id="column3" class="flex-row"></div>
  119.             <div id="column4" class="flex-row"></div>
  120.         </div>
  121.     </div>
  122.     <div id="translation-layer" class="translation-layer">
  123.         <div id="translation-box" class="translation-box"></div>
  124.     </div>
  125.     <!-- Loading Spinner -->
  126.     <div id="loading" style="display: none;">
  127.         <div class="d-flex justify-content-center">
  128.             <div class="spinner-border text-primary" role="status">
  129.                 <span class="sr-only">Loading...</span>
  130.             </div>
  131.         </div>
  132.     </div>
  133.    
  134.     <script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script>
  135.     <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
  136.    
  137.     <script>
  138.         $(document).ready(function(){
  139.             $("#loading").hide();
  140.             if(sessionStorage.getItem('example_index') == undefined) sessionStorage.setItem('example_index', 0);
  141.             else sessionStorage.setItem('example_index', (sessionStorage.getItem('example_index') + 1) % 4);
  142.             // Function to create default items with colors
  143.             function createDefaultItems() {
  144.                 for (var i = 0; i < 100; i++) {
  145.                     var columnIndex = Math.floor(i / 25);
  146.                     var column = $("#column" + (columnIndex + 1));
  147.                     var color = `rgba(0, 90, 255, ${0.5 - i/100 * 0.45})`;
  148.                     var itemStyle = 'background-color: ' + color + ';';
  149.                     
  150.                     var itemContainer = $('<div class="item-container"></div>');
  151.                     itemContainer.append($('<span class="order-number">' + (i + 1) + '. </span>'));
  152.                     var item = $('<span class="word-box" style="' + itemStyle + '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>'); // Empty content
  153.                     itemContainer.append(item);
  154.                     
  155.                     column.append(itemContainer);
  156.                 }
  157.             }

  158.             // Create default items on page load
  159.             createDefaultItems();
  160.             $("#search-button").click(function(){
  161.                 $("#loading").show();
  162.                 var description = $("#search-box").val();
  163.                 let examples = ['&#6194;&#6177;&#6185;&#6188;&#6177;&#6189;&#6177; &#6186;&#6182;&#6188;&#6182;&#6178;&#6146; &#6196;&#6178;&#6195;&#6176;&#6191; &#6194;&#6177;&#6185;&#6188;&#6177;&#6189;&#6177; &#6198;&#6177;&#6188;&#6177;&#6194;&#6177;&#6178;&#6146; &#6186;&#6178;&#6199;&#6158;&#6176; &#6196;&#6178;&#6195;&#6176;&#6191; &#6194;&#6176;&#6178;&#6147;', '&#6192;&#6176;&#6184;&#6176;&#6189;&#6158;&#6176; &#6186;&#6180;&#6195;&#6180;&#6191;&#8239;&#6178; &#6194;&#6176;&#6198;&#6178;&#6195;&#6188;&#6180;&#6199;&#6176;&#6189;&#6180;&#6191;&#6188;&#6180;&#6146; &#6192;&#6177;&#6195;&#6188;&#6178;&#6191; &#6192;&#6176;&#6184;&#6176;&#6189;&#6158;&#6176;&#8239;&#6198;&#6178; &#6176;&#6189;&#6180;&#6197;&#6178;&#6190; &#6186;&#6179;&#6191;&#6189;&#6176;&#6188;&#6180;&#6147;', '&#6180;&#6196;&#6178;&#6199; &#6198;&#6176;&#6186;&#6180;&#6195;&#6176;&#6191;&#8239;&#6180;&#6184; &#6190;&#6176;&#6192;&#6178; &#6186;&#6182;&#6194;&#6182;&#6190;&#6197;&#6178; &#6194;&#6176;&#6178;&#8239;&#6186;&#6176;&#6199; &#6181;&#6189;&#6177;&#6195;&#6177;&#6191;&#6177;&#6184; &#6195;&#6176;&#6186;&#6192;&#6178;&#6188;&#6180;', '&#6192;&#6177;&#6196;&#6177;&#6184; &#6192;&#6177;&#6199;&#6189;&#6182;&#6191;&#6177;&#6185;']
  164.                 if(description == '')
  165.                 {
  166.                     description = examples[sessionStorage.getItem('example_index')];
  167.                     $("#search-box").val(description);
  168.                 }
  169.                 // Clear existing results in each column
  170.                 $("#results .flex-row").empty();
  171.                 $.get("/getWords?description=" + description, function(data){
  172.                     var words = data; // Assuming data is a list of strings
  173.    
  174.                     // Distribute words across columns
  175.                     for (var i = 0; i < words.length; i++) {
  176.                         var columnIndex = Math.floor(i / 25);
  177.                         var column = $("#column" + (columnIndex + 1));
  178.                         var itemNumber = i % 25 + 1;
  179.                         var color = `rgba(0, 90, 255, ${0.5 - i/100 * 0.45})`;
  180.                         var itemStyle = 'background-color: ' + color + ';';
  181.                         
  182.                         var itemContainer = $('<div class="item-container"></div>');
  183.                         itemContainer.append($('<span class="order-number">' + (i + 1) + '. </span>'));
  184.                         var item = $('<span class="word-box" style="' + itemStyle + '">' + words[i] + '</span>');
  185.                         itemContainer.append(item);
  186.                         
  187.                         column.append(itemContainer);
  188.                     }
  189.                     $("#loading").hide();
  190.                 });
  191.             });

  192.             $(document).click(function(event) {
  193.                 if (!$(event.target).closest('.translation-layer, .word-box').length) {
  194.                     $('#translation-layer').hide();
  195.                 }
  196.             });

  197.             function getTranslations(word, position) {
  198.                 $.get('/getTranslations?word=' + word, function(response) {
  199.                     if (response.result === 'success') {
  200.                         const groupedTranslations = {};
  201.                         var translationsHtml = '';
  202.                         // 遍历所有翻译,并按origin分组
  203.                         Object.keys(response).forEach(key => {
  204.                             if (key !== "result") {
  205.                                 translationsHtml += '<div style="flex-grow: 1;">'; // Flex container for translations
  206.                                 response[key].forEach((translation, index) => {
  207.                                     translationsHtml += (index + 1) + '. ' + translation + '<br>';
  208.                                 });
  209.                                 translationsHtml += '</div><div style="text-align: right;"><u>' + key + '</u></div>'; // New div for origin, aligned right
  210.                             }
  211.                         });
  212.                         var $translationLayer = $('#translation-layer');
  213.                         $translationLayer.html(translationsHtml)
  214.                                         .css({
  215.                                             'left': position.left + position.width + 10 + 'px',
  216.                                             'top': position.top + 'px'
  217.                                         })
  218.                                         .show();
  219.                     }
  220.                 });
  221.             }

  222.             $('#results').on('click', '.word-box', function() {
  223.                 var word = $(this).text().trim();
  224.                 var wordPosition = $(this).offset();
  225.                 wordPosition.width = $(this).width(); // Add width to the position object
  226.                 getTranslations(word, wordPosition);
  227.             });

  228.         });
  229.     </script>
  230.    
  231. </body>
  232. </html>

复制代码

最佳答案

查看完整内容

服务器有点不稳定,现在直接上本地的代码,希望大佬看看,谢谢:
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2024-8-22 23:49:37 | 显示全部楼层    本楼为最佳答案   
服务器有点不稳定,现在直接上本地的代码,希望大佬看看,谢谢:



  1. 以下是index.html文件中的代码。

  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5.     <meta charset="UTF-8">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Reverse Dictionary</title>
  8.     <style>
  9.         body {
  10.             display: flex;
  11.             flex-direction: column;
  12.             align-items: center;
  13.             justify-content: start;
  14.             height: 100vh;
  15.             margin: 0;
  16.         }
  17.         #title {
  18.             margin-top: 20px;
  19.             text-align: center;
  20.         }
  21.         iframe {
  22.             width: 100%;
  23.             height: 100%;
  24.             border: none;
  25.         }
  26.         h1 {
  27.             font-size: 50px;
  28.         }
  29.     </style>
  30. </head>
  31. <body>
  32.     <div id="title">
  33.         <h1>Mongolian Reverse Dictionary</h1>
  34.     </div>
  35.     <!-- Including search.html using iframe -->
  36.     <iframe src="/search" name="searchFrame"></iframe>
  37. </body>
  38. </html>
复制代码






  1. 以下是search.html文件中的代码:

  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5.     <meta charset="UTF-8">
  6.     <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7.     <title>Mongolian Reverse Dictionary</title>
  8.     <link  rel="stylesheet">
  9.     <link rel="stylesheet" >
  10.     <style>
  11.         @font-face {
  12.             font-family: 'MongolianFont';
  13.             src: url('/static/fonts/MQG8F02.ttf') format('truetype');
  14.         }
  15.         body {
  16.             display: flex;
  17.             flex-direction: column;
  18.             writing-mode: vertical-lr;
  19.             -webkit-writing-mode: vertical-lr;
  20.             -moz-writing-mode: vertical-lr;
  21.             -o-writing-mode: vertical-lr;
  22.             font-family: 'MongolianFont', sans-serif;
  23.         }
  24.         .content-wrapper {
  25.             display: flex;
  26.             flex-direction: row;
  27.             align-items: flex-start;
  28.         }
  29.         .search-container {
  30.             transform: rotate(90deg);
  31.             transform-origin: left top;
  32.             margin-left: 200px;
  33.             margin-top: 15px;
  34.         }
  35.         #search-box {
  36.             writing-mode: horizontal-tb;
  37.             width: 87vh;
  38.             height: 1.5cm;
  39.         }
  40.         #results {
  41.             writing-mode: horizontal-tb;
  42.             margin-top: -65px;
  43.             margin-left: 7.2cm;
  44.             display: flex;
  45.             flex-direction: column;
  46.         }
  47.         .item {
  48.             writing-mode: vertical-lr;
  49.             font-size: 25px;
  50.         }
  51.         .word-box {
  52.             padding: 5px;
  53.         }
  54.         #search-button {
  55.             padding-top: 20px;
  56.             padding-bottom: 20px;
  57.             padding-left: 5px;
  58.             padding-right: 5px;
  59.         }
  60.         .flex-column {
  61.             display: flex;
  62.             flex-direction: column;
  63.         }
  64.         .flex-row {
  65.             display: flex;
  66.             flex-direction: row;
  67.         }
  68.         .item-container {
  69.             display: flex;
  70.             flex-direction: column; /* Adjust direction for vertical alignment */
  71.             align-items: center; /* Center items for consistent appearance */
  72.         }
  73.         .order-number {
  74.             margin-bottom: 5px; /* Space between order number and word box */
  75.             font-size: 25px;
  76.         }
  77.         .word-box {
  78.             /* Styles remain unchanged, ensure it's suitable for vertical text */
  79.             display: inline-block; /* Adjust display to accommodate vertical text */
  80.             padding: 5px;
  81.             writing-mode: vertical-lr; /* Ensure text orientation is vertical */
  82.             flex-grow: 1;
  83.             font-size: 25px;
  84.             cursor: pointer;
  85.         }
  86.         .translation-layer {
  87.             position: absolute;
  88.             display: none;
  89.             background-color: white;
  90.             border: 1px solid #ccc;
  91.             z-index: 1000;
  92.             padding: 10px;
  93.             box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  94.         }
  95.         .translation-box {
  96.             background-color: white;
  97.             padding: 20px;
  98.             writing-mode: horizontal-tb;
  99.             display: flex; /* Ensure it's still a flex container */
  100.             flex-direction: column; /* Stack children vertically */
  101.             justify-content: space-between; /* Space out children */
  102.             height: 100%; /* Ensure it takes full height */
  103.         }
  104.     </style>
  105. </head>
  106. <body>
  107.     <div class="content-wrapper">
  108.         <div class="search-container">
  109.             <input type="text" id="search-box" class="form-control" placeholder="&#6177;&#6199;&#6178;&#6188;&#6182; &#6182;&#6189;&#6177;&#8239;&#6198;&#6178;&#6184;&#8239;&#6178;&#6198;&#6177;&#6184; &#6195;&#6182;&#6199;&#6192;&#6182;&#6191;&#6177;&#6191;&#8239;&#6178; &#6179;&#6199;&#6179;&#6189;&#6180;&#6191;&#6180;&#6189;&#6176;&#6199;&#6176;&#6178;&#6146; &#6177;&#6192;&#6177;&#6186;&#6177;&#6191; &#128269; &#6195;&#6176;&#6199;&#6180;&#6186;&#6196;&#6178;&#8239;&#6198;&#6178; &#6195;&#6176;&#6199;&#6180;&#6197;&#6180; &#6197;&#6178;&#6193;&#6178;&#6198;&#6158;&#6177;&#8239;&#6198;&#6178; &#6182;&#6197;&#6177;&#6189;&#6177;&#6199;&#6177;&#6178;">
  110.             <button class="btn btn-primary" id="search-button">
  111.                 <i class="fa fa-search"></i>
  112.             </button>
  113.         </div>
  114.         <div id="results" class="d-flex flex-column">
  115.             <!-- Predefined columns for results -->
  116.             <div id="column1" class="flex-row"></div>
  117.             <div id="column2" class="flex-row"></div>
  118.             <div id="column3" class="flex-row"></div>
  119.             <div id="column4" class="flex-row"></div>
  120.         </div>
  121.     </div>
  122.     <div id="translation-layer" class="translation-layer">
  123.         <div id="translation-box" class="translation-box"></div>
  124.     </div>
  125.     <!-- Loading Spinner -->
  126.     <div id="loading" style="display: none;">
  127.         <div class="d-flex justify-content-center">
  128.             <div class="spinner-border text-primary" role="status">
  129.                 <span class="sr-only">Loading...</span>
  130.             </div>
  131.         </div>
  132.     </div>
  133.    
  134.     <script src="https://cdn.staticfile.org/jquery/3.6.0/jquery.min.js"></script>
  135.     <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
  136.    
  137.     <script>
  138.         $(document).ready(function(){
  139.             $("#loading").hide();
  140.             if(sessionStorage.getItem('example_index') == undefined) sessionStorage.setItem('example_index', 0);
  141.             else sessionStorage.setItem('example_index', (sessionStorage.getItem('example_index') + 1) % 4);
  142.             // Function to create default items with colors
  143.             function createDefaultItems() {
  144.                 for (var i = 0; i < 100; i++) {
  145.                     var columnIndex = Math.floor(i / 25);
  146.                     var column = $("#column" + (columnIndex + 1));
  147.                     var color = `rgba(0, 90, 255, ${0.5 - i/100 * 0.45})`;
  148.                     var itemStyle = 'background-color: ' + color + ';';
  149.                     
  150.                     var itemContainer = $('<div class="item-container"></div>');
  151.                     itemContainer.append($('<span class="order-number">' + (i + 1) + '. </span>'));
  152.                     var item = $('<span class="word-box" style="' + itemStyle + '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>'); // Empty content
  153.                     itemContainer.append(item);
  154.                     
  155.                     column.append(itemContainer);
  156.                 }
  157.             }

  158.             // Create default items on page load
  159.             createDefaultItems();
  160.             $("#search-button").click(function(){
  161.                 $("#loading").show();
  162.                 var description = $("#search-box").val();
  163.                 let examples = ['&#6194;&#6177;&#6185;&#6188;&#6177;&#6189;&#6177; &#6186;&#6182;&#6188;&#6182;&#6178;&#6146; &#6196;&#6178;&#6195;&#6176;&#6191; &#6194;&#6177;&#6185;&#6188;&#6177;&#6189;&#6177; &#6198;&#6177;&#6188;&#6177;&#6194;&#6177;&#6178;&#6146; &#6186;&#6178;&#6199;&#6158;&#6176; &#6196;&#6178;&#6195;&#6176;&#6191; &#6194;&#6176;&#6178;&#6147;', '&#6192;&#6176;&#6184;&#6176;&#6189;&#6158;&#6176; &#6186;&#6180;&#6195;&#6180;&#6191;&#8239;&#6178; &#6194;&#6176;&#6198;&#6178;&#6195;&#6188;&#6180;&#6199;&#6176;&#6189;&#6180;&#6191;&#6188;&#6180;&#6146; &#6192;&#6177;&#6195;&#6188;&#6178;&#6191; &#6192;&#6176;&#6184;&#6176;&#6189;&#6158;&#6176;&#8239;&#6198;&#6178; &#6176;&#6189;&#6180;&#6197;&#6178;&#6190; &#6186;&#6179;&#6191;&#6189;&#6176;&#6188;&#6180;&#6147;', '&#6180;&#6196;&#6178;&#6199; &#6198;&#6176;&#6186;&#6180;&#6195;&#6176;&#6191;&#8239;&#6180;&#6184; &#6190;&#6176;&#6192;&#6178; &#6186;&#6182;&#6194;&#6182;&#6190;&#6197;&#6178; &#6194;&#6176;&#6178;&#8239;&#6186;&#6176;&#6199; &#6181;&#6189;&#6177;&#6195;&#6177;&#6191;&#6177;&#6184; &#6195;&#6176;&#6186;&#6192;&#6178;&#6188;&#6180;', '&#6192;&#6177;&#6196;&#6177;&#6184; &#6192;&#6177;&#6199;&#6189;&#6182;&#6191;&#6177;&#6185;']
  164.                 if(description == '')
  165.                 {
  166.                     description = examples[sessionStorage.getItem('example_index')];
  167.                     $("#search-box").val(description);
  168.                 }
  169.                 // Clear existing results in each column
  170.                 $("#results .flex-row").empty();
  171.                 $.get("/getWords?description=" + description, function(data){
  172.                     var words = data; // Assuming data is a list of strings
  173.    
  174.                     // Distribute words across columns
  175.                     for (var i = 0; i < words.length; i++) {
  176.                         var columnIndex = Math.floor(i / 25);
  177.                         var column = $("#column" + (columnIndex + 1));
  178.                         var itemNumber = i % 25 + 1;
  179.                         var color = `rgba(0, 90, 255, ${0.5 - i/100 * 0.45})`;
  180.                         var itemStyle = 'background-color: ' + color + ';';
  181.                         
  182.                         var itemContainer = $('<div class="item-container"></div>');
  183.                         itemContainer.append($('<span class="order-number">' + (i + 1) + '. </span>'));
  184.                         var item = $('<span class="word-box" style="' + itemStyle + '">' + words[i] + '</span>');
  185.                         itemContainer.append(item);
  186.                         
  187.                         column.append(itemContainer);
  188.                     }
  189.                     $("#loading").hide();
  190.                 });
  191.             });

  192.             $(document).click(function(event) {
  193.                 if (!$(event.target).closest('.translation-layer, .word-box').length) {
  194.                     $('#translation-layer').hide();
  195.                 }
  196.             });

  197.             function getTranslations(word, position) {
  198.                 $.get('/getTranslations?word=' + word, function(response) {
  199.                     if (response.result === 'success') {
  200.                         const groupedTranslations = {};
  201.                         var translationsHtml = '';
  202.                         // 遍历所有翻译,并按origin分组
  203.                         Object.keys(response).forEach(key => {
  204.                             if (key !== "result") {
  205.                                 translationsHtml += '<div style="flex-grow: 1;">'; // Flex container for translations
  206.                                 response[key].forEach((translation, index) => {
  207.                                     translationsHtml += (index + 1) + '. ' + translation + '<br>';
  208.                                 });
  209.                                 translationsHtml += '</div><div style="text-align: right;"><u>' + key + '</u></div>'; // New div for origin, aligned right
  210.                             }
  211.                         });
  212.                         var $translationLayer = $('#translation-layer');
  213.                         $translationLayer.html(translationsHtml)
  214.                                         .css({
  215.                                             'left': position.left + position.width + 10 + 'px',
  216.                                             'top': position.top + 'px'
  217.                                         })
  218.                                         .show();
  219.                     }
  220.                 });
  221.             }

  222.             $('#results').on('click', '.word-box', function() {
  223.                 var word = $(this).text().trim();
  224.                 var wordPosition = $(this).offset();
  225.                 wordPosition.width = $(this).width(); // Add width to the position object
  226.                 getTranslations(word, wordPosition);
  227.             });

  228.         });
  229.     </script>
  230.    
  231. </body>
  232. </html>

复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2024-8-22 23:49:51 | 显示全部楼层
您好,鱼油!根据您的描述,网页无法根据不同分辨率进行自适应显示,可能是某些自适应设计的基础规则没有正确应用。

对于这种情况,可以从以下几个方面入手进行排查:

1. **确保引入了正确的 Bootstrap 样式文件**:
  
  1. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
复制代码


2. **在 `<head>` 部分添加视口元标签**,确保正确缩放:
  
  1. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
复制代码


3. **使用 Bootstrap 的栅格系统** 来布局模块,确保不同分辨率下能够灵活调整:
  
  1. <div class="container">
  2.        <div class="row">
  3.            <div class="col-md-4">模块1</div>
  4.            <div class="col-md-4">模块2</div>
  5.            <div class="col-md-4">模块3</div>
  6.        </div>
  7.    </div>
复制代码


4. **检查自定义样式**,有时自定义的 CSS 会覆盖 Bootstrap 的样式,造成自适应问题。

如果这些方法依旧无法解决问题,您可以通过 QQ 联系合适的技术人员获取详细的帮助。希望这些建议对您有帮助!如有其他问题,欢迎继续提问。

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2024-8-23 12:04:13 | 显示全部楼层
Amgalang 发表于 2024-08-23 12:04
服务器有点不稳定,现在直接上本地的代码,希望大佬看 ...


您好,鱼油。根据您的代码,以下是一些基本建议,确保您的网页在不同分辨率下自适应:

1. **使用Bootstrap的栅格系统**:
   在您的`index.html`和`search.html`中,可以使用Bootstrap的栅格系统来确保元素在不同设备上有良好的布局。

例如,替换您的HTML中的某部分代码如下:
```html
<div class="container">
    <div class="row">
        <div class="col-md-4">
            <!-- Your content here -->
        </div>

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2024-8-23 17:27:18 | 显示全部楼层
写个全集化自适应CSS样式嵌入
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2024-8-24 08:58:57 | 显示全部楼层
feiyu999 发表于 2024-8-23 17:27
写个全集化自适应CSS样式嵌入

好的,谢谢您
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-5-13 21:33

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表