How come it's proving to be impossible to align this unordered list that's nested within a jQuery accordion?

I have exhaustively attempted various methods to center the #accordion ul.

Do you have any recommendations?

Code:

css:

.container {
    margin: 0 auto;
    overflow: hidden;
    width: 960px;
}

    #accordion {
        float: left;
        position: relative;
        width: 940px;
        height: 200px;
        overflow: hidden;
        margin: 25px 0px 0px;
    }

    #accordion ul {
        list-style: none;
        margin: 0px;
        display: block;
        height: 200px;
        width: 940px;

        }

    #accordion ul li {
        float: left;
    }

    #accordion ul li a {
        background:#FFFFFF none repeat scroll 0%;
        border-right: 2px solid #fff;
        cursor:pointer;
        display:block;
        overflow:hidden;
        width:78px;
        height: 200px;
    }

    #accordion ul li.landscapes a {
        background: url(../images/landscapes.jpg) repeat scroll 0%;
    }

    #accordion ul li.people a {
        background: url(../images/people.jpg) repeat scroll 0%;
    }

    #accordion ul li.nature a {
        background: url(../images/nature.jpg) repeat scroll 0%;
    }
    #accordion ul li.abstract a {
        background: url(../images/abstract.jpg) repeat scroll 0%;
    }

    #accordion ul li.urban a {
        background: url(../images/urban.jpg) repeat scroll 0%;
        min-width:310px;

    }

php:

<div id="intro">
    <div class="container">
        <div id="accordion">
            <ul>
                <?php // Create and run custom loop
                    $custom_posts = new WP_Query();
                    $custom_posts->query('post_type=page_content&page_sections=Slider (Front Page)');
                    while ($custom_posts->have_posts()) : $custom_posts->the_post();
                ?>
                <li class="landscapes"><?php the_content(); ?><></li>
                <?php endwhile; ?>
            </endwhileul>
        </div>
    </div><!-- .container -->
</div><!-- #intro -->

Reference Image:

Answer №1

Have you considered adjusting the width of #accordion ul to a smaller size, such as "auto" or a significantly reduced value? Currently it is set at 940 while its container is only 960px wide. You could also experiment with adding margin: 0 auto; to the ul after resizing it, or applying text-align: center to #accordion.

Answer №2

The conclusion of your list is marked with </endwhileul> instead of the correct closing tag, which should be </ul>

Is your intention to align the images at the center of the UL?

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

Responsive design with Flexbox, interactive graphics using canvas, and dynamic content resizing

I'm having difficulties with my canvas-based application. I have multiple canvases, each wrapped in a div container alongside other content. These containers are then wrapped in an "hbox" container. The objective is to create a dynamic grid of canvas ...

Can you determine someone's age by choosing options from dropdown menus?

Hey there. I've been working on a little project for my job, and I put together a simple HTML text file. I'm looking to extract the date of birth from dropdown menus in order to calculate the person's age and then proceed with some other fun ...

Is it possible to dynamically load different sections of a webpage separately without relying on JQuery or Ajax?

In order to ensure a smooth user experience for this project, I need the page to load while simultaneously querying the database. Even if the query is not yet finished loading, I want the page to display and wait for the query to complete. This approach wi ...

Utilizing jQuery to Select Check Boxes Alongside Labels

In my jQuery code, I have a simple trigger set to run when a radio button is clicked in order to check certain checkboxes on the page. <script> jQuery('#op5').click(function () { $('input[type=checkbox]'). ...

Looking to invoke the parent function from a jQuery iframe dialog?

1) Frame.jsp <div id="existingEndorsement" style="font-size:12px; height:200px !important; display: none;" > <iframe id="existingEndorsementFrame" width="410" height="200"></iframe> </div> 2) ExistingEndorsement.jsp function ...

The onProgress event of the XMLHttpRequest is triggered exclusively upon completion of the file upload

I have a situation with my AJAX code where the file upload progress is not being accurately tracked. The file uploads correctly to the server (node express), but the onProgress event is only triggered at the end of the upload when all bytes are downloaded, ...

What causes socket.emit to duplicate after a dynamic update with jQuery trigger?

Is there a way to dynamically update the content of a div called "display-holder" in client-side code while ensuring that the socket.emit function fires only once? I have tried using off() and unbind() functions, but they do not seem to work in preventing ...

The input data from the MySQL database requires two page refreshes in order to be retrieved

Every time I input new values into the form fields and submit them, the page needs to be reloaded twice to display the updated values. For example, consider the $balance_2 in the 7th line. This line calculates the sum of all row values and updates the Bal ...

Experiencing the Pause: A Fresh Take on

I'm currently using this slideshow for a project, and I need to understand if it's possible to resume its interval. The current issue is that when you hover over the slideshow, the progress bar stops. But once you remove the mouse, it continues f ...

Is it possible to cache an html page and display it on the current page when reloading?

I have been attempting to design a webpage with links in a table that trigger modals when clicked. These links are added dynamically using Jquery. $("table").append('<tr><td><a href="#exampleModal" data-bs-t ...

Struggling to make CSS work properly with a table that has been appended

I am currently working on an ajax request to retrieve rows of data from a PHP file, consisting of three values each. After successfully appending this data into a table, I am facing an issue with adding classes or IDs for styling purposes. Here is the JSF ...

CSS - changing images for the menu based on user interaction

I'm in the process of designing a website and I have a unique challenge - I need to figure out how to create a dynamic triangle below an item on the menu bar using CSS. The catch is that the horizontal position of this triangle will shift based on wh ...

AJAX request generating new data instead of modifying existing records

Within my code, I have placed my AJAX call inside a $("button").on("click") jQuery method. Therefore, whenever the button element is clicked, the AJAX call triggers and inserts values into the mustache template. <button type="button">Click Me!</ ...

What is the best way to dynamically resize a div as the page size changes?

I am currently working on a project that involves a div dynamically shrinking as the page size decreases. However, I have encountered an issue where the height of the div remains constant despite this resizing: CSS .container { min-height: 180px; max ...

What is the best way to create a popup that appears next to a button and above another element?

pre-prompt: https://i.sstatic.net/0l32k.png post-prompt: https://i.sstatic.net/MzRUu.png I am completely clueless on how to achieve this, can anyone provide guidance? ...

Add a variable's value as a key to an array

I am working with an array: let pages = new Array(); My goal is to add data from my pages to this array in the following way: $('li.page').each(function () { let datatype = $(this).attr('data-type'); let info = $(this ...

Please explain the steps for creating a responsive grid layout

*{ margin: 0; margin-bottom: 200px; padding: 0; border: 0; outline: 0; font-size: 100%; vertical-align: baseline; background: transparent; } .grid-container { position:relative; display: inline-grid; grid-template-col ...

What is the best way to align a table (datatable) to the left?

How can I align the table to the left without using float:left in the following code? Applying text-align: left to the parent element of the table doesn't seem to work as expected. http://jsfiddle.net/william/B4qJG/1 HTML: <div class="valueList" ...

Arrange the div and ensure that the external JavaScript file functions properly when the page loads

I am encountering an issue with my JavaScript and CSS code. It works perfectly fine within the fiddle environment but fails to function properly outside of it. Here is the link to the fiddle When I embed the code into an HTML document directly, it does n ...

Popup mode is utilized by CodeIgniter error pages to display error messages

Is there a way to show error messages without being redirected to the error pages located in application\errors\*error_pages*? We want to remain on the same page and display any errors that occur in a popup. Can someone provide an example code fo ...