What is the best way to adjust a horizontal list of inline elements to stack vertically when the div container is resized?

Here is the issue I'm facing (notice how the yellow tiles are overflowing):

(view image here) because my reputation points are not enough.

The screenshot above illustrates how the small yellow rectangles are extending beyond the boundaries of the grey box.

I would like the tiles to behave as shown in the simulated screenshot below:

(view image here) due to insufficient reputation points.

In essence, I want the dynamically generated JavaScript tiles to automatically conform to the limits of their parent container and shift down to a new row instead of overflowing.

These tiles are coded as follows:

<span class='tile'>Tile content</span>

...and they are created using JavaScript. The tiles are placed within a div:

<div id="conversionPanel" class="panel">
       <span class='tile'>Tile1</span>
       <span class='tile'>Tile2</span>
       <!-- additional tiles can vary in number -->
</div>

The CSS for the conversionPanel is simple: margin: 0 auto; width: 500px;

The CSS styles applied to the tiles are:

.tile {
   display:inline;
   padding:5px;
   margin:3px;
   border:1px solid white;
   /* Additional visual effects in css3 */
 }

If anyone could assist me with this problem, I would greatly appreciate it. I have searched extensively but haven't found a solution yet.

Answer №1

This code snippet makes it simple to style tiles as individual words within a centered panel. The CSS provided styles the panels and tiles accordingly.

   .panel {
     text-align: center;
     width: 300px;
   }
   .tile {
     display:inline-block;
     padding:5px;
     margin:3px;
     border:1px solid white;
   }

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 it possible to recognize when the mouse button is held down and the cursor is outside the viewport by using mouseleave detection?

Is there a way to detect when a user moves the mouse outside of the view-port, even if they are holding down the mouse button (for example, if the mouse is on the browser address bar)? In the code below, I am currently using mouseout and mouseleave to det ...

Utilizing JQuery to capture user input in a textarea and showcase it in a span element with key press

Is there a way to capture the user's input and display it in a span above the textarea? Specifically, how can I detect when the user presses the enter/return key (keyCode 13) and correctly insert a line break ( ) in the span? $('#InviteMessage ...

Utilizing Pagination in Python Django to Handle URL Identifiers

I'm encountering a small issue with the following code: Html Code : a href="{% url 'entertainment:novelsView' novel.id %}">buttonclass="pull-right btn btn-primary btn-xs">Link span class="fa fa-link"</span></button</a vi ...

Issue with the left margin of the background image

I am currently facing an issue with a series of background images that are supposed to fade in and out behind my content. These images are centered, wider than the content itself, and should not affect the width of the page. However, there is an unexpected ...

Programme for Server Login

After creating my own server, I attempted to implement a login feature to restrict access to its files. Unfortunately, using Javascript for this task proved to be insecure as usernames and passwords could easily be viewed in the source code: <form name ...

Dynamic collapsible containers

I discovered a useful feature on w3schools for collapsing elements: https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_collapsible_symbol However, I would like to reverse it so that all elements are initially shown when the page loads, and then ...

Initial page load experiencing issues with paroller.js functionality

Upon hard refreshing the page in the middle section, there seems to be an issue with the paroller js transform: translateY(); CSS effect not functioning properly on the <div class="col col-6" data-paroller-factor="0.4" data-paroller-type="foreground" da ...

Create a URL hyperlink using javascript

I am looking to create a link to a page that updates its URL daily. The main URL is where X represents the day of the month. For example, for today, July 20th, the link should read: In my JavaScript section, I currently have code that retrieves the cur ...

What is the location where UIWebView saves HTML5 offline files?

I'm curious about the location where HTML5 offline content is stored when saved from a UIWebView in an iOS app. Is it saved locally within my app's access, or somewhere else? ...

Securing Your WordPress Custom Form with Captcha

I have a unique form on my WordPress website that tracks IP addresses, checks referer pages, and validates email addresses. Despite these measures, I am still receiving spam subscriptions. I have tried implementing both Bestwebsoft CAPTCHA and really sim ...

Need help with styling for disabled autocomplete? Check out the attached image

I'm currently working with material-ui and react to create a basic form. Everything is functioning properly except for a small UI issue that I can't seem to figure out how to resolve. When I utilize the browser's auto-complete feature, the i ...

Correcting W3C validation issues is essential

I am encountering errors in my W3C validation process. Even though I have set <!DOCTYPE HTML> for my page, I continue to experience issues as shown in the image below. I have been trying to troubleshoot and resolve these errors without much success ...

Center-aligned video text overlay that adapts to different screen sizes for a responsive design

I am looking to showcase a full-width video with overlay text that is perfectly centered both vertically and horizontally on the video. The centering should adapt to changes in viewport width so that it remains centered at all times. Additionally, I would ...

Refreshing HTML tables with AJAX in Django

After going through all the posts here, I found that some are outdated and others don't quite match my issue. Apologies for bringing it up again. I have a basic HTML table with data in it. My goal is to update this data without refreshing the entire ...

Troubleshooting issues with media queries related to device pixel ratio

My media queries in LESS are functioning correctly on the desktop, but encountering issues when tested on an iPad2 or Samsung Galaxy 4 phone. It appears that the device-pixel-ratio is causing disruptions. I attempted to reduce the min-device-pixel-ratio to ...

What is the reason my CSS formatting isn't being applied in Vue.js?

As a newcomer to web development and vue.js, I've been struggling to style my code effectively. Below is an example of my vue.js code where I have created markup for a profile description using figure, figcaption, and image elements. Could you please ...

A dynamic 2-column website design featuring a mobile-friendly layout and an adaptable image

After searching through numerous resources on the topic, I have yet to find a solution to this particular challenge. Is it feasible to create a webpage layout with a text column on the left and an image column on the right that will seamlessly transition i ...

"Using Rails remote link to create a standalone 'button' element, not embedded in a line of text or a

In my current project, I am attempting to create an ajax "button" that mimics the functionality of a typical link_to "content", some_path, remote:true. The goal is to have this button swap out images to indicate different statuses when clicked (e.g. on/off ...

What is the best way to prevent table cell borders from encroaching on the padding area of the cell?

When dealing with table cell elements that have borders, it's common for them to not respect the vertical height of the cell containing them. Sometimes a child element's borders may overlap the padding or border of its containing cell. To prevent ...

Error message: Angular JS encountered an issue when trying to initiate the test module. The cause

When I run JavaScript within an HTML file and use AngularJS with ng-repeat function, I encounter this console error: angular.js:38 Uncaught Error: [$injector:modulerr] Clicking on the link in the error message leads to: Failed to instantiate module test ...