background preloader

Making SVGs Responsive with CSS

Making SVGs Responsive with CSS
An article on how to make embedded SVGs cross-browser responsive. We're going to cover embedding techniques, how to apply the "Padding Hack" and how to use inline media queries to make SVGs adaptive. An SVG can be embedded on a web page in many ways; one of which is embedding it inline in an HTML5 page using the <svg> tag. The other commonly used techniques include embedding it as an image using the <img> tag, embedding it using the <object> tag, using an iframe, and as a CSS background image. Conceptually, making an SVG scale as its container scales should be as simple as removing any fixed height and/or width, and specifying a viewBox attribute value. That said, there are certain “fixes” and hacks that we can use to get the expected behavior in all browsers. Making SVGs Fluid Using CSS In order to make an SVG fluid, the first logical thing to do is to remove the height and width attributes. We’ll be using the following SVG nautical logo in the demos. SVG embedded using <img> Wrapping Up

Effortless Style by heydon Complaints dept: @heydonworks My Summer Job In Situ (photo: Ars Technica) The Unit is an Axiom listlessliked a drinkprobably had a cigarette in one hand shit at soldering When you're worried about your CSSbeing "future proof"... (photo: justjimwilldo) (photo: monkeyc.net) Now I'm even when it's not obvious :p The Separation Of Concerns "HTML should allow separation of content and presentation. Design Principle <center><ul face="arial"><li><font color="white" size="2">A list item</font></li><li><font color="white" size="2">Another list thingy</font></li></ul></center> <ul><li>A list item</li><li>Another list thingy</li></ul> Maintainable code base? Efficiency? Interoperability! Victoria talented writerweb savvywilling to learn new skills (metalanguage) not a designer + doesn't want to be(photo: carbonNYC) <ul class="menu"><li class="menu__item">first item</li><li class="menu__item">item number two</li></ul> Can't be created with MarkdownTextileWYSIWYGsStandard HTML Let's not ask a writer to be a designer

Breakfast with Ethan Marcotte: Part Three of Three | The Pixel Lab Breakfast with Ethan Marcotte: Part OneBreakfast with Ethan Marcotte: Part Two Ethan: I think it’s interesting to look at the changing demographic of the web as a lens to think better about performance, accessibility and reach basically. I could be wrong, but that’s where my head’s at. George: That’s where you think the future is? Ethan: Yeah, I mean the web is more broadly accessed right now than in any other point in it’s history, right? George: It’s not going to happen any time soon either. Ethan: I don’t think so – not without some massive changes. George: Hopefully people will start talking about it, right? Ethan: Yeah, to be fair I think a number of people are. “… it can be really powerful to look at some of your design assumptions through the lens of performance throughout the project.” - Ethan Marcotte George: So, what are you working on now? Ethan: I just finished up a Responsive web application for a large client and it was a really fun project. George: And, what’s next after that?

The Mobile Web Handbook — nearly done Page last changed today On Tuesday I delivered the final edits for The Mobile Web Handbook, my new book published by Smashing Magazine. Order it here. The book is a bit late; it was originally slated to appear in June. However, it’s really done now; you can expect the e-book in about a week and the physical book at the end of September. Writing a book about the mobile market and the mobile web is tricky. The Mobile Web Handbook. Here’s the table of contents: The Mobile World: How the mobile world differs from the desktop world. In general, and with my financial well-being in mind, I’d say everyone who reads this should buy it. The Boston Globe | Responsive Web Design You know, there’s—and I think the two of you may at some point or another heard me do this before—but a lot of times I really love the show, The West Wing. Not so much for the reason that’s it’s about the West Wing or American government politics, so much as there’s a lot of scenes in which they apply to life for the way that a business functions and stuff like that. And so, I kind of think it might be fun to use this allegory. The story is kind of an allegory of the way things… the culture shift that happened. Harkening back to my reference to “culture eats strategy for breakfast,” the culture of the Globe was that a stakeholder would make a request and file a request via our ticketing system if it was actionable, or would ask to have a meeting to talk about some kind of product request that they wanted to make. I think it was like the fourth season in which Mrs. And I love that scene because that is exactly how business decisions get made at major media companies.

RWD Podcast Episode #17 : Stephen Hay — Responsive Web Design Author: Justin AveryPublished: 28 Aug 2014Tags:Media Queries; Frameworks; Workflow; Performance; Mobile First; Layout; Typography; Progressive Enhancement; Content; CSS; Design; Design ToolsCategory: Podcast Stephen got started in 1995 and his first website was build using Server Side Image Maps. Want to see it? Unfortunately he isn't able to locate the site to share with us, but let your imagination run wild. Since then he's built a web design company called Cinnamon which he ran for 10 years before deciding to leave his own company and go out as an individual contractor. We talk about writing a book, the challenges, and the beauty of reading a real physical book over using a kindle. Responsive Design Workflow Start out with readable structured content. When people jump into responsive design start thinking about designing at each breakpoint. The good thing about frameworks is that you can quickly mock up layouts that are responsive and you can show your clients exactly what you mean.

RWD Podcast Episode #16: John Allsopp — Responsive Web Design Author: Justin AveryPublished: 22 Aug 2014Tags:Performance; Mobile First; Progressive Enhancement; Element QueriesCategory: Podcast When first writing the article, A Dao of Web Design, John realised that the medium of the web was one that would support a wide range of use cases. This was a feature of the web, not a bug. Although written in 2000 it wasn't until 2007 and the release of the iPhone that we began to understand what this truly meant. It still took another 3 years of building sites for people to decide it as wise to invest time and money into something that could provide a single source of content across the now quickly growing list of devices. This is where the timing of Ethan's article kicked off the whole responsive web movement. "I think it's now just web design" John ran a conference in Australia called Respond. Responsive email design is one of the problems that was discussed. Framing what the problems we are facing now that we've moved away from the layout.

Coming Soon: CSS Feature Queries | Web Platform Team Blog Feature Queries are part of the CSS3 Conditional Rules specification, and offer a native method of testing for CSS feature support. You can use Feature Queries to test whether certain CSS rules are supported, and optimize your page for the available set of features. Feature Queries have a number of stable browser implementations in Chrome, Firefox, and Opera, and at least one recent experimental implementation in WebKit. As browser support continues to increase, it’s probably worth taking a look to see if Feature Queries fit into your current projects. Feature Queries in CSS Feature Queries look like Media Queries, but test support for CSS property/value pairs rather than display characteristics. Let’s move on to a more realistic example. Altogether a great effect, right? The above code includes a single-color fallback if the semi-transparent color overlay isn’t supported. Feature Queries in JavaScript The Feature Queries specification also provides a JavaScript interface: CSS.supports.

Using Sass to Build a Custom Type Scale with Vertical Rhythm One way to achieve visual consistency in web design is to use a vertical rhythm. For a website, this would mean that no matter what font-size any text element is, its line-height is always an even multiple of a consistent unit of rhythm. When this is done precisely, you could put a striped background behind your page and each text block (paragraphs, headings, blockquotes, etc) would line up along the lines in that grid. As you could imagine, setting this up by hand would require a lot of math and typing. I’ll start off by admitting that there are already some good Sass plugins that help build a custom type scale with consistent vertical rhythm. Why Build Our Own? That raises a great question: With all those tools available, why should we try building our own? Before we start, let’s define what kind of type scale we’re going to build. One last detail for fun: We’ll be able to adjust the base font-size and line-height for various screen widths with a short media query mixin. Conclusion

Case study: Guardian Soulmates redesign | Info Toward the end of 2013 we faced two challenges with Soulmates: first, users had told us that the design looked a bit tired. Second, we had a mobile website which was lacking a lot of functionality, and was not very appealing visually. We decided to develop a responsive site and give Soulmates a makeover with a new branding at the same time. The new branding We worked with design agency Multiadaptor to create a fresh new branding for Soulmates. The thinking behind the new branding is best expressed on Multiadaptor’s own website. The challenges Creating a responsive site and implementing the new branding at the same time posed some challenges: Rolling it out all in one “big-bang” release would mean sudden, massive changes to the site, which could potentially be confusing to users. The approach At the Guardian we aim for an Agile approach not just as an engineering process, but also as a way of deploying changes to users in small increments. The responsive site The rebranding The learnings

Guardian beta · Introducing our new video pages This week we have launched a completely redesigned video player and a new design for our video pages. Over the next few days it will reach all 100 million of our global unique browsers. While our mobile readers have been using the new site for some time now, only five percent of our desktop users have seen it through our beta programme. The launch of our new video pages marks the first time that our many millions of global users will experience part of our new site. The first change many users will notice is the bold use of colour - greys and oranges - that will let our viewers know they are visiting a multimedia section of our site. Next, our video player has been redesigned in line with the new visual language that we are deploying across our beta site and that is already evident on our new Guardian App. Crucially, the new video pages are entirely responsive, meaning our video content looks exactly the same regardless of the platform, device and screen size it is being watched on.

Related: