CSS Tutorial
<picture>
: Detta element låter dig ange flera bildkällor för olika storlekar och enheter.srcset
-attribut: Detta attribut anger en lista över bildkällor med deras respektive bredd. Exempel: srcset="/bild-100w.jpg 100w, /bild-200w.jpg 200w, /bild-300w.jpg 300w"
(max-width: 600px) 100w, (max-width: 900px) 200w, 300w
picture {
max-width: 100%;
}
source {
display: none;
}
source[media="(max-width: 600px)"] {
display: block;
}
@media (min-width: 601px) and (max-width: 900px) {
source[media="(max-width: 900px)"] {
display: block;
}
}
@media (min-width: 901px) {
source[media="(min-width: 901px)"] {
display: block;
}
}