[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Hero image adjusting/revealing based upon browser width

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

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 54

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 54

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
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 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…
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…

656 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