Can a rotationX be applied within an existing rotationX?

I have a collection of 3 divs labeled a, b and c inside a container. The container is rotatedX by 90 degrees, giving the appearance that it is "lying on its back". Now, I am trying to rotate the a, b, and c divs so they appear to be "standing up" again. However, I am facing difficulties in achieving this effect. To better illustrate my issue, I have created a fiddle.

<div class="container">
    <div class="inner-container">
        <div class="a box"></div>
        <div class="b box"></div>
        <div class="c box"></div>        
    </div>
</div>

.container { position:relative; }
.inner-container { margin-left:100px; margin-top:100px; width:200px; height:200px; background-color: rgba(255,0,0,1); left:0px; -webkit-transform: rotateX(90deg); position:absolute; }
.box { width:50px; height:50px; position:absolute; -webkit-transform: rotateX(0deg); }
.a.box { background-color:green; bottom:0; left:0; right:0; margin:auto; }
.b.box { background-color:blue; top:0; left:0; }
.c.box { background-color:yellow; top:0; right:0; }

https://jsfiddle.net/tyf5vdj2/2/

Answer №1

To achieve the desired effect, applying transform-style: preserve-3d to the .inner-container is necessary.

.container { position:relative; -webkit-perspective: 1000;}
.inner-container { margin-left:100px; margin-top:10px; width:200px; height:200px; background-color: rgba(255,0,0,1); left:0px; -webkit-transform: rotateX(90deg); position:absolute; -webkit-transform-style: preserve-3d}
.box { width:50px; height:50px; position:absolute; -webkit-transform: rotateX(0deg); }
.a.box { background-color:green; bottom:0; left:0; right:0; margin:auto;   transform: rotateX(45deg);}
.b.box { background-color:blue; top:0; left:0; }
.c.box { background-color:yellow; top:0; right:0; }
<div class="container">
    <div class="inner-container">
        <div class="a box"></div>
        <div class="b box"></div>
        <div class="c box"></div>        
    </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

Utilizing the Bootstrap grid system to dynamically adjust column width based on specific conditions

When working with HTML and bootstrap (3.7) CSS, I often come across this issue: <div class="row"> <div class="col-xs-6">Stretch ME!</div> <div class="col-xs-6">Conditional</div> </div> Sometimes the "Conditional" d ...

Choose a checkbox by targeting a specific column value with XPath

While automating the testing with Selenium, I encountered an issue related to selecting a checkbox in a table row. To resolve this problem, I turned to XPath for assistance. Specifically, I needed to choose the row based on the file name. Below is the rele ...

Problem with CSS hovering on images when hovering on links?

While attempting to add 2 hover images to my website, I encountered an issue where a black border appeared in the middle of the images. This was caused by the hover effects on the links. Below is the code snippet: a:hover,a:active { color:Black; o ...

Differences in React projects utilizing materialize-css compared to those using react-toolbox or material-ui

Is there a difference in technical benefits or code reliability when directly using material-css in JSX versus utilizing JSX specific libraries like material-ui or react-toolbox? Conversely, could using JSX libraries like material-ui or react-toolbox provi ...

Tips for creating a fixed footer that adjusts with a flexible wrapper

Feeling incredibly stressed, I embarked on a quest to find the perfect sticky footer. After searching Google for what seemed like an eternity, I came across multiple tutorials recommending the use of min-height:100%. However, this approach caused the wrap ...

The conditional comment designed for browsers other than Internet Explorer may not work properly on outdated versions of

I find myself in a predicament where I must dynamically load one of two stylesheets depending on the browser accessing the page: If any browser other than IE, then load the "new" stylesheet If IE is version 9 or higher, then load the "new" stylesheet ...

Achieve consistent column heights with flexbox styling

I have a solution for achieving equal height columns using the CSS property display:table. Here is an example: .row { display: table; width: 100%; } .col{ display: table-cell; } However, in my case, I am using flexbox and the row class has ...

Perform time update every second

Is it feasible to have my timeupdate function run every second? (Using VUE CLI) @timeupdate="videoSecond" videoSecond(){ let Second = this.player.currentTime(); let CaptureList = this.capturesList; CaptureList.forEach(element => ...

Adjust the state based on the event in ReactJs

I have the following code snippet in a React JS application: const items = [ { value: "A", label: "A" }, { value: "B", label: "B" }, { value: "C", label: "C" }, { value: "D", label: "D" }, { value: " ...

Enhance User Experience with the Tooltip Feature and Customized

Here is the jQuery code I am using to style my tooltips: $(function() { // select all input fields within #tooltips and attach tooltips to them $("#tooltips :input").tooltip({ // place tooltip on the right edge position: "cen ...

What is the best way to align two span tags to the right on separate lines?

I am facing an issue with the positioning of three span tags: A is floated left while B and C are floated right. My desired layout is to have C positioned below B, both floating right on separate lines. I attempted using display:block for B but it did not ...

Display the header of the table after a page break in HTML using CSS

I have a unique question that is somewhat similar to others I've come across, like CSS: Repeat Table Header after Page Break (Print View). The difference in my question lies in the need for handling multiple headers. My query is about displaying the ...

The background image on Nuxt.js is not adapting to different screen sizes

My journey with developing a Nuxt app hit a snag in the CSS department early on. The issue plaguing me, as is often the case, is responsive background images. Everything looked great during testing on desktop browsers, but when I opened it up on my mobile ...

When converting a block formatting context into a block, the margin does not collapse

It seems that the behavior of margins collapsing between block elements inside and outside a BFC is not as straightforward as expected. For instance, when a button element's display property is set to inline-block, it forms a BFC, which should prevent ...

Tips for adjusting the width of items within the Box element in Material UI React

I am utilizing React Material UI along with the Box component to style my form. In this scenario, I have 4 items in each row except for the last row where I need to display only 3 items with the last item filling the entire row by merging two elements toge ...

Is it possible to modify this code to accept multiple IDs at once?

I'm attempting to create a form in JavaScript where, upon entering the necessary details and clicking submit, the user's email client opens with the information pre-filled for easy sending. However, I am facing challenges as my code involves mult ...

When it comes to creating a CSS drop-down menu, don't forget to incorporate an additional <ul

I've created a drop-down menu using CSS with 5 visible list items. When hovering over one of the list items, it highlights and triggers a drop-down effect to display another list underneath. Essentially, you have an initial set of options, and upon ho ...

Align an image in the center of a div without using absolute positioning

I'm currently facing an issue where I need to align an image at the center of a div without using absolute positioning. This is necessary because the image spills over into any adjacent divs on the page. Specifically, I have a previous div containing ...

What is the best way to define relative paths for content like CSS files?

Whenever I link to a file, I always find myself having to include the entire absolute path like this <link rel="stylesheet" type="text/css" href="F:/XmppOld/XAMPP2/htdocs/MAIN_SITE_LAYOUT/css/stylemainpage.css" /> I want to simplify it to ...

What is the best way to center align the button on my card?

I am having trouble aligning the "Check Github" button in the center of the card. I have tried using item-align: center;, justify-content:center;, and margin-right: 50px; but none of them seem to work on this particular element. Can you please provide guid ...