Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 318811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:36:15+00:00 2026-05-12T08:36:15+00:00

I have a <div> with the CSS rule margin: 0 auto; and I’m using

  • 0

I have a <div> with the CSS rule margin: 0 auto; and I’m using MooTools to slide it when necessary.

It seems that the mere instantiation of an Fx.Slide object removes the margin on my element. That is, whereas the element used to be centered inside its parent, it is now left-aligned. Just this line alone seems to do this:

var slide = new Fx.Slide('mydiv');

I can counteract this effect by doing something like this:

var slide = new Fx.Slide('mydiv');
$('mydiv').setStyle('margin', '0 auto');

But this is crude and I certainly don’t want to have to do this every time I come across this situation. And even more so, I want to know, why does MooTools remove the margin in the first place? Is there an option I don’t know about, some parameter I’ve neglected? Please let me know, as I’m new to MooTools. While I’m quickly finding that its applications are far and above those of jQuery (at least for my purposes), I’m finding that its documentation is much less verbose than its syntax.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:36:15+00:00Added an answer on May 12, 2026 at 8:36 am

    From Fx.Slide.js:

    Fx.Slide = new Class({
    
        /* .. */
    
        initialize: function(element, options){
            this.addEvent('complete', function(){
                this.open = (this.wrapper['offset' + this.layout.capitalize()] != 0);
                if (this.open && Browser.Engine.webkit419) this.element.dispose().inject(this.wrapper);
            }, true);
            this.element = this.subject = document.id(element);
            this.parent(options);
            var wrapper = this.element.retrieve('wrapper');
            this.wrapper = wrapper || new Element('div', {
                styles: $extend(this.element.getStyles('margin', 'position'), {overflow: 'hidden'})
            }).wraps(this.element);
            this.element.store('wrapper', this.wrapper).setStyle('margin', 0);
            this.now = [];
            this.open = true;
        },
    
        /* .. */
    

    As you can see, Fx.Slide takes the element (this.element) you apply to it, wraps it in a wrapper div (this.wrapper) with overflow: hidden and the margin and position of the element and then removes the margin of the element.

    So removing the margin is by design. What I do not understand is why the margin is not transferred to the wrapper. You might have some CSS modifying plain DIVs in the parent element that is using !important and is preventing Fx.Slide from transferring the properties properly.

    Are you using MooTools 1.2.3 with the latest version of MooTools More (1.2.3.1)?

    Also, for Fx.Slide to work properly, your page needs to be in standards mode. Do you have an XHTML or HTML (Strict Or Transitional) doctype as the first thing in your markup? (No XML prolog). Worst case, if it still doesn’t work, use the following:

    $('mydiv').getParent().setStyle('margin', '0 auto');
    

    MooTools is great JavaScript framework to work with and I personally feel that it is way more powerful than jQuery (excluding the fact that jQuery has a huge community). Unfortunately, the More package (which is the equivalent of jQuery’s plugins) consistency is somewhat lacking in some aspects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 176k
  • Answers 176k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If any thing, it will be faster. If your php… May 12, 2026 at 3:20 pm
  • Editorial Team
    Editorial Team added an answer This is all explained by Google right here. May 12, 2026 at 3:20 pm
  • Editorial Team
    Editorial Team added an answer Fan'ing via the API is currently not possible. Most probably,… May 12, 2026 at 3:20 pm

Related Questions

I have a <div> with the CSS rule margin: 0 auto; and I'm using
I have a div with links in it. And I'm lining them up one
I'm currently using a combination of CSS and Div tags to achieve rounded corners
I have the following HTML scenario: <div> <input id=txt0 type=text /><input type=checkbox id=chk0 /></div>
I am using the AJAX autocomplete add-on to the <asp:textbox> control. I have everything

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.