Solved

Hero image adjusting/revealing based upon browser width

Posted on 2014-02-25
5
360 Views
Last Modified: 2014-02-26
Hi -

I'm not really a CSS guy (just know enough to be dangerous) - and I've had a project land in my lap where I need to design a banner/hero image function that reveals/adjusts based upon browser width.

Is there a JQuery/CSS function or something similar (or some guidance you can provide) on how to accomplish this?

A good example would be on http://www.silveroak.com

Take a look at the header image.  The center point remains constant - revealing more/less of the image as you expand/contract the browser window.  That's the effect I'm trying to accomplish.  :)

Any suggestions?

Thanks ahead of time!
0
Comment
Question by:erzoolander
  • 3
  • 2
5 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39887765
That does not look like it really adjusts.  Check out the bootstrap framework which is a responsive framework of css and js/jquery.   They use the term jumbotron http://getbootstrap.com/examples/jumbotron-narrow/

Otherwise, you can either use media queries or a width as a percentage.
0
 
LVL 1

Author Comment

by:erzoolander
ID: 39890037
Well, the third image (the one with the trees) is the one that illustrates the concept best.  When you adjust the browser horizontal width - the center point of the image remains constant/aligned with the div beneath it - while cropping/revealing equally from left and right.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39890616
Like this? http://jsbin.com/yokadiwo/1/

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
  <style>
    .hero{
      background-image: url('http://www.silveroak.com/content/images/home/home_banner3_1.jpg'); 
      background-repeat:no-repeat;
      background-attachment:fixed;
      background-position:center; 
      background-size:cover;
      height: 300px;
      text-align:center;
      padding-top:50px;
      padding-left:50px;
      color:red;
    }
    
    </style>
</head>
<body>
  <div class="container">
  <div class="hero">I am hero</div>
  </div>  
</body>
</html>

Open in new window

0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 39890620
I think I broke jsbin...that link did not work for a bit. (which is why we delete link only answers)
0
 
LVL 1

Author Closing Comment

by:erzoolander
ID: 39890732
Perfect - thank you!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
This article discusses how to create an extensible mechanism for linked drop downs.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now