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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:00:07+00:00 2026-06-10T13:00:07+00:00

I tend to make a division that width = window.innerWidth; height = width/5; 1/5

  • 0

I tend to make a division that width = window.innerWidth; height = width/5;
1/5 acturally is the background-image’s height/weith ratio.
So I write the code as below.

HTML:

<!DOCTYPE HTML>
<HTML>
<HEAD>
    <TITLE>FORM</TITLE>
    <META CHARSET="gb2312" />
    <LINK REL="stylesheet" HREF="css/style.css" />
    <SCRIPT TYPE="text/javascript">
        function onload(){

            //innerWidth of the window 
            var window_innerWidth;
            //height of DIV#head
            var head_height;
            //DIV#head
            var head_div;
            //btn
            var left_btn;

            window_innerWidth=window.innerWidth;
            head_height=window_innerWidth*120/600;
            head_div=document.getElementById("head");
            left_btn=document.getElementById("head_left_btn");
            right_btn=document.getElementById("head_right_btn");

            if(head_div&&left_btn){
                head_div.width=window_innerWidth;
                head_div.height=head_height;


                alert(window_innerWidth+ " " +head_height + " " + head_div.height 
                    + " " + left_btn.height);

            }

        }
    </SCRIPT>

</HEAD>
<BODY onload="onload();">
    <DIV ID="head">
        <BUTTON ID="head_left_btn" class="btn_hide" TYPE="button"></BUTTON>
        <BUTTON ID="head_right_btn" class="btn_hide" TYPE="button"></BUTTON>
    </DIV>

</BODY>
</HTML>

CSS:

#head{

background-image: url('../img/basic_.jpg');
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
background-size: cover;
}


.btn_hide{

width: 49.5%;
height: 100%;
opacity: 0.5;
}

The img I use as background is 600px*120px

What I am exactly doing is trying to make a head tabs. The problem is that while the width of the division goes right with javascript, the height doesn’t. Though the output from alert shows the value of the height is right, the display of the page is not. Can anyone help here? Many thanks!

  • 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-10T13:00:09+00:00Added an answer on June 10, 2026 at 1:00 pm

    Try this:

    head_div.style.height = head_height + "px";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tend put multiple lines of code that fullfill a certain task into blocks,
I try to make my code fool-proof, but I've noticed that it takes a
I have noted over the years, that I tend to write maybe a screen
I've worked on a number of products that make use of code generation. It
I tend to add lots of assertions to my C++ code to make debugging
Coming from the MS SQL world, I tend to make heavy use of stored
I'm making a website that tend to handle all the request in one page
I tend to make a lot of folders and when doing OO I put
Is there any reason that will make you use: add2 = lambda n: n+2
I have observed for a while that C# programmers tend to use int everywhere,

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.