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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:29:39+00:00 2026-05-26T18:29:39+00:00

I am trying to force the width of a div to the width of

  • 0

I am trying to force the width of a div to the width of a browser window. So that even if the window is resize the adjusts it’s width.

I have been researching for about an hour and have found odd bits and pieces such as .resize() but can’t find anything which works.

  • 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-26T18:29:40+00:00Added an answer on May 26, 2026 at 6:29 pm

    Without a container limiting the width, a div should span the width of the browser window by default. You can explicitly set the width to 100%, but that shouldn’t be necessary:

    <div style="width:100%;">Hello world</div>
    

    I think CSS is more appropriate here, but you can do this in jQuery like this:

    $("#div1").width($(window).width());
    

    To run the above code whenever the window is resized, you can do this:

    $(window).resize(function(){
        $("#div1").width($(window).width());
    });
    

    Here’s a jsFiddle. For the sake of demonstration, the div expands on button click.

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

Sidebar

Related Questions

i'm trying to force a div to have a certain height depending on his
Situation: I'm trying to refresh the graph ( Force Directed ) on window.resize .
I'm trying to use jQM-DateBox with data-option timebox in Force Clock Mode, to have
I have a stupid WinCE application where I'm just trying to force an exception
I'm trying to display a number of images horizontally inside of a fixed-width div.
I'm trying to display a number of div (boxes) horizontally inside of a fixed-width
i am trying to figure this out: i have some html and php: <div
The following grid and container(s) do not have a fixed width. I'm trying to
I am trying to inspect the div element that appears for Tipsy hover-overs on
I am trying to force HTTPS on a domain. It must be done using

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.