zoukankan      html  css  js  c++  java
  • [HTML5] Show Different Variations of Images Depending on the Viewport Width using Art Direction

    For small viewports, we may want to show a variation of the desktop image. A very common use case of this is a cropped, smaller version of the desktop image. In this lesson, we are going to discuss showing a cropped version of the desktop image, but only for smaller viewports.

    <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, maximum-scale=1" />
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/marx/2.0.7/marx.min.css">
      <link rel="stylesheet" href="style.css">
    </head>
    <body>
    
      <picture>
        <!-- Show a cropped size image -->
        <source
          media="(max- 500px)"
          srcset="https://imgur.com/SXwenFN.jpg"
          sizes="90vw"
        >
        <img
          src="https://imgur.com/stCVVhQ.jpg"
          alt="Mother sheep and her lambs chilling in a field"
        >
      </picture>
        
    
      
    </body>
    
    </html>
  • 相关阅读:
    数据放在服务端和客户端的利与弊
    python异步I/O并发
    view
    mysql千万或者上亿的数据怎么设计数据库
    Django(一)
    JQuery
    BOM与DOM
    JavaScript
    CSS(二)
    CSS介绍
  • 原文地址:https://www.cnblogs.com/Answer1215/p/9832377.html
Copyright © 2011-2022 走看看