CSS to Change the Order of Displayed Table Cells

I have created a web page layout using blocks set to display: table-cell. Everything is functioning correctly, but I am struggling to rearrange the cells within a row and I am curious if there is a way to achieve this or maybe an interesting trick that could help me accomplish it.

I want to make these changes exclusively through CSS and the use of display: table-cell :)

Thank you in advance for any guidance.

HTML

<div class="dtc">
    <div>Item1</div>
    <div>Item2</div>
</div>

CSS

.dtc{
    display: table;
    width: 100%;
}
.dtc > *{
    display: table-cell;
}

Current table:

+-------+-------+
| Item1 | Item2 |
+-------+-------+

Desired result:

+-------+-------+
| Item2 | Item1 |
+-------+-------+

Answer №1

Implement RTL for the parent element and LTR for its children to reverse the order.

.dtc { direction: rtl; }
.dtc > div { direction: ltr; }

It is crucial to include LTR for children to ensure proper text alignment.

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

Error arises when uploading csv files to Node.js with Multer due to an unexpected field presence

I'm currently working on implementing a file upload feature with the use of Node.js, Vue, and Multer. Below is the Vue.js front-end code: export default { data(){ return{ selected: "How do you want to input the data?", options: [ ...

Trouble with Leafletjs Routing Machine collapse button loading issue

In my project, I am using django 1.10.5, booststrap 4.0, and LeafletJs 1.0.3 along with the routing machine plugin and geocoder. However, I have encountered an issue where the collapse button of the control panel for the routing machine does not appear (it ...

Using the explode function to parse an XML file and extract the data into a unified array output

My XML file can be found here. I am currently parsing it using the following code: <?php $xml=simplexml_load_file('info.xml'); foreach($xml->testcase as $var){ $var=explode('/',$var->script); $module =array($var[2]) ...

Applying CSS Styles to a Single Class Only

I have been using Zurb's Foundation to customize the navbar with my own styles, which has been successful so far. However, I encountered an issue with the responsive behavior of the navbar when the viewing container size changes. The navbar adds a sec ...

Using jQuery to completely replace the DOM with new HTML content by utilizing the .load method

I'm currently facing an issue with a Captive Portal implementation on my website. Here's the scenario: go to any site, like www.php.net, and then in Chrome's console, execute the following code: $("html").load( "https://www.ccc.co.il/Suspe ...

What is the method to duplicate "subheadings" within an HTML table?

*I am facing a challenge with my HTML table that has col-span heading and related subheadings. I am struggling to find a way to repeat the subheading followed by the main heading. Below is the code snippet I have been experimenting with: <scri ...

Concealing items in a loop using Javascript

I need assistance with this issue. I am trying to hide text by clicking on a link, but it doesn't seem to be working correctly. Even though I tried the following code, I can't figure out why it's not functioning as expected. Is there a diff ...

Is your text appearing vertically in Internet Explorer?

I'm having an issue with my small single page website where the text in a form is displaying vertically instead of horizontally in Internet Explorer. The problematic part is related to "vehicle condition." Any suggestions on what I might be doing wron ...

An issue occurred while calling the Selenium web driver: the driver.get() function couldn't access the attribute "href" of the linked_url, resulting in a stale element reference

Currently, I am utilizing Python with Selenium to work on extracting links from Google search results. After successfully accomplishing this task, I am now attempting to navigate through these links one by one using a for loop and the driver.get() method: ...

What is the process for fetching a specific image from a database folder by referencing its name?

We have a collection of images stored in the uploads folder within the root directory. Our goal is to display a single image for each user profile. Each user's profile image file name is saved in the database table called user under the field profile ...

What steps can be taken to resolve the Parsing error that is caused by an Unexpected

Having trouble changing the text color and getting a Parsing error? Can someone help me find the error and suggest a solution? Check out my code below import React from 'react'; import react, { Component } from 'react' import { Platef ...

What steps are involved in linking Java with JavaScript?

After attempting to connect html and javascript using applet, unfortunately it was unsuccessful. I am curious if there is an alternative method besides applet to establish this connection. ...

The <img> tag needs to dynamically adjust its size based on the width of its parent element, while ensuring it does not exceed its original dimensions

I spent hours working on my tribute page project on codepen and managed to pass 9 test cases. However, no matter what I try, I just can't seem to pass the last test case. My CSS code: #img-div { display: block; filter: grayscale(100%); width: 1 ...

In CodeIgniter, the $this->input->post() function consistently returns an empty value

I'm encountering an issue where the value from an AJAX post always turns out empty. Even after confirming that the value is correct before the post, I'm unable to retrieve it using $this->input->post() HTML <?php if ($product_info-> ...

Browsing with PHP/HTML on Safari from Mac Os 10.6.5 seems to run at a sluggish pace

This is the program: <?php require_once 'swift-mailer/lib/swift_required.php'; $name = $_POST['name']; $email = $_POST['email']; $form_subject = $_POST['form_subject']; $form_message = $_POST['form_message ...

How to retrieve text content from a span element with Selenium WebDriver and C#

I am at a mental roadblock and can't figure out this puzzle. My goal is to retrieve the number "9" from the span with id = "lookupCount". No matter how much effort I put in, I just can't seem to make it work. Please lend me a hand, here is the pr ...

What is the best way to implement a front-end CSS style for text instead of a background style?

I have HTML text I want to style with a color like rgba(0,0,0,0.1), but I want the color to appear above or on top of the text, not below or behind it. Issue: How can I accomplish this? (CSS or JavaScript solutions are welcome). Thank you in advance for ...

Certain Android devices may experience compatibility issues with the web app

I am facing an issue with my webapp on Raspberry Pi, as it is not being recognized properly by all my Android devices. The server hosting the website is a Raspberry Pi 3 running Apache and everything is up to date. To protect privacy and security, all IP ...

Display one div and conceal all others

Currently, I am implementing a toggle effect using fadeIn and fadeOut methods upon clicking a button. The JavaScript function I have created for this purpose is as follows: function showHide(divId){ if (document.getElementById(divID).style.display == ...

Optimizing Rendering Performance: Comparing the Impact of Multiple Stylesheets vs. Single Dynamic CSS on Dynamic CSS

Currently, I am in the process of developing a website that supports "plugins" as external "displays". These plugins consist of custom full-screen HTML content managed by a client-provided JavaScript driver. The website engine utilizes an API to allow thes ...