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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:50:53+00:00 2026-06-12T00:50:53+00:00

I have a problem with element positioning. I have a div element which further

  • 0

I have a problem with element positioning. I have a div element which further contains the svg path element. Mark-up is something like this :

 <div style="position:absolute;" class="svg">
  <svg xmlns="http://www.w3.org/2000/svg" version="1.1">
   <path id="path203" d="M150 0 L75 200 L225 200 Z" />
  </svg>
 </div>

I want to set the border around the path element when user mouseover the path. For this i have to access the height and weight of the path element and then set those value as an height and width of its parent div element. For this i used getBoundingClientRect(). Code :

 var box = document.getElementById("path203").getBoundingClientRect();
 $("#path203").parents("div.svg").css({ width: box.width + "px", height: box.height + "px" });

Here my problem is not fully solved by this i only get the border, but the position of div and its children path element is not the same both have different offset values. So for this i set the top and left for the parent div also :

 var box = document.getElementById("path203").getBoundingClientRect();
 $("#path203").parents("div.svg").offset({ left: box.left + "px", top: box.top });

Now by this div got the correct position but its child path element move away from its position. May be the reason is because the path element is the child of div element. So when we move div , all of its child elements will also move simultaneously. How can i change the parent div offset value without changing its child element offset ?

  • 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-12T00:50:54+00:00Added an answer on June 12, 2026 at 12:50 am

    You could take the svg outside of parent div and access the div directly via $('div.svg').

    Here is a fiddle: http://jsfiddle.net/FSQrz/

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

Sidebar

Related Questions

I have a problem positioning an element in certain browsers. I'm using the jQuery
I have a problem to load specific div element and show on my page
I'm developing a 3-column website using a layout like this: <div id='left' style='left: 0;
I have some HTML with the following approximate structure and positioning: <div class=grand-parent style=position:
I have a problem with element selection, i have a form and i want
I have a problem where an element is not showing on Opera nor Firefox.
HI! I have a problem with changing the name of a select element. I
I have the following problem, i have to know if an element has children
I've created a form with code and I have a big problem. Every element
I have a problem finding elements in XPath that's contains a certain string ignoring

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.