简体   繁体   English

表格后的按钮会自动添加为一行。 如何区分它们?

[英]The button after a table is automatically added as a row. How to seperate them?

I have created a struts2 application about Student Database.我创建了一个关于学生数据库的 struts2 应用程序。 The problem is that whenever I add a submit button after showing the database in table, the button is surrounded by a big background similar to that of the row width of the table before it.问题是,每当我在表格中显示数据库后添加提交按钮时,该按钮都会被一个大背景包围,类似于之前表格的行宽。 I want to remove that border.我想删除那个边框。

Here is the image how it looks:这是图像的外观: 在此处输入图片说明

See, how there is a grey background around the home button, I don't want that.看,主页按钮周围有灰色背景,我不想要。

Here is a snippet of the code: JSP:这是代码片段:JSP:

<table>
            <tr>
            <th>RollNo:</th>
            <th>Name:</th>
            <th>DOB:</th>
            <th>Gender:</th>
            <th>Address:</th>
            </tr>
            <%
            while(rs.next())
            {

            %>
                    <tr>
                    <td><%=rs.getInt(1) %></td>
                    <td><%=rs.getString(2) %></td>
                    <td><%=rs.getString(3) %></td>
                    <td><%=rs.getString(4) %></td>
                    <td><%=rs.getString(5) %></td>
                    </tr>
                   <%

                }
                %>
        </table>
        <%
        rs.close();
        stmt.close();
        conn.close();
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }


    %>
    </div>
    <br><br>

    <s:form action="home.jsp">
        <s:submit class="button4" value="Home"></s:submit>
    </s:form>

table.css file: table.css 文件:

table {
    background-color: #dbdbdb;
    width: 60%;
}

th,td {
    color: #363b3f;
    border-bottom: 1px solid #ddd;
}

tr:nth-child(even) {
    background-color: #c8c8c8
}

tr:hover {
    background-color: #c488d7;
}

button.css按钮.css

.button4
{
    background-color: #af4ccf; /* purple */
    border: none;
    color: black;
    padding: 18px;
    font-family: 'Amputa';
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    margin: 4px 2px;
    border-radius: 30%;
    -webkit-transition-duration: 0.4s; /*Safari*/
    transition-duration: 0.4s;
    cursor: pointer;
}

.button4:hover
{
    background-color: #c986df; /* Light purple */
}

I have tried encapsulating the table and button in separate div.我尝试将表格和按钮封装在单独的 div 中。 Also I have tried, putting the button in a different table.我也尝试过,将按钮放在不同的表中。 But nothing works.但没有任何作用。 I can't seem to pinpoint the exact point where it may be going wrong.我似乎无法确定可能出错的确切点。 How and what can I do to make that background border go away and center align the button?我该怎么做才能使背景边框消失并使按钮居中对齐?

The s:form generated additional HTML elements parsed by the freemarker template used by the tag implementation. s:form生成了额外的 HTML 元素,由标签实现使用的 freemarker 模板解析。 It chooses a template based on the theme used by the tag.它根据标签使用的主题选择模板。

You have created CSS for any element on the page including those generated by Struts tags, so the style is inherited.您已经为页面上的任何元素创建了 CSS,包括由 Struts 标记生成的元素,因此样式是继承的。

Using common selectors for all page elements not always fit the design and appearance of the elements on the page.对所有页面元素使用通用选择器并不总是适合页面上元素的设计和外观。 On the other hand qualified selectors narrow its usage to particular content that could be wrapped with the container or other element.另一方面,合格的选择器将其使用范围缩小到可以用容器或其他元素包装的特定内容。 You can also qualify your selectors with the id or use class attribute on the table and qualify selectors by class.您还可以使用表上的id或 use class属性来限定您的选择器,并按类限定选择器。

Struts uses a few themes for elements generated by UI tags. Struts 为 UI 标签生成的元素使用了一些主题。 If you want to custom design your pages with Struts tags that has a minimal effect, then you should use a simple theme.如果您想使用效果最小的 Struts 标签自定义设计您的页面,那么您应该使用simple主题。

<s:form action="home.jsp" theme="simple" cssStyle="background-color: none">
    <s:submit class="button4" value="Home"></s:submit>
</s:form>  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Vue如何将forloop按钮表分成表中的不同行 - Vue How to seperate forloop button table into different row in table HTML表格在行的底部添加空格。 - HTML Table adding space at the bottom of a row. 相对定位不适用于表格行。 - Relative Positioning not working on a Table Row. 如何获取 javascript 在页面加载后添加的表的行? - How can I get the row of a table added after pageload by javascript? CSS图片不在行中。 怎么解决? - CSS image is not in row. How to resolve? 淘汰:表选择取消选择行。 取消选择行的问题/挑战 - Knockout: Table Select Unselect Row. Issue/challenge with unselecting Row 使用jquery将远程数据加载到同一表后,如何在表的底部添加一行? - How to get an added row to bottom of the table after remote data is load in same table using jquery? 单击按钮后添加行后计算输入字段 - Calculate input field after row added when button click 无样式列表将文本放在下一行。 如何阻止这个? - unstyled list drops text in next row. how to stop this? 我将行添加到html表中,并且添加成功,但是我想将该表数据导入excel表中,如何在下载按钮上添加? - i add row to html table & it added successfully but i want to import that table data to excel sheet how to add on download button?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM