Advertisement
Guest User

css attr() responsive HD images ?

a guest
Jun 30th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.18 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>responsive image : span images v2</title>
  6.     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  7.    
  8.     <style>
  9.        
  10.         .img{
  11.             display: inline-block;
  12.             vertical-align: baseline;
  13.             overflow: hidden;
  14.             background-size: 100% auto;
  15.             background-position: 0 0;
  16.             position: relative;
  17.         }
  18.        
  19.        
  20.         /* simple marker */
  21.         .img[data-hdsrc]{
  22.             border:1px solid red;
  23.         }
  24.  
  25.         /* to show some attr() support */
  26.         .img:after{
  27.             content: attr(data-hdsrc);
  28.         }
  29.        
  30.         /* to use with a device pixel ratio media query */
  31.         .img{
  32.             background-image: attr(data-hdsrc); /* won't do it, neither url( attr(data-hdsrc) ) */
  33.             width: 400px;
  34.             height: 200px;
  35.         }
  36.        
  37.     </style>
  38.    
  39. </head>
  40. <body>
  41.    
  42.     <p>
  43.         <i class="img" data-hdsrc="url(http://lorempixel.com/800/400/city/6/highres/)">
  44.             some hidden alt replacement here ?
  45.         </i>
  46.  
  47.         Lorem ipsum dolor sit amet, consectetur adipisicing elit. Repellat, sit, corrupti dicta quod quo atque alias natus a unde voluptatem architecto perspiciatis modi perferendis ex odio similique deleniti voluptatum. Itaque.
  48.     </p>
  49.    
  50.  
  51.    
  52.    
  53. </body></html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement