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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:00:03+00:00 2026-06-17T10:00:03+00:00

http://jsfiddle.net/DAFHq/1/ <div id=gray-box> <div id=red-box></div> </div> I need the RED square to be positioned

  • 0

http://jsfiddle.net/DAFHq/1/

<div id="gray-box">
<div id="red-box"></div>
</div>

I need the RED square to be positioned 20px to the right of the gray box with scrolling content in it, while keeping it vertically aligned in the center.

It should remain positioned relative to the gray box while scrolling and when the screen is resized.

Any ideas? The jsFiddle is one I found and modified to show what I need, The vertical align is perfect, but I have no idea howto position it how I need it horizontally.

Maybe something with jQuery?

  • 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-06-17T10:00:05+00:00Added an answer on June 17, 2026 at 10:00 am

    Try this:

    var positionFoo = function() {
      $('#foo').css({
        'left': $('#bar').offset().left + $('#bar').width() + 20 + 'px',
        'top': ($(window).height() / 2) - ($('#foo').height() / 2)
      });
    };
    
    $(window).resize(positionFoo);
    positionFoo();
    

    You will also need to add position: fixed; to #Foo.

    Updated fiddle

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

Sidebar

Related Questions

http://jsfiddle.net/w9E4K/7/ <div id=parent> <div id=left>Left</div> <div id=right>Right</div> </div>​ #left { display: inline-block; width: 75%;
http://jsfiddle.net/jqrmh/ $(.one).position({ my: right top, at: right top, of: $(.main), }); I need to
http://jsfiddle.net/h2vMN/1/ I have a text box text inside it already, in the actual application
http://jsfiddle.net/WTELW/4/ The following works fine on JSFiddle, but doesn't seem to work right in
http://jsfiddle.net/ZDydm/ Here is what I'm trying to do.. div { border: 1px solid black;
http://jsfiddle.net/mjmitche/gq6En/78/ In this fiddle, if you drag the orange box into the white box,
http://jsfiddle.net/VTD9P/2/ $(button).click(function(){ $(body).append('<div class=vidminclose>X</div>'); }); $(.vidminclose).click(function(){ $(this).remove(); }); ​ ​why is it when i
http://jsfiddle.net/BXNE9/1/ I want to open div through anchor point using related link. when I
http://jsfiddle.net/Greg_J/R5ZHk/ I'm appending a div to a container and then animating the height. The
http://jsfiddle.net/V7BJM/ The text in the box is going to be dynamic depending on who

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.