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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:18:03+00:00 2026-05-27T09:18:03+00:00

HTML and CSS layout remains a bit of a black art to me, so

  • 0

HTML and CSS layout remains a bit of a black art to me, so I’d appreciate any help in what I’m trying to accomplish.

I’m in the process of creating a JavaScript API for our company’s “widget”, so that folks can include it on their websites. If the user presses a button within that widget, I want to increase the size of the widget, say from 300×200 to 600×400. So far so good, a little bit of JS and I’m happy. But there are two constraints:

(1) I want to “overflow” anything larger than 300×200 onto the page, i.e., I don’t just increase the size of the host <div> tag so that other elements on the page move out of the way; I actually want to cover over other elements in the page.

(2) I want to do this intelligently, so that if the widget is on the left-hand side of the page, it will expand to the right; if it’s on the right-hand side of the page, it should expand to the left; if it’s on the top, it should expand towards, the bottom; and if it’s on the bottom, it should expand upwards towards the top.

I presume that some appropriate combination of position/display/float CSS properties is what I’ll need – but I haven’t yet been able to wrap my head around the precise combination required.

Thanks in advance.

EDIT 12/8/11 –

Just for future reference, I ended up using the jquery UI position() overload to help me out with the positioning. This is the code that I ended up using:

// Create a placeholder object and then hide the engage display element.
var host = engageObject.getHost();
var engageHost = engageObject.getEngageHost();
var parent = engageObject.getParentElement();
this.mPlaceholder = document.createElement('div');
$(this.mPlaceholder)
    .width($(engageHost).width())
    .height($(engageHost).height())
    .css('float', 'left');
parent.insertBefore(this.mPlaceholder, host);
$(engageHost).hide();

// Update the host's layout
this.mOriginalHostPositioning = $(host).css('position');
this.mOriginalHostWidth = $(host).width();
this.mOriginalHostHeight = $(host).height();
$(host).width($(this.mConnectHost).width());
$(host).height($(this.mConnectHost).height());
$(host).css('position', 'absolute');

// If we would otherwise spill out of the window on the right or the bottom,
// make sure we expand in the correct direction.
var topLeft = $(parent).offset();
var right = topLeft.left + $(this.mConnectHost).width();
var bottom = topLeft.top + $(this.mConnectHost).height();
var posStr;
if (right > $(window).width()) {
    posStr = "right ";
} else {
    posStr = "left ";
}
if (bottom > $(window).height()) {
    posStr += "bottom";
} else {
    posStr += "top";
}
$(host).position({ my: posStr, at: posStr, of: parent });

Effectively, I create a new placeholder image that’s the same size as the original, unexpanded widget (engageHost), hide the original widget, and then position my new connectHost to the appropriate corner of the original parent element.

  • 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-27T09:18:03+00:00Added an answer on May 27, 2026 at 9:18 am

    I think the Z-Index property of CSS is what you’re looking for. Just pulling the entire div to a higher Z-Index may solve your problem. Alternatively you may want to reserve the space behind the widget. Use an empty div like this:

    <!-- The following div takes up the space behind the floating applet.  In your case 300x200 or 600x400 ect -->
    <div style="width:300; height:200; float:left;">&nbsp;</div>
    
    <!-- The following div is where your widget goes (floating above the rest of the page) -->
    <div style="position:absolute; left:0px; top:0px; z-index:2;"> 
        Your widget code here
    </div>
    
    
    <div style="clear:both">
        Other code on the website here.
    </div>
    

    Relevant W3 Schools:
    http://www.w3schools.com/cssref/pr_pos_z-index.asp

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

Sidebar

Related Questions

Are there any html/css checkers that are javascript based like JSLINT?
I am trying to build this very simple (visually speaking) layout using HTML/CSS that
I have an html/javascript/css project that i am trying to make an Android application
I have a quite complicated HTML/CSS layout which I would like to convert to
i need to find away to parse html and css layout to be able
What CSS is needed to create such an HTML layout: +--[li]---------------------------------------------+ |+--[div]-------------------------------------++---+| || A
I'm using this HTML,CSS and Javascript code (in one document together if you want
What is the best way (using HTML/CSS) to create an iTunes-style layout with the
I am having trouble generating a HTML/CSS layout. The best way to think of
I need to do with html and css such layout: left width is static

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.