我正在提取已保存在我们的数据库中的项目"Results.ItemPicture、Results.ItemLink等."并使用带有JJ的for循环在页面上显示它们,并且想要将它们打印在页面上的列中.到目前为止,它们只是被放在彼此的顶部.我该如何着手做这件事呢?

    <div class =header>&nbsp;</div>
        <div class="app">
            <main class="content">
                <form action="/getItem" method="get" class="input-wrapper">
                    <button type="submit" class="fa fa-search"></button>
                    <input type="text" class="input-wrapper-text" style="color:white;" placeholder="Search" name="q">
                </form>


                    <div style = "position: absolute; top: 175px; left: 47%;">
                        <h2>
                            Add Items
                        </h2>
                    </div>
                    <div style = "position: absolute; top: 250px; left: 10%;">
                        <h1>
                            Catalog
                        </h1>
                    </div>
                <div style="width: 3000px; margin: 10px 0px;">
                    <hr size="10">
                </div>

                    <% for (var i=0; i<results.length; i++) {%>
                        <div style = "display: block;">
                            <div style = "display: inline-block; vertical-align: top;" class = "ebayImage">
                                <a href = "#" class = "ebayImage" onclick="javascript:location.href='<%= results[i].ItemLink%>';" id="itemButton">
                                <img src= "<%=  results[i].ItemPicture %>" style="width:250px; height: auto; border: 1px solid #cacaca;" alt="redirects to original eBay listing">
                                </a>
                            </div>
    
                        <div style = "display: inline-block; vertical-align: top;" class = "ebayInfo">
                            <a href = '<%=results[i].ItemLink%>' style = 'width: auto; margin-left: 20px; color:black;'><h3><u><%= results[i].ItemName%></u></h3></a>
                            <p>&nbsp;</p>
                            <p style="justify-content: space-between; width: auto; margin-bottom: 10px; margin-left: 20px; color: #5b619b; font-weight: bold;"> Points: <%= results[i].ItemPrice%></p>  
                            <p><button type="button" style="background-color: rgb(128, 0, 0);" id="newCatItem" onclick="deleteFromCat()">Remove Item</button></p>
                        </div>
                    </div>  

enter image description here

推荐答案

只需删除所有匹配的样式: 位置:绝对;

该属性使项目彼此重叠,在这种情况下,您可能不需要绝对定位它们.

如果有一个具体的设计,你想遵循提供一个描述,我可以创建一个很好的HTML示例.

编辑:

只是将图像和内容包装在一个div中,并带有"Display:Block"的样式.并移除了"浮动"属性.这将把产品放在不同的生产线上.

把所有这些都包在森林里.

如何使用Display:https://www.w3schools.com/cssref/pr_class_display.php

<div class=header>&nbsp;</div>
<div class="app">
  <main class="content">
    <form action="/getItem" method="get" class="input-wrapper">
      <button type="submit" class="fa fa-search"></button>
      <input type="text" class="input-wrapper-text" style="color:white;" placeholder="Search" name="q">
    </form>
    <div style="text-align: center;">
      <h2> Add Items </h2>
    </div>
    <div style="text-align: center;">
      <h1> Catalog </h1>
    </div>
    <div style="display: block; width: 100%; max-width: 100%; padding: 10px; box-sizing: border-box;">
      <hr size="10">
    </div>
    <% for (var i=0; i
                
                <results.length; i++) {%>
      <div style="display: block;">
        <div style="display: inline-block; vertical-align: top;" class="ebayImage">
          <a href="#" class="ebayImage" onclick="javascript:location.href='<%= results[i].ItemLink%>';" id="itemButton">
            <img src="https://images.pexels.com/photos/312418/pexels-photo-312418.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=2" style="width:250px; height: auto; border: 1px solid #cacaca;" alt="redirects to original eBay listing">
          </a>
        </div>
        <div style="display: inline-block; vertical-align: top;" class="ebayInfo">
          <a href='<%=results[i].ItemLink%>' style='width: auto; margin-left: 20px; color:black;'>
            <h3>
              <u>Item Name</u>
            </h3>
          </a>
          <p>&nbsp;</p>
          <p style="justify-content: space-between; width: auto; margin-bottom: 10px; margin-left: 20px; color: #5b619b; font-weight: bold;"> Points: 0.00 </p>
          <p>
            <button type="button" style="background-color: rgb(128, 0, 0);" id="newCatItem" onclick="deleteFromCat()">Remove Item</button>
          </p>
        </div>
      </div>

Html相关问答推荐

HTML横幅未正确对齐页面顶部

HTML图像无法正确放大和缩小规模

HTML5章节或文章

如何删除在小屏幕上单击按钮时出现的蓝色方块?

CURL邮箱中的图像不能调整其大小

选中/取消选中带有_hyperscript的多个复选框

如何从卷轴中排除粘性元素?

使用响应迅速的网格系统,将两列保持在同一行,同时允许更多列用于更大的屏幕

风格规则应该适用于响应图像的哪些方面?哪种规则适用于<;图片和gt;,哪种规则适用于<;img>;?

如何使用Reaction Js读取html文件中的代码

下划线在 Bootstrap 5 导航链接下无法正常工作

绝对类在另一个绝对类之上

将图像的高度限制为固定的纵横比,并在超过时使用 object-fit

pandas `to_html()` - 如何只使特定的行有边框

如何使 Shiny 中的 selectInput Select 扩展到井面板之外或以其他方式使它们更容易被用户看到?

把标题、段落和图片放在一起

Bootstrap 5 英雄

在 React (NEXT) 中,当我try 进行动态补充时,我无法使用实例this来引用输入

文本输入在 Chrome 中保持水平滚动,带有文本溢出:省略号

两个按钮范围滑块的 CSS