Pinterest splash page in twitter bootstrap -


checkout pinterest's splash page - **(make sure logged out of account or wont see splash page.) image of macbook @ bottom, it's responsive , shrinks , expands depending on size of broweser window.

silly question... how it? , how can done using twitter bootstrap?

if @ <script> blocks on page, can see how it's done. it's resize listener. here's simplified version:

var htaboveimage = $content.height(),     naturalimageht = 450,     padding = 150,     minimageht = 100;  var changefunc = function() {     var windowht = $window.height();     var imageht = math.min(                       math.max(windowht - htaboveimage - padding, minimageht)                       naturalimageht,                   );     $image.height(imageht); }; changefunc(); $(window).on("resize", changefunc); 

there's no need update width too, because <img>s automatically resize proportionately when size 1 dimension in css. full code on pinterest updates padding on content above image keep vertically centered.

by way: chrome's developer tools friend when comes questions this! making careful use of these tools, takes minute see what's going on:

  1. right-click image > inspect element
  2. resize window , notice there's explicit height in px being set on tag, updating continuously. must done js. who's setting it?
  3. right-click tag > break on... > attributes modifications
  4. resize window again , hit breakpoint
  5. top of call stack buried in minified jquery code – generic code setting css property. what's highest non-jquery piece of code on stack?
  6. there's code!

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -