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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:51:02+00:00 2026-05-11T21:51:02+00:00

I have a situation where I think using the ’em’ metric would be perfect.

  • 0

I have a situation where I think using the ’em’ metric would be perfect. I have a container with several elements inside. These elements all use em for dimensions, font-size, borders.. everything. I want to be able to grow or shrink all of these elements dynamically by simply changing the em value of the parent container.

At least that’s my theory. I tried to implement something like this using jquery but it appears that everything is converted to px and changing the em has no effect on the child elements.

Here is an example:

<div id="parent">
     <div class="child">Text</div>
     <div class="child">Text</div>
     <div class="child">Text</div>
</div>

<style>
    #parent { font-size: 1em; }
    .child { width: 10em; height: 10em; font-size: 5em; }
</style>

With javascript (jquery for this example), I would like to be able to do something like this:

$('#parent').css('font-size', '2em') // This would make everything grow
$('#parent').css('font-size', '.5em') // This would make everything shrink

This line does not produce an error. However, after inspecting further it appears that everything has been converted to px value. Thus, parent em values lose their power. Here is what I mean:

After the page renders, I run these commands through the firebug console

$('#parent').css('font-size'); // Returns 100px (for example's sake)
$('.child:first').css('font-size'); // Returns 50px
$('#parent').css('font-size', '2em'); // This should affect all children
$('#parent').css('font-size'); // Returns 20px
$('.child:first').css('font-size'); // STILL Returns 50px

As you can see, all the children remain at 50px.

Am I going about this the right way? What am I missing? Is this really a lot harder than I think it is? In a sense, I’m trying to duplicate the effect that browser-zoom has.

Thanks for any help.

  • 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-11T21:51:02+00:00Added an answer on May 11, 2026 at 9:51 pm

    You try resizing the text using percentage.

    $('#parent').css('font-size', '200%')// This would make everything grow
    $('#parent').css('font-size', '50%') // This would make everything shrink
    

    edit after comment – using FF2.0

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"  "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
        <title>test</title>
    <script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script>
        <style type="text/css">
        body {font-size:10px;}
        #parent { font-size: 1em; }
        .child { width: 10em; height: 10em; font-size: 5em; }
    </style>
    
    <script type="text/javascript">
      $(document).ready(function(){
            alert($('#parent').css('font-size')); // Returns 10px (for example's sake)
            alert($('.child:first').css('font-size')); // Returns 50px
            $('#parent').css('font-size', '200%'); // or you can use 2em here
            alert($('#parent').css('font-size')); // Returns 20px
            alert($('.child:first').css('font-size')); // Returns 100px
        });
    </script>
    </head>
    <body>
    <div id="parent">
         <div class="child">Text</div>
         <div class="child">Text</div>
         <div class="child">Text</div>
    </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have come across a situation (which I think is weird but is possibly
I would like to know how you normally deal with this situation: I have
Id columns can specify a generator. Perfect. However, I have a situation in which
I have the fallowing situation using vertex buffers in OpenGL on iPad: - render
Using c#, .net, Visual Studio 2010 I have a situation when a user clicks
I have a situation where I am using a third party library. On machines
Moin! I have a situation where I try to display an error message using
I have a situation that i have a hidden div with two input elements
I have a situation where I can use ToUpper() in codebehind or I can
I think I'm in somewhat of a unique situation: I have a decent amount

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.