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 7515355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:46:52+00:00 2026-05-30T00:46:52+00:00

I have a site in PHP, the design is about 800 pixels wide and

  • 0

I have a site in PHP, the design is about 800 pixels wide and centered on the page.

I want to add a chat to it, so that when it opens, it fixes to the right side of the page (about 25% wide) and pushes the rest of the page over to the left, so that my design re-centres, but now having this chat ‘frame’ open on the right.

I don’t know if i’m explaining myself well, but I’ve got a chat and everything set up, and I know how to fixed position div tags to the right, it’s just the part about getting the rest of the page to recentre if the chat ‘frame’ is opened.

Is there anyway to do this without starting from base again?

eg. chat closed

--------------------------
|    ________________    |
|    |              |    |
|    |              |    |
|    |     site     |    |
|    |              |    |
|    |              |    |
|    ----------------    |
|                        |
-------------------------

eg. chat open

---------------------------
| ________________  |     |
| |              |  |  c  |
| |              |  |  h  |
| |     site     |  |  a  |
| |              |  |  t  |
| |              |  |     |
| ----------------  |     |
|                   |     |
---------------------------
  • 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-30T00:46:54+00:00Added an answer on May 30, 2026 at 12:46 am

    Pure CSS center-alignment of independent elements without known width is a canonically tricky thing to achieve, so I believe JavaScript is the solution here. The following solution wraps “site” and “chat” into a centered div, augmenting the width of the wrapper to account for the presence of the chat window:

             #wrapper
    ---------------------------
    | ________________  |     |
    | |              |  |  #  |
    | |              |  |  c  |
    | |    #site     |  |  h  |
    | |              |  |  a  |
    | |              |  |  t  |
    | ----------------  |     |
    |                   |     |
    ---------------------------
    

    With the following initial styles:

    #wrapper {
        margin: 0 auto;
        width: 800px; // <-- this needs to increase when chat is visible! 
    }
    #site {
        float: left;
        width: 800px;
    }
    #chat {
        display: none; // change to 'display: block;' to to reveal
        float: right;
        width: 200px;
    }
    

    Since JavaScript is needed to toggle the chat element, we can dynamically modify the width of #wrapper at the same time. Here’s an implementation that uses jQuery, which is recommended for reasons of code-conciseness, x-browser compatibility, and online community:

    $('#chatbtn').click(function(){
        var xcurr = $('#wrapper').width();
        var xtend = $('#chat').width();
        if ($('#chat').is(":visible")) xtend = -xtend;
        $('#wrapper').width(xcurr + xtend);
        $('#chat').toggle();
    });​
    

    That should do it!

    • Please see a DEMO.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Information: I have a site that has a design on index.php, and then you
I have a PHP site that uses a fairly common authentication scheme. The entire
In my live site I have php include() and require() that have full path
I have a site with URLs like this: http://domain.co.uk/subdir/page.php I have redesigned the site
I have a PHP-driven site that includes an XML stock feed, which is remotely
I have some code on my PHP powered site that creates a random hash
I have a Web site (PHP) that generates a CSV file (text/csv) with the
I have no idea about PHP. I have PHP site hosted on Server A.
I have an object oriented framework that uses a page design, where each page
I have an existing site in php running on Apache using the mod_rewrite plug-in.

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.