Using CSS3 translate will result in children becoming relatively positioned

I am facing an issue with a sidebar that contains 2 divs.

<div class="sectionsContainer clearfix"><-- Sidebar -->
    <div class="leftSection pull-left">
        <p>Maor</p>
    </div>
    <div class="rightSection pull-right">
        <div class="backButton clearfix">
            <i class="fa fa-chevron-left fa-2x blueColor pull-left"></i>
            <p class="pull-left"><strong>Back</strong></p>
        </div>
        <button class="btn blueButton ng-scope" data-ng-click="openPopover()"><i class="fa fa-plus"></i></button>
        <div class="popover fade bottom in">
            <div class="arrow"></div>
            <div class="popover-content">...</div>
        </div>
    </div>
</div>

Both of them have the classes:

.leftSection, .rightSection {
     width:50%;
    -webkit-transition: all 0.5s ease;
    -moz-transition: all 0.5s ease;
    -ms-transition: all 0.5s ease;
    -o-transition: all 0.5s ease;
    transition: all 0.5s ease;
}

When I click on the Maor element, both leftSection and rightSection receive the "moveLeft" class:

.moveLeft {
    -ms-transform: translate(-100%,0); /* IE 9 */
    -webkit-transform: translateX(-100%); /* Chrome, Safari, Opera */
    transform: translate(-100%,0); /* Standard syntax */
    -webkit-transform-style: preserve-3d;
}

The outcome is that the "leftSection" div moves left along with the "rightSection" so only the "rightSection" is visible due to being under an "overflow:hidden" div.

The popover div properties are:

position:absolute;
top:0;
left:0;
max-width:276px;
padding:1px;
text-align:left;
background-color:#FFF;
background-clip:padding-box;
border:1px solid rgba(0,0,0,0.2);
border-radius:6px;
box-shadow: 0 5px 10px rgba(0,0,0,0.2);

Now, when I click on the:

<button class="btn blueButton ng-scope" data-ng-click="openPopover()"><i class="fa fa-plus"></i></button>

The popover div becomes positioned relative to the rightSection. After investigating, I found out this is due to the moveLeft class using the translate property.

Do you have any suggestions or ideas to solve this?

Answer №1

It appears that the translate function utilizes a relative position to move the elements internally. In cases where you have an absolute positioned element within a parent with relative positioning, the position is relative to the parent.

To address this issue, the only viable solution is to relocate the popover div outside of a parent with relative positioning. My preferred approach is to place it directly within the body tag:

<body>
    <div class="sectionsContainer clearfix"><-- Sidebar -->
        <div class="leftSection pull-left">
            <p>Maor</p>
        </div>
        <div class="rightSection pull-right">
            <div class="backButton clearfix">
                <i class="fa fa-chevron-left fa-2x blueColor pull-left"></i>
                <p class="pull-left"><strong>Back</strong></p>
            </div>
            <button class="btn blueButton ng-scope" data-ng-click="openPopover()"><i class="fa fa-plus"></i></button>
        </div>
    </div>

    <div class="popover fade bottom in">
        <div class="arrow"></div>
        <div class="popover-content">...</div>
    </div>
</body>

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

Exploring the intricacies of Jquery in Tapestry weaving

I am using jquery/datatable and I want to implement highlighting for selected rows. I found sample jQuery code that accomplishes this: var oTable; var giRedraw = false; $(document).ready(function() { /* Add a click handler to the rows - this could be use ...

Changing a complex array structure in javascript into a CSV format

I have a complex nested array that I need to convert into a downloadable CSV file. My current approach involves iterating through each array and subarray to build the CSV, but I'm wondering if there's a more efficient method available? Here is a ...

Performing an Ajax request to the server and then sending the retrieved data back to Charts.js

After extensively researching ajax, php, and related topics, I'm facing a challenge. I want to take an array retrieved from my database and integrate it into a chart.js script. The data retrieval seems fine as per Firebug inspection, but the issue ari ...

What causes AngularJS to alter my GET parameters when using $http?

I am currently making a basic GET request to a REST service in order to obtain a list of users and sort them by their usernames. Using jQuery, the process runs smoothly: $.getJSON('/api/users', { sort: { username: 'asc' } }, funct ...

Enhancing many-to-many relationships with additional fields in Objection.js

I have a question that I haven't been able to find a clear answer to in the objection.js documentation. In my scenario, I have two Models: export class Language extends BaseId { name: string; static tableName = 'Languages'; st ...

Koa and Stripe are patiently holding off on displaying the page

My current setup involves using koa and stripe for processing a one-time payment. Although the functionality is there, I'm facing an issue where the page renders before the 'data' assignment takes place. This results in the 'id' sh ...

Guide on how to execute jasmine tests coded in TypeScript for Node.js applications

I am eager to test my express application developed in TypeScript. I am utilizing jasmine for writing test cases, webpack for bundling TypeScript files to JavaScript, and karma as the test runner. Please locate the following files: // about.service.ts - ...

Every character entered in JSP should trigger an instant retrieval of the corresponding string in the servlet

Having a JSP file that contains a text field: <form action="someServlet" method=post> <input type ="text" name="user" id="uname"> <button type="submit" id="submit">Submit</button> </form> When typing each letter in the JSP, ...

How come this constant can be accessed before it has even been declared?

I find it fascinating that I can use this constant even before declaring it. The code below is functioning perfectly: import { relations } from 'drizzle-orm' import { index, integer, pgTable, serial, uniqueIndex, varchar } from 'drizzle-orm ...

Tips for properly panning across the canvas

I added event listeners to capture mouse movement, clicks, and releases in my code. canvas.addEventListener('mousemove', onMouseMove, false); canvas.addEventListener('mousedown', onMouseDown,false); canvas.addEventListener('mouseu ...

The user authentication is not recognized in the current session (Node.js, Express, Passport)

I have encountered an issue where req.user is undefined, despite my efforts to troubleshoot for over 4 hours. I even resorted to copying and pasting the server/index.js file from a friend's server, modifying the auth strategy to suit my own, but the p ...

Replace automatically generated CSS with custom styles

When using a Jquery wysiwyg editor, I have encountered an issue where it automatically adds code to the textarea at runtime. The problem arises from it inserting an inline style of style="width:320px" when I need it to be 100% width due to styles already ...

What is the most efficient way to iterate through an array to push properties into an object nested within another array?

I have been working on a small Angular application that functions as a scheduler, allowing users to input a Name, Start and End dates, and toggle a boolean checkbox through a form. One challenge I am facing is trying to assign the names entered by each use ...

Things, their examples and the impact of setTimeOut

I'm currently delving into object oriented programming in JavaScript. function doStock() { //my class var that = this; var nAntiFreeze = null; // timeout ID var getContent = function(oInPageContainer) { GM_log('Antifreeze, before clea ...

Update the background URL of a div element using an HTML tag

My question is about a CSS div with set dimensions and background that I want to change on hover. I am aware that this seems like a simple task, but what I really want to do is retrieve the background sources from within the HTML tag itself. For example: ...

When trying to insert JavaScript into the console, a section of the code fails to execute

In this code snippet, I am fetching the most common English words from Wikipedia, extracting all the words from the page, and then filtering out the commonly used words: // get table data from most common words var arr = []; $.ajax({ url: 'https:/ ...

Leveraging the AngularJS promise/defer feature alongside the Quickblox framework, learn how to efficiently upload images and subsequently upload public URLs to a custom

I am currently developing an application that requires users to upload 5 images of themselves. Using a backend-as-a-service platform like Quickblox, I have to create and upload blob files individually. Once each image is uploaded, I receive a success call ...

Looking to adjust the title font size when exporting DataTable to Excel?

Would like to customize the title of an excel file exported from Datatable. I attempted to implement a solution found on a stackoverflow post, but it ended up applying the customization to the entire sheet. $("#datatable").DataTable({ ...

"Exploring the functionalities of jquery .change() specifically in the

I have a jQuery change function set up to adjust the values of another select drop down whenever the user changes the month (to display the correct number of days). Everything works perfectly in most browsers, but Firefox seems to be giving me trouble :( ...

Place the div at the bottom of the container with a flexible height determined by the content-wrapper

Can anyone help with a css problem I'm having? I am trying to create two columns, each containing dynamic content and images at the bottom of the column. Here is an example image for reference: https://i.sstatic.net/pvOef.png I want these image bloc ...