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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:00:01+00:00 2026-05-31T20:00:01+00:00

I am trying to use JavaScript to set an elements width relative to their

  • 0

I am trying to use JavaScript to set an elements width relative to their screen resolution width. I’ll explain a bit why… I have this image: https://i.stack.imgur.com/HeXvu.png

I want this to be my header, by I don’t want it to be a fully static image, I want the header to scale with the screen resolution, so I set up my CSS and HTML something like this…

HMTL:

<html>
    <body>
        <div class="globalContainer">
            <div id="headerMain">
                <div class="headerLeft">
                </div>
                <div class="headerRight">
                </div>
            </div>
        </div>
    </body>
</html>

CSS:

#headerMain {
    height: 79px;
    background-image: url(../img/global/middleHeader.png);
    background-repeat: repeat-x;
}
.headerLeft {
    width: 63px;
    height: 79px;
    background-image: url(../img/global/leftHeader.png);
    background-repeat: no-repeat;
    float: left;
}
.headerRight {
    width: 63px;
    height: 79px;
    background-image: url(../img/global/rightHeader.png);
    background-repeat: no-repeat;
    float: right;
}

Now, what I am trying to do here is, have predefined widths and heights for the left and right cured parts of the header, and use initial header div (with the middle image set as background). The only problem I have encountered here is this, the background of the main div (one with the middle part of the header), shows behind the image that is the right curve of the header, like this: https://i.stack.imgur.com/XEq85.png

How do I get around to doing this? One way I could think of was to use JavaScript. Here’s what I was thinking, first the script fetches the users screen width using “screen.width,” then subtract “63” from the value (the width of the right curved part of the header), and set that value as the main header element’s width, which should theoretically fix the background issue. The only problem is, I have little to no JavaScript experience and don’t know how to do anything, the only reason I know of the few things I do, is mostly because I have copy/pasted a few other JS codes in a few of my pages… Yeah. Pretty bad. So, what do I do? o_o

  • 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-31T20:00:02+00:00Added an answer on May 31, 2026 at 8:00 pm

    You could try taking the left and right header divs out of the headerMain div and placing them at the same level in the DOM. Then use this modified CSS:

    #headerMain { height: 79px; background-image: url(../img/global/middleHeader.png); background-repeat: repeat-x; position:absolute; top:0px; left:63px; right:63px;} 
    
    .headerLeft { width: 63px; height: 79px; background-image: url(../img/global/leftHeader.png); background-repeat: no-repeat; position:absolute; top:0px; left:0px;} 
    
    .headerRight { width: 63px; height: 79px; background-image: url(../img/global/rightHeader.png); background-repeat: no-repeat; position:absolute; top:0px; right:0px;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to use Pixastic JavaScript library for image manipulation in Windows 8
I am trying to use an HTML form and javascript (i mention this, because
I'm trying to use the replace function in JavaScript and have a question. strNewDdlVolCannRegion
I'm trying to wrap my head around Javascript's function.apply(). You use it like this:
I'm trying to set the width and height of an element with javascript to
I'm trying to use javascript to code up a dynamic form, where elements are
I'm trying to set the width in percent (80%) of the Facebook code.This doesn't
Trying to figure out a way to use Javascript to set up a little
I am trying to use JavaScript to start a marquee when a user puts
I am trying to use the flXHR javascript library for making cross-domain calls. I

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.