`how to showcase a collection of items in a horizontal layout`

My goal is to showcase Groups in a horizontal layout, with each group displaying its members. Here's an example:

   Group 1:           Group 2:       Group 3:
   1. Joe Blo         1. Bob         1. etc..
   2. Joe smith       2. Billybob
   3. Joe glow        3. Bobby

I'm grappling with CSS and can't seem to figure out what's missing in my code:

<ul id="grpId">
@foreach (var item in Model)
{                  
    <li>           
        Group @Html.DisplayName(item.GroupId.ToString())<br />
        <ol>
            @foreach (var student in item.GroupMembers)
            {
                <li>@String.Format("{0} {1}", student.FirstName, student.LastName)</li>
            }
        </ol>

    </li>

}
</ul>

This is how I've styled it using CSS:

#grpId
{
    background-color:aliceblue;
    list-style-type: none;
    padding-right: 20px;
}

    #grpId li
    {
        height:300px;

        background-color: aliceblue;
        display: inline;
        font-weight: bold;
        font-size: large;
    }
        #grpId li ol
        {
            display: inline;
        }

Answer №1

Check out this jsFiddle example
Ensure that you are clear on which type of list item (<li>) your CSS rule is targeting: using #grpId li will impact all list items, while #grpId > li specifically targets only direct children of the unordered list (<ul>)

#grpId {
    background-color: aliceblue;
    list-style-type: none;
    padding-right: 20px;
}
#grpId > li {
    height: 300px;
    display: inline-block;
    font-weight: bold;
    font-size: large;
}
ol > li {
    font-weight: normal;
    font-size: medium;
}

Answer №2

Here is the recommended style to use:

#grpId
{
    overflow: auto;
}

#grpId > li
{
    float: left;
}

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

Is there a way to apply the 'absolute' or 'fixed' with a width of 100% to the parent div specifically, rather than to the window size?

I would like to create a banner similar to the one shown here: https://i.sstatic.net/SZLr9.png I am attempting to achieve this using 'absolute' or 'fixed' positioning. However, when I tried using 'left: 0 right: 0 top: 0', i ...

Learn the step-by-step process of displaying a Bootstrap modal dialog in Vue.js!

I've been attempting to implement a modal dialog using bootstrap and vue js. The goal is to display the dialog box after a user successfully registers. <div> .... <div class="modal fade" v-if="isEnabled"> <div class="modal-di ...

Material-UI icons refusing to show up on the display

I've been working on creating a sidebar component and importing various icons to enhance the UI, but for some reason they are not displaying on the screen. I even tried other suggested solutions without success. <SidebarOption Icon = {InsertComment ...

What is the best way to incorporate TypeScript variables into CSS files?

In my Angular project, I am aiming to utilize a string defined in Typescript within a CSS file. Specifically, I want to set the background image of a navbar component using a path retrieved from a database service. Although I came across suggestions to use ...

What could be the reason for the malfunction of the nav-tab and tab-pane components?

I'm currently having an issue with my nav-tab and tab-pane implementation. While the nav-tab is working fine, the tab pane does not display the correct content when I click on a second tab. As a beginner in using Bootstrap, I am looking for advice on ...

Opacity is causing issues with hover effects in CSS

I'm facing an unusual CSS challenge. Check out this simple code snippet below that showcases the issue: <html> <head> <style> .hover { float: right; } .hover:hover { background-color: blue; ...

Delay the fading in of an element using jQuery

Is there a way to remove the pause between the images in my JavaScript/jQuery slideshow when fading in and out? I attempted using a small delay, but it still didn't eliminate the blank space. Any suggestions? Check out the code on jsfiddle: https://j ...

Is your jQuery TextEditor not functioning properly?

Having some trouble integrating the jQuery TextEditor plugin into my CodeIgniter project. I'm puzzled as to why it's not functioning properly. Just a heads up, my project also utilizes Bootstrap. Can anyone shed some light on why the plugin is fa ...

Stop Duplicate Entries from Showing in Your Angular Project

In my application, there is a form that enables users to search for doctors based on the criteria they select from drop-down menus. Below is the structure of the form: https://i.sstatic.net/itguq.png When a user chooses a city and clicks the search butt ...

Troubleshooting Issues with CSS3PIE and border-radius

Trying to implement CSS3PIE for my website to enable border-radius in IE8 (and older versions). The code works perfectly on all other browsers except IE. Below is the CSS I am using: #body_text_design{ border:2px solid black; background-color:#CCC ...

Does adding the Angular bootstrap script at the end of the body tag impact webpage speed more than using ng-app on the body tag?

In the past, we had placed ng-app on the body tag which led to problems with dependency injection when multiple modules were being used on the same webpage. This required module creators to be aware of the existing app and inject their app into it. We are ...

Access nested array data directly in AngularJS

Currently, I am facing an issue when it comes to extracting data from a nested array. Initially, my inquiry was about how to display data from a nested array in a table format on an HTML page as new rows. However, I now require the ability to directly show ...

Adding a div via an Ajax call is only successful during the initial page load

Currently, I am utilizing a combination of YQL and jQuery to retrieve content from a distant page. While I am able to successfully load the content during the initial page load, I encounter an issue when attempting to return to the same page after navigati ...

cutting tags with priority levels

I'm facing an issue where the vertical label "PINK" is centered perfectly in a section, but when I scroll down to the next section, it gets covered by a section with a higher z-index. div.back1 { background-color: #FF00FF; position: relativ ...

Should CSS properties be applied directly to the html tag?

Surprisingly, I recently discovered that it's possible to set the background-color of the html tag. It seems strange since I always thought the body was responsible for containing the first rendered tag. I used to believe that the html tag was just a ...

Storing dynamic content on a server and retrieving it for future use

I'm working on a webpage that allows users to create elements dynamically and I want to save those elements to the server. When someone else visits the page, I want them to see those saved elements as well. I'm not too familiar with web programm ...

How can one remove surrounding paragraph texts using BeautifulSoup in Python?

I'm a beginner in Python, working on a web crawler to extract text from articles online. I'm facing an issue with the get_text(url) function, as it's returning extra unnecessary text along with the main article content. I find this extra te ...

Resolving syntax error to enable dismissible device alerts

I am attempting to make my devise alerts dismissible. According to the bootstrap documentation found at this link, adding data-dismiss="alert" is necessary. However, when I try to implement this into my application layout as shown below, a syntax error oc ...

Ways to extend div to fill the rest of the page's vertical space

Apologies, my search has yielded many results, but none that directly address my specific issue. It appears that there is a proliferation of div-height problems on this platform. :-( Here is the layout I am working with for testing purposes: <!DOCTYPE ...

What is the best way to determine which DOM element is clicked when using the OnClick event? Can

Upon clicking an element: I seek to pinpoint the exact element. To prevent selecting multiple elements (e.g. with the same class) (and with or without an id), I am considering retrieving the absolute location/path in the DOM. Strategy: I have devised two ...