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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T15:15:37+00:00 2026-05-21T15:15:37+00:00

I want to make the logo (in the top left corner) always keep its

  • 0

I want to make the logo (in the top left corner) always keep its aspect ratio, but I also want it to stay in the right place, for any browser. Here’s my code:

<body>
<img src="/home/istom/Dropbox/bcs logo border.png" width="25%" height="25%" style="position:absolute;top:6%;left:9.7%;z-index:1" />
<div style="position:absolute;top:12.5%;left:12.5%;width:75%;height:75%;border-style:solid;border-color:#6699cc;border-width:3px;background-image:url('/home/istom/Downloads/BCHands.jpg');background-position:95% 50%;background-repeat:no-repeat;background-size:60% auto;">
    <div style="float:left;position:relative;top:25%;left:5%;">Hello</div>
</div> 

If you use this code, and resize your window, you’ll see the logo is stretched infuriatingly out of shape. How can I make sure it keeps it’s aspect ratio?

PS: If anyone can tell me how to do the same for the background-image that would great.
PS: As little jQuery as possible (still, if jQuery is the only way…)!

  • 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-21T15:15:38+00:00Added an answer on May 21, 2026 at 3:15 pm

    If you specify only the width of the image, the height will automatically be adjusted to keep the aspect ratio (and vica-versa). So remove the CSS height declarations, or the width declarations, depending on what should determine the size.


    If you wanted to change which dimension is the deciding dimension based on the browsers aspect ratio, then you can use some JavaScript/jQuery to check. EG, tall skinny windows should have the width as the deciding dimension, and height should be used for wide short windows.

    $(window).resize(function(){
        if ( $(window).width() / $(window).height() < idealWidthHeightRatio)
            $("#the_img").css({width: "auto", height: "25%"})
        else
            $("#the_img").css({width: "25%", height: "auto"})
    
    })
    

    I think I got the css syntax correct, and the width/height would have to be defined using css, not attributes.

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

Sidebar

Related Questions

I am trying to make overlay over image while dragging but its also moving
I have link for example domain.com/de/controler/action?param=value and I want make actionlink to keep same
I want my navigation menu to have 3 links on the left, the logo
I want to make an animation of 2 div´s but I don´t succeed :(.
I want make datetimepicker in my project. Using jquery how it is possible? I
I want make a bash script which returns the position of an element from
I want make interactive application where user launches it and can do various task
Let's say I want make some of my sources publicly available via my blog
I am new android app developer i want make app for tablets and phone
I have style sheet with a class name changebackgroundcolor i want make change in

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.