Arranging various s:select dropdowns for inline display styling

I have a form with three consecutive struts2 tags. Upon rendering the page, the s:select tag is automatically converted to the HTML code at the bottom.

The issue arises when I attempt to style the form in order to display these dropdowns horizontally. Unfortunately, as the code stands, I am unable to set ids or classes for any of the elements. They are all assigned auto-generated ids, and I can only apply a cssClass to the select tag itself, not to the ul or li elements.

Although I have the option to assign an id to the form element, my limited experience with CSS has prevented me from achieving the desired outcome. Therefore, my question is: How can I style the following HTML to present the li elements in a horizontal line while only having access to set the form id and class? Additionally, it would be preferable if the labels were situated above the select box.

It's worth noting that there is an existing CSS stylesheet that styles these elements differently. The divs have specific display attributes that could disrupt the layout of the li elements. Is there a way to instruct the browser to ignore its default styling and simply display these elements inline?

Alternatively, is it possible to switch to using a plain old "ul" tag instead? If so, how can I populate it with items while setting display value and id values?

        <ul>
        <li>
            <div id="xxxx">
                <label>Somelabel</label>
            </div>
            <div id="ssdf">
                <select id="sfsd" name="xx" class="this i can control">
                    <option>1</option>
                    <option>2</option>
                </select>
            </div>
        </li>
        <li>Second dropdown etc</li>
    </ul>

Answer №1

If you want to manipulate the styling of list elements within a form using CSS, you can utilize the descendant selector. This allows you to target specific elements based on their hierarchy relationship.

#formid ul{
   overflow:hidden; /* this ensures the height adjusts according to the content*/
}

#formid li{
   float: left; /* just make sure the total width of all list items does not exceed the width of the containing ul element*/
}

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

Identifying a change in the source location of an iframe element

I am working with an iframe object that is currently set to a specific page's URL. Here is an example: <iframe src="http://en.wikipedia.org/wiki/Special:Random"></iframe> My goal is to display an alert whenever the location of the iframe ...

The Material-UI TextField is placed in the Header section of the page

As I scroll down the page, I noticed that the TextField in the header area remains visible. This header is styled using CSS and includes a TextField from the material-ui library. This is my first time creating a header with CSS. Are there any specific cod ...

Enhance User Experience by Implementing Event Listeners for Changing Link Visibility Using mouseover and getElementsBy

I am new to JavaScript and struggling to find a solution. Despite searching online for fixes, none of the solutions I've found seem to work for me. I have spent hours troubleshooting the issue but I must be missing something crucial. Can someone plea ...

How to center a text box within a div using CSS

Looking for equal margins on top and bottom? Here's how to achieve it: If you have a container div like this: <div id="search"> <input id="txtSearch" type="txt"> </div> Your CSS should look something like this: #search{ m ...

Error encountered while retrieving the cropped image, atob function was unable to execute

I am currently facing an issue with saving a cropped image in Chrome. When I try to save it, the download fails when using the Download button that I added to the page. I have successfully used ngx-image-cropper for cropping the image as intended. The cro ...

Like button for Facebook located at the bottom of a static webpage

I am facing an issue with my web application where it does not scroll properly, especially when there is a Facebook button at the bottom. The behavior in Chrome and Firefox is inconsistent and causing some trouble. In Chrome, the div repositions correctly ...

The submit button appears as grey on IOS when using the input[type="submit"]

Why does the submit input look different on IOS only, and how can this be resolved? https://i.sstatic.net/UVlKB.png Thank you in advance For HTML: <input class="btn" type="submit" [disabled]="" ...

Issues with functionality of Bootstrap 5 popover in responsive JavaScript DataTable

As I work on constructing a web page for my hobby, I am utilizing Bootstrap 5.3.3 and JS DataTables 2.0.5. Within the page, there is a table displaying data about various players. I have implemented a feature where clicking on certain cells triggers a popo ...

What is the best way to incorporate a fadeIn effect while using the .attr method?

I am working with a line of code that switches between classes class1 and class4 to update the background of my website. I would like to incorporate a fadeIn effect each time the class changes. Can you help me with this? Thank you! Below is the code snipp ...

I'm having trouble getting my Bootstrap Navbar list aligned in the center

I've been attempting to align my menu list items in the center of the bootstrap navbar but have had no success. Despite trying various CSS styles, the items remain on the left side. Please take a look at my HTML and CSS below and let me know if there ...

Evaluation of HTML5 file upload functionality with unit testing

How can I perform JavaScript unit testing for file uploads using the HTML 5 File API? Let's consider the following code: <form method="POST" enctype="multipart/form-data"> <input type="file" id="fileselec ...

What is the best way to align text in the center based on a specific portion of the content?

I'm working on an inline flex div where I want to create a unique effect using the words wrap and the div overflow. As the window is resized, some of the words in the sentence will disappear, altering the meaning. The width will determine the result: ...

What is the most effective method for dynamically showcasing buttons in AngularJS?

Hello all, I'm currently learning AngularJS and I was wondering if anyone could recommend the simplest and most effective method for dynamically displaying links from AngularJS to HTML. I am looking to display a variable number of buttons in my HTML ...

Tips for achieving a Google Map that smoothly slides behind a sticky header as you scroll

I recently added a sticky header using CSS to my long HTML page. At the bottom of the page, there is a <div> element with a Google Map embedded in it. As I scroll down the page, the content scrolls behind the sticky header as expected, but the Googl ...

Drawing images on a Canvas using specified coordinates: A step-by-step guide

https://i.stack.imgur.com/YkibI.jpg I've been trying to position images on specific coordinates, but I'm having trouble getting the shapes and angles right. Currently, only the top left corner is matching correctly. var _width, _height; var im ...

Combining several position-aligned classes into a single div instead of each having their own individual div

http://jsfiddle.net/58arV/ Trying to create a question component where users can choose the correct answer out of 4 options. I planned to use 4 input styles with a checkmark "radio" DIV on the right. When a user clicks on an option, it should display a c ...

What is the best way to combine a top <div> with a bottom <div> in an image without creating unsightly white gaps?

I need help overlapping two divs on top of an image in HTML. The first div should cover part of the top area of the image, while the second div should cover part of the bottom area of the image. These divs should be displayed over the image without leaving ...

Utilize JavaScript or JQuery to create a dynamic pop-up window that appears seamlessly on the

Looking to create a unique feature on an HTML page? Want a clickable link that opens a "pop-up" displaying a specific image, right within the page rather than in a new tab or window? Ideally, this pop-up should be movable around the page like a separate ...

Has anyone figured out the issue with Uplodify? It suddenly ceased to function

For some time now, I've been using uplodify without any issues. Unfortunately, as of yesterday, it suddenly stopped working. I'm at a loss as to what might have caused this sudden change. Could someone please offer me some assistance? I've ...

Creating columns with equal heights in Bootstrap 3 without compromising on the column padding

I am using a standard Bootstrap 3 CSS setup and I am trying to give columns inside a row the same height. I have been experimenting with using display: table and display: table-cell, which does work, but it seems to add vertical padding to columns with les ...