?
Solved

Hero image adjusting/revealing based upon browser width

Posted on 2014-02-25
5
Medium Priority
?
372 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 2000 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

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

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

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.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
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…
Suggested Courses

800 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