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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:48:10+00:00 2026-05-30T08:48:10+00:00

I’ve been going crazy with this: I have a banner which is structured like

  • 0

I’ve been going crazy with this: I have a banner which is structured like this:

<div id="header-image-wrapper">
    <a href="#content-title" id="header-link">
        <img id="bannerimage" src="image source" />
    </a>
</div>

The images won’t always be the same width, and my client wants the image to be horizontally centered within the div. The div should have a maximum width of 1200px with overflow:hidden, so that if the image is larger than that, it will be centered and the excess on the left and right side will be cut off.

The only way I could think this would work was using javascript:

var imgWidth = document.getElementById('bannerimage').style.width/ 2;
document.getElementById('bannerimage').style.marginLeft = imgWidth;

But when I refresh the page, I get this error:

[cycle] terminating; zero elements found by selector

Does anyone know what that means, and why it’s happening? Also, if someone has a better solution to this problem, please share it as I’m at my wit’s end. 🙂

  • 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-30T08:48:11+00:00Added an answer on May 30, 2026 at 8:48 am

    Edit: (bottom one won’t work if the image is too big, like you said, but this one should) Put the image as the background of the a tag and position it center.

    <html>
    <head>
    <style>
    #header-image-wrapper {
    text-align: center;
    width: 1200px;
    overflow: hidden;
    }
    #header-link {
        background-image: url("<Path to Your Image>");
        background-position: center;
        background-repeat: no-repeat;
        display: block;
        width: 1200px;
        height: 300px;
    }
    </style>
    </head>
    <body>
    <div id="header-image-wrapper">
        <a href="#content-title" id="header-link">
        </a>
    </div>
    </body>
    </html>
    

    I would just use CSS here. Give the div an ID and then style it accordingly with “text-align: center”

    <head>
    <style>
    #imgDIV {
    text-align: center; //It's not only for text :)
    width: 1200px;
    overflow: hidden;
    }
    </style>
    </head>
    <div id="imgDIV">
       <img src="path to image">
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I would like to run a str_replace or preg_replace which looks for certain words
I have this code to decode numeric html entities to the UTF8 equivalent character.
link Im having trouble converting the html entites into html characters, (&# 8217;) 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.