Ensuring divs are centered when resizing the page

Is there a way to center an unordered list of tables while ensuring that it remains centered even when the window is resized? The list should move each table to a new line if they can no longer fit. Check out the code snippet below for reference:

<div id="container">
    <ul id="project-list" class="child">
        <div class="the-crew_item">
            <li>
                <a href="#/got/" class="proj-link">
                    <table border="0" cellpadding="0" cellspacing="0" class="proj">
                        <tr valign="top">
                            <td>
                                <a href="#/got/" class="proj-link"><img src="images/got-thumb.jpg" border="0" /></a></td>
                        </tr>
                        <tr valign="top">
                            <td class="project-desc" style="background: url(images/logo-hbo.png) no-repeat center center;">
                                <h1>Game of Thrones</h1>
                                Epic Fan Event
                            </td>
                        </tr>
                    </table>
                </a>
            </li></div><div class="the-crew_item">
        <li>
            <a href="#/airbnb/" class="proj-link">
                <table border="0" cellpadding="0" cellspacing="0"  class="proj">
                    <tr valign="top">
                        <td>
                            <a href="#/airbnb/" class="proj-link"><img src="images/air-thumb.jpg" border="0" /></a></td>
                    </tr>
                    <tr valign="top">
                        <td class="project-desc" style="background: url(images/logo-airbnb.png) no-repeat center center;">
                            <h1>Airbnb</h1>
                            Hello LA
                        </td>
                    </tr>
                </table>
            </a>
        </li>
    </ul>
        <p>&nbsp;</p>
    </div>
</div>

Answer №1

Perhaps this solution can assist you -

#container {
    margin:10px auto;
    width:500px;
    background:blue;
}
<div id="container">
    <ul id="project-list" class="child">
        <div class="the-crew_item">
            <li>
                <a href="#/star/" class="proj-link">
                    <table border="0" cellpadding="5" cellspacing="2" class="proj">
                        <tr valign="top">
                            <td>
                                <a href="#/star/" class="proj-link"><img src="images/star-thumb.jpg" border="0" /></a></td>
                        </tr>
                        <tr valign="top">
                            <td class="project-desc" style="background: url(images/logo-movie.png) no-repeat center center;">
                                <h1>Hollywood Stars</h1>
                                Movie Premiere
                            </td>
                        </tr>
                    </table>
                </a>
            </li></div><div class="the-crew_item">
        <li>
            <a href="#/vacation/" class="proj-link">
                <table border="0" cellpadding="5" cellspacing="2"  class="proj">
                    <tr valign="top">
                        <td>
                            <a href="#/vacation/" class="proj-link"><img src="images/vacation-thumb.jpg" border="0" /></a></td>
                    </tr>
                    <tr valign="top">
                        <td class="project-desc" style="background: url(images/logo-travel.png) no-repeat center center;">
                            <h1>Travel Adventures</h1>
                            Explore the World
                        </td>
                    </tr>
                </table>
            </a>
        </li>
    </ul>
        <p>&nbsp;</p>
    </div>
</div>

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

Displaying a message text upon successful AJAX request

I have a web page with an AJAX request that updates data in the database. After the update, I want to display a message to the user on the webpage confirming that the data has been successfully updated. However, currently, no message is being displayed and ...

Apple's iPhone does not adhere to media query specifications

My responsive website was functioning perfectly on desktop, Android, and Windows Phone devices. However, when I asked my friends to check it on their iPhones running iOS 10, they informed me that the media queries were being ignored on iPhone models 5, 5s, ...

access denied on image links

While developing a web app with Angular5, I encountered an issue regarding retrieving image URLs from the 4chan API. Each post in my database contains an image URL, however, when I try to access it through my app, I receive a 403 forbidden error in the con ...

Tips on updating checkbox background color after being selected

I've been working on creating checkboxes for seat selection in Angular using a TypeScript file, but I'm facing an issue where the background color of the checkbox doesn't change after checking them. Here's my TypeScript function: gener ...

"Remaining Elements" within a CSS Design

I am faced with a challenge where I have 4 elements nested inside a container element. The height of the container should be set to 100% of the browser window. The inner elements need to stack vertically, with the first two and last elements having a natur ...

"Reduce the height and adjust the row spacing of the Vuetify form for a more

I'm currently working on creating a form using vuetify that closely resembles the one shown in this image: After experimenting with vuetify grid and columns, I've managed to achieve something similar to this: My goal now is to reduce the height ...

Sliding the container with a width adjustment and left margin fails to display all images

In the provided HTML code below, there is a functionality to move images horizontally by clicking on buttons: $(document).ready(function() { calculate_width(); $('#moveleft').click(function() { var loga = $('#marki #loga'); ...

Ways to center the percentage on the progress bar

I'm having an issue with positioning the percentage 100% in the center of the element. I attempted adjusting the spacing in the JavaScript code, but so far it hasn't been successful. Here is the current output for the code: http://jsfiddle.net/G ...

Is it possible to highlight only a specific color on the div background?

I'm trying to create a layout similar to this: I've managed to get most of it working, but I'm struggling with the yellow rectangle that spans the background of the screen. Currently, it looks like this: The issue is that the rectangles ar ...

Leverage the power of Reactjs to add hover effects to a mapped

I am facing a challenge in styling the ListItem on hover. The issue arises when the list is dynamically generated, causing all list items to change style simultaneously when hovered over. How can I target only one element for styling? Below is the code sni ...

Ways to identify if the text entered in a text area is right-to-left justified

Within a textarea, users can input text in English (or any other left-to-right language) or in a right-to-left language. If the user types in a right-to-left language, they must press Right-shift + ctrl to align the text to the right. However, on modern O ...

Nested Bootstrap structure with a column containing two sub-columns

I am attempting to create a grid layout using bootstrap. The layout should consist of a full 12 column layout on desktop, with an 8 column grid and a 4 column grid within it. The 8 column grid will contain an image/text, while the 4 column grid will have t ...

How to Create a Floating DIV with CSS

Here is the URL I am referring to: Website I want to position the Weather DIV above other content on the page while still maintaining its position when expanded or collapsed. How can I achieve this without affecting the layout of other elements? This is ...

Issues arise with the behavior of Bootstrap design when adapting to different screen sizes, as well as

I am currently working on designing my personal portfolio using Bootstrap. I have made some progress with the setup, but I am encountering some issues. When I resize the window, the top menu collapses into a button. However, when I click on the button, n ...

Navigating through each segment

I'm currently working on a website with sections that are set to be 100% height of the window, but at least 800px tall. My goal is to implement a smooth scrolling functionality where one scroll moves the view from section to section. However, if the ...

Understanding the read status of WhatsApp messages

I am seeking assistance with HTML layout and dynamically parsing content. My objective is to parse contacts who have read a specific message in the group. I have attempted to examine the DOM structure for the DIV block that contains these contacts, but it ...

Issue with customizing Bootstrap5 table colors based on themes

In my latest project, I decided to customize Bootstrap 5.1.3 using Sass in order to introduce some new color themes to the panels. I quickly realized that customizing Bootstrap 5.1.3 is not as straightforward as it was with Bootstrap 4. After updating my ...

What are the best methods for extracting real-time data from Yahoo Finance streaming services?

Yahoo finance streaming employs a unique method where a file gradually grows in size to continually update their data: ^FTSE Is there a way for me to gather this data (I have no intention of selling it- just looking to create my own beginner trading dash ...

Click on an element using jQuery to apply a specific class to all other similar

I am looking to dynamically add a class to a DIV after clicking on an A element with the same class. Here is an example: <ul> <li><a href="#1" class="test1">1</a></li> <li><a href="#2" class="test2">2</a>< ...