CSS-Only Art Direction
How do I make an css-only art direction?
This is an experimental prototype of just using CSS to make images responsive with art direction.. What is a css-only art direction? How do you make a css-only art direction? This script and codes were developed by Joshua P. Larson on 23 July 2022, Saturday.
CSS-Only Art Direction - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CSS-Only Art Direction</title> <meta name="viewport" content="width=device-width" /> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ body { padding: 1rem; font-family: "Helvetica Neue", Helvetica, sans-serif; max-width: 50rem; margin: 0 auto;
}
figure { margin: 0 0 2rem; background: #efefef;
}
figcaption { text-transform: uppercase; font-size: 0.8em; margin-bottom: 1em;
}
img { max-width: 100%;
}
.picture { overflow: hidden; height: 66vmin; position: relative;
}
.picture img { max-width: none; width: 300%;
}
.picture.art-center img { transform: translate(-25%, -25%);
}
.picture.art-top-left img { transform: translate(-5%, -5%);
}
.picture.art-top-right img { transform: translate(-55%, -5%);
}
.picture.art-bottom-left img { transform: translate(-5%, -45%);
}
.picture.art-bottom-right img { transform: translate(-45%, -45%);
}
@media all and (min-width: 40em) { .picture { height: auto; } .picture img { max-width: 100%; transform: none !important; width: auto; }
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body>
<h1>CSS-only art direction demo</h1>
<p> This is a CSS-only implemantation of responsive images and art direction. There are four classes: art-center, art-top-left, art-top-right, art-bottom-left, and art-bottom-right to use in different situations.
</p>
<p> The following caveats exist for this technique:
</p>
<ul> <li>It depends on <strong>vmin</strong> and <strong>transform</strong> to make things happen. Sorry, IE8!</li> <li>The centered class doesn't really center it all the way. That needs to be fixed.</li> <li>The only breakpoint is set at 40em. There could theoretically be more added.</li> <li>A large image is still loaded on mobile. Might consider combining with a backend responsive images solution.</li> <li>I haven't tested it in anything but Chrome on Mac.</li>
</ul>
<figcaption>No art direction</figcaption>
<figure><img src="http://upload.wikimedia.org/wikipedia/commons/3/32/Discussion_%289601907576%29.jpg"/></figure>
<figcaption>Art direction: art-center</figcaption>
<figure class="picture art-center"><img src="http://upload.wikimedia.org/wikipedia/commons/3/32/Discussion_%289601907576%29.jpg"/></figure>
<figcaption>Art direction: art-top-left</figcaption>
<figure class="picture art-top-left"><img src="http://upload.wikimedia.org/wikipedia/commons/3/32/Discussion_%289601907576%29.jpg"/></figure>
<figcaption>Art direction: art-top-right</figcaption>
<figure class="picture art-top-right"><img src="http://upload.wikimedia.org/wikipedia/commons/3/32/Discussion_%289601907576%29.jpg"/></figure>
<figcaption>Art direction: art-bottom-left</figcaption>
<figure class="picture art-bottom-left"><img src="http://upload.wikimedia.org/wikipedia/commons/3/32/Discussion_%289601907576%29.jpg"/></figure>
<figcaption>Art direction: art-bottom-right</figcaption>
<figure class="picture art-bottom-right"><img src="http://upload.wikimedia.org/wikipedia/commons/3/32/Discussion_%289601907576%29.jpg"/></figure>
</body>
</html>
CSS-Only Art Direction - Script Codes CSS Codes
body { padding: 1rem; font-family: "Helvetica Neue", Helvetica, sans-serif; max-width: 50rem; margin: 0 auto;
}
figure { margin: 0 0 2rem; background: #efefef;
}
figcaption { text-transform: uppercase; font-size: 0.8em; margin-bottom: 1em;
}
img { max-width: 100%;
}
.picture { overflow: hidden; height: 66vmin; position: relative;
}
.picture img { max-width: none; width: 300%;
}
.picture.art-center img { transform: translate(-25%, -25%);
}
.picture.art-top-left img { transform: translate(-5%, -5%);
}
.picture.art-top-right img { transform: translate(-55%, -5%);
}
.picture.art-bottom-left img { transform: translate(-5%, -45%);
}
.picture.art-bottom-right img { transform: translate(-45%, -45%);
}
@media all and (min-width: 40em) { .picture { height: auto; } .picture img { max-width: 100%; transform: none !important; width: auto; }
}
Developer | Joshua P. Larson |
Username | jplhomer |
Uploaded | July 23, 2022 |
Rating | 3.5 |
Size | 4,086 Kb |
Views | 58,696 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Verge-Style Homepage Tiles | 5,147 Kb |
Seamless Scrolling Background | 2,535 Kb |
Webkit Text Masking | 1,975 Kb |
Lightweight Quiz Widget | 4,596 Kb |
JS Geolocator | 2,653 Kb |
Displaying a Google Street View of your current location | 2,275 Kb |
Populate Native HTML Datalist with AJAX | 2,763 Kb |
Responsive HTML Timeline | 3,137 Kb |
Animated Donut Chart | 3,808 Kb |
Fixed Nav HoverIntent Example | 4,444 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
APortfolio | Skybutterfly | 5,174 Kb |
Css or Czz.. | Judag | 4,111 Kb |
TweenMax transformOrigin Bubble | Nicolund | 2,209 Kb |
Vertical Pan Hammer.js example | Jtangelder | 2,144 Kb |
Light Switch | Bartuc | 4,933 Kb |
Lightrays v2 | Sinthetyc | 2,903 Kb |
CSS3 iPad | Vikvarg | 1,766 Kb |
Break Out | AzazelN28 | 12,431 Kb |
Wikipedia Viewer | Thalpha | 4,426 Kb |
SVG Animation | Pollardld | 3,133 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!