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

Steps for deactivating tab stops on the primary webpage in the presence of a snackbar

On my web page, there are multiple drop-down menus, input fields, and buttons that can be interacted with using both the tab key and mouse. After entering certain data, I trigger a snackbar (source: https://www.w3schools.com/howto/howto_js_snackbar.asp) t ...

What is the best way to customize the appearance of these two images within a div element?

While working on a small website project during my internship, I initially used an inline stylesheet. However, upon my boss's recommendation, I switched to an external stylesheet. Now, I'm trying to figure out how to style the two images within d ...

How to divide an HTML string into an array using PHP

I am in need of some assistance from you all. The issue I am facing involves dealing with a string of HTML that looks like this: <h4>Some title here</h4> <p>Lorem ipsum dolor</p> (some other HTML here) <h4>Some other title ...

IE9 causing trouble with CSS vertical alignment

I'm trying to center a button with text using Cuffon for the font, but I can't get it to align vertically and horizontally. The text-align property is working fine, but vertical align isn't. Here's the code for my div block: btndownlo ...

Close the overlay by clicking outside of it

I'm working on creating a unique pop-up window that appears when a customer adds a product to their cart. The design features red and green background divs with a darker overlay (#overlay-daddy) and a white child div (#overlay). My issue arises from ...

PHP is struggling to retrieve the value of "img src"

CSS <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <form action="./test2.php" method="POST"> ...

floating containers aligned side by side in a perfectly positioned parent container

I'm currently working on aligning a set of buttons within a DIV popup that I've created. My goal is to have the buttons positioned next to each other, but I'm having trouble achieving this. I've attempted using 'float: left', ...

If the header 1 contains a specific word in jQuery, then carry out an action

I have successfully used the contains() function before, but I've never incorporated it into an if-statement. The code below doesn't seem to be working as expected. Essentially, I want to check if H1 contains the word "true" and perform a certain ...

Tips for utilizing jQuery to display images similar to videos

Are there any plugins available that can create a video-like effect on images by incorporating scroll, pan, tilt, zoom (in/out) transitions for a few seconds before fading to the next image? I've searched but haven't found anything quite like thi ...

I'm struggling to locate the space that should be between these elements

After accidentally starting in quirks mode without declaring a doctype, I realized my mistake and corrected it by declaring a doctype. However, there is a persistent issue with a space between .car-box-img and car-box that I can't seem to locate in t ...

The total height of the document's body in jQuery is not equal to the sum of the viewport height and the window's scroll top position at the bottom of the document

Why does the document height appear smaller than the window scroll top value plus the viewport height when I reach the end of the document? Shouldn't they be equal? I've been struggling with this issue for hours and can't seem to figure it o ...

How can I set a checkbox as mandatory using ng-messages and Ionic framework?

I am currently developing a form for my application using Cordova CLI 8.0, Ionic 1.3.5, and AngularJS 1.5. My goal is to set a checkbox as required within the form. Here's the approach I have taken so far: <ion-checkbox name="entry.exportcode" n ...

How can an object be utilized within the image tag's src attribute?

Is it possible to use an object in the img src attribute? // HTML <img src= "item.img" ...

Tips for displaying HTML elements beyond the boundaries of an iframe

Similar Inquiry: How can content from an IFRAME overflow onto the parent frame? I am in search of a potential solution for the following issue: There is a specific element with the style "position: absolute" within a page loaded into an iframe. Based ...

Reducing the Bootstrap Navbar Collapse Width

After spending all day searching for an answer, I still haven't found a solution to my problem. Here is the code I am struggling with: <div class="visible-xs navbar navbar-ti navbar-fixed-top "> <div class="container"> <div class ...

Navigating through the website has become quite challenging due to the malfunctioning navigation bar. Instead

I recently completed a website and designed an awesome navigation bar in a separate file. However, when I combined them together, the navigation bar disappeared. The background of my "list" div should be filled in and larger, but it's not working as e ...

Why isn't the parent div stretching alongside its child divs?

Take a look at this example: wthdesign.net/website/olaf&co/index.php I am currently working on creating a responsive layout, but I am struggling to figure out how to make the "#content" div stretch with its child div when there is more content than ex ...

React Nested Menu Selection

Having trouble displaying TextField values in my React app. Utilizing material UI and material-ui-phone-number packages. Noticed that values appear behind when clicking the flag due to zIndex issue. Looking for modifications only on dialog2.js For code ex ...

Discover the Magic of Jquery Hover Effect Unleashed

$('.outerBox').hover( function() { $(this) > $('.innerBox').stop(); $(this) > $('.innerBox').slideDown(750); }, function() { $(this) > $('.innerBox').stop(); $(this) > $(&apos ...

Unable to display images on mobile devices using HTML

I recently created a website using HTML and CSS. I have successfully added images to some of the web pages, and they display properly on laptops and desktops. However, I am facing an issue where the images do not appear on small screens, even though all im ...