Solved

Hero image adjusting/revealing based upon browser width

Posted on 2014-02-25
5
369 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 53

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 53

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 53

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
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…
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…

696 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