Solved

Hero image adjusting/revealing based upon browser width

Posted on 2014-02-25
5
367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2

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 2

Author Closing Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

733 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