How can I create two buttons on one line in a Struts2 form?

My form has two buttons - one for registering and the other for canceling the form. I created them using the following code:

<s:submit name="cancel" key="project.button.cancel" />
<s:submit name="login" key="form.register.registerBtn" />

However, when I view the form, the buttons appear on separate rows instead of in the same row. You can see this in the image below:

How can I fix this issue? Thank you.

Update 2013/9/21 :
Here is the full JSP page code:

<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath}/resources/css/form.css" />
    <title>Insert title here</title>
</head>
<body>
    <div style="padding-top: 20px;"></div>
    <div style="width: 600px; margin: 0 auto;">
    <div style="float: left; padding: 20px; padding-top: 0px;">
        <img alt=""
            src="${pageContext.request.contextPath}/resources/img/register.png">
    </div>
    <div class="box" style="width: 300px; float: left;" id="col">
        <h1>
            <span class="title"><s:text name="form.register.title" /></span>
        </h1>
        <hr />
        <form action="login" method="post" namespace="/">
            <span class="text"><s:text name="user.nickname" /></span>
            <s:textfield name="nickname" />
            <hr />
            <span class="text"><s:text name="user.username" /></span>
            <s:textfield name="username" />
            <span class="text"><s:text name="user.password" /></span>
            <s:password name="password" />
            <span class="text"><s:text name="user.validation" /></span>
            <s:password name="validation" />
            <s:checkbox name="recoverable" key="user.recoverable" />
            <hr />
            <span class="text"><s:text name="user.email" /></span>
            <s:textfield name="validation" />
            <div style="display: inline-block; white-space: no-wrap;">
                <s:submit name="cancel" key="project.button.cancel"
                    cssClass="button-red" />
                <s:submit name="login" key="form.register.registerBtn"
                    cssClass="button-green" />
            </div>

        </form>
    </div>
</div>

Answer №1

To solve this issue, it is recommended to group them together within a single div element and style it using CSS.

<s:form action="login" method="post" namespace="/" theme="simple">
  ....
  <div style="display:inline-block;white-space:nowrap;">
    <s:submit name="cancel"  key="project.button.cancel" />
    <s:submit name="login"  key="form.register.registerBtn" />
  </div>
</s:form>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating HTML tabs using jQuery with input[type="radio"] tutorial for beginners

I'm having trouble creating a tab with input[type="radio"] using Jquery. The tab works fine on the first click, but it doesn't work on the second click. I can't figure out where the issue is in the Jquery code. Can someone assist m ...

How can I adjust the regular font size within a paragraph or link using bootstrap?

Looking at the fs-* classes can be very helpful, you can find them here: https://i.sstatic.net/l1Y22.png The issue I'm facing is that these classes only work for h1 to h6 headings, and not for smaller text. For example, I am unable to adjust the fo ...

Is there a way to conceal the contents of a page until all the images have finished loading?

I'm currently working on improving the performance of a website that is loading very slowly. I have already reorganized, compressed and minified the JavaScript and CSS files, but the main issue seems to be with the images. The site contains large imag ...

Converting a JSON array of key-value pairs into a Plain Old Java Object (POJO

Is it possible to use Jackson to convert the JSON data below into a POJO class? { "company": [{ "employee": { "address": { "email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c7a6a5a487a0aaa6aeabe9 ...

Issue with bootstrap 4 CDN not functioning on Windows 7 operating system

No matter what I do, the CDN for Bootstrap 4 just won't cooperate with Windows 7. Oddly enough, it works perfectly fine on Windows 8. Here is the CDN link that I'm using: <!doctype html> <html lang="en> <head> <!-- Req ...

Do you think removing certain code decreases the size of an apk file?

I currently have some code in my files that is no longer being used. Instead of completely deleting it, I am considering commenting it out so it can be useful later on. Is this a good idea? If I comment out the code instead of removing it, will it affect ...

Automated vertical alignment of rows within the Bootstrap table

I'm currently working on a table for my personal project that populates with data from the database. I am trying to get the rows to display vertically under headings (see screenshot at the bottom of this question). I have attempted various solutions f ...

Unable to locate image files stored in vendor/images in the Rails 4 view

I have successfully set up a custom bootstrap theme with Rails 4, and placed the image file here: /vendor/assets/images/custom_bootstrap_theme/demo/bg01.jpg The index.html.erb file is referencing this image as follows: <img src="/vendor/assets/image ...

Get an Array Using AJAX in PHP and JavaScript

Section 1 I want to retrieve an Array from PHP and use it in JavaScript. I have created a file using the fwrite function in PHP, then included that file in my next .load method inside a Div. The new PHP file contains an "include 'somefile.php';" ...

Concealing a Div element without the use of Jquery or JavaScript

I have an Upper and Lower div in my HTML code. I am trying to display the Lower div only if the Upper div is present, otherwise hide it. Is there a way to achieve this using CSS without using Jquery or Javascript? Note: No modifications should be made t ...

Only CSS creates tooltips within text seamlessly without any line breaks

I have been exploring ways to incorporate multiple tooltips into text on my website. After experimenting with both span and div tags, I was able to create a tooltip using CSS only. However, I am facing challenges with positioning the tooltiptext correctly. ...

Animation that responds to scrolling movements

Is there a way to animate text based on scrolling? <p class="class">TEXT</p> transform:translateX(-500px);opacity:0; transform:translateX(0px);opacity:1; ...

Creating personalized queries in MongoDB repository using Spring Data REST

I am currently working on a project that involves creating a custom query based on the instructions provided in the Spring guide: Accessing MongoDB Data with REST and following the guidelines outlined in the Reference 4.4 Custom Implementations. However, I ...

Step-by-step guide on applying a universal CSS class to every component within an application

I am in the process of building a multilingual react application and I am looking for a solution to dynamically apply certain CSS styles to most components based on the chosen language. I am seeking something akin to direction-rtl and direction-ltr, whic ...

Tips for Avoiding Line Breaks in CSS Divs

I am currently designing a website menu with items such as Home, Contact us, and About us. Each item is styled with a background color and text size of 125X30. I initially used the float property in CSS to align them correctly in a single line from left ...

Issue with dynamically adjusting flex box width using JavaScript

Currently, I am developing a user interface that heavily relies on flexbox. The layout consists of a content area and a sidebar that can be toggled by adding or removing a specific class. Whenever the sidebar is toggled, the content area needs to be manua ...

Sophisticated Sidebar Design using Bootstrap 5

Looking to design a responsive sidebar for navigation on my page, with selected and hover properties. Visualizing the selected option to appear like this: Selected (active) option in sidebar The goal is to have the image cover the left side of the backgr ...

Trouble with CSS animation when incorporating JavaScript variables from a PHP array

Whenever I use a script to fetch an array of objects from PHP... I successfully display the results on my website by outputting them into Divs. The challenge arises when I introduce CSS animations. The animation only triggers if the variable length excee ...

Instructions for configuring a VPN proxy on an Android device

Seeking assistance in connecting to an HTTP proxy like 95.179.128.75:8080 and routing all traffic through the Ultrasurf app. Attempted to create a VPN service using the following code: class MyVpnService : VpnService() { override fun onStartCommand(intent ...

The web server experiences a layout and functionality breakdown caused by an issue with the config.js file following the uploading process

I recently created a website. However, when I uploaded it to my hosting company's server and tested it on different browsers, the layout appeared broken. Some of the CSS files loaded properly, but certain elements and styles were not in their correct ...