89475

How can I make this image responsive?

Question:

I am trying to include a logo for my site. It needs to be responsive. With the following CSS the image is OK with width, but the top & bottom of the logo are not displayed. If the site was not responsive, I would just put height: 100px; underneath the width. How can I make all the logo display, including the top and bottom bits of it, but still make the logo responsive?

.header-image .site-title > a { background: url(images/logo.png) no-repeat left; float: left; width: 100%; }

The rest of the CSS which my be making the top & bottom parts of the logo to not be displayed, is below.

.title-area { float: left; padding: 10px 0; width: 360px; } .header-full-width .title-area { width: 100%; } .site-title { font-size: 32px; font-weight: 400; line-height: 1.2; } .site-title a, .site-title a:hover { color: #333; } .header-image .site-title > a { background: url(images/logo.png) no-repeat left; float: left; width: 100%; } .site-description { font-size: 16px; font-weight: 300; line-height: 1.5; } .site-description, .site-title { margin-bottom: 0; height: auto; /*added by me */ } .header-image .site-description, .header-image .site-title { display: block; text-indent: -9999px; }

I suspect that it is something to do with a container?

Answer1:

using a fixed height for an element doesn't automatically make a site "not responsive," but you might consider using min-height: 100px; (or whatever the correct height is) to ensure that important elements of the logo won't be hidden. Depending on what exactly the desired behavior is, you could also (or instead) set a relative height (e.g. height: 100%;)

Another possible approach is to use either the cover or contain keyword value for <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/background-size" rel="nofollow">the background-size property</a>

Recommend

  • is it possible to insert a line break in this tooltip?
  • Python PIL to extract number from image
  • Why does it draw lines in the wrong place?
  • Floated image with variable width and heading with background image
  • saving file generated by TCPDF
  • How to view images from protected folder with php?
  • How Lists (specifically, RecyclerView with CardViews) in Android work
  • Textfile Structure (tables)
  • How to have background script and something similar to a default popup?
  • HTTP/2 streams vs HTTP/1.1 connections
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Python urlparse: small issue
  • Google Custom Search with transparent background
  • Disable Enter in editText android
  • Android fill_parent issue
  • Change multiple background-images with jQuery
  • Syntax for setting draggablecursor property in google maps api
  • MongoDB in PHP using aggregate to group by _id is null not working
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Insert into database using onclick function
  • Display issues when we change from one jquery mobile page to another in firefox
  • Encrypt data by using a public key in c# and decrypt data by using a private key in php
  • Align navbar back button on right side
  • How to check if every primary key value is being referenced as foreign key in another table
  • Sending data from AppleScript to FileMaker records
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • vba code to select only visible cells in specific column except heading
  • To display the title for the current loaction in map in iphone
  • GridView Sorting works once only
  • Circular dependency while pushing http interceptor
  • How to get icons for entities from eclipse?
  • AngularJs get employee from factory
  • trying to dynamically update Highchart column chart but series undefined
  • python regex in pyparsing
  • How to set the response of a form post action to a iframe source?
  • Change div Background jquery
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?