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

  • Home
  • SEARCH
  • 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 7709311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T00:49:47+00:00 2026-06-01T00:49:47+00:00

I want a <div> that reacts and fits the screen window size. The <div>

  • 0

I want a <div> that reacts and fits the screen window size. The <div> is supposed to have the dimensions 2:3 So that the height is 3:3 and the width is 2:3. It is easy enough to make it in css by writing width: 200px; and height:300px;.

The thing is that I want the height of the <div> to resize depending on the screensize. And also I want the text inside of it to resize. I know it is possible by javascript or jQuery, but I really don’t know how. Something like taking the height and split it in three, and then times two, and then make .css({'width',newWidth});

And it should be about the same thing with the text inside of it.

I found the correct way to do it. I had to change a little bit, but it works now.

$(window).resize(function() {
var ratio = 0.6;
$('#hovsa').width($(window).height() * ratio).height($(window).height());
// instead of directly using "$(window).width() * ratio", you can call a method to
// calculate width and height each time window is resized.
})

I have changed the width to be height * ratio and it worked very well. The only thing I need to do now is to make the fontsize going the same way as well.

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

    As said before, it is better for you to use percent values if the size you want will always be the same.

    But, in other cases, if you need a fixed size for your div, or a calculated one, you can listen for window resizing event and do your css modification :

    $(window).resize(function() {
        var ratio = 0.8;
        $('#divId').width($(window).width() * ratio).height($(window).height() * ratio);
        // instead of directly using "$(window).width() * ratio", you can call a method to
        // calculate width and height each time window is resized.
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DIV that I want to touch the bottom of the screen
I want to show a div that serves as a loading screen when invoking
I have a div that I want to toggle between displaying or not when
I have a div that I want when user click on a button slideUp
I have a div set transparent with rgba and want on that div an
I have a contenteditable div that I want users to be able to select
I have a div that i want to apply two backgrounds to it. Basically
I want to have an inner div that sites inside different sized container divs,
You know what I mean? Like let's say we have: <div style=width:100px;font-size:10px>Some Text</div> But
I have a div that contains an iFrame and I want to ensure that

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.