Home » Development » CSS » Page 6
Use the CSS font loading API. Not supported in all browsers yet (MDN, W3C). You can call document.fonts to get a FontFaceSet object.
document.fonts.check('bold 16px Roboto'); // true or false
Use Font Face Observer – its a small @font-face loader and monitor compatible with any web font service. It will monitor when a web font is applied to the page and notify you. It does not limit you in any way in where, when, or how you load your web fonts. Unlike the Web Font Loader Font Face Observer uses scroll events to detect font loads efficiently and with minimum overhead.
Use jQuery-FontSpy.js, works by checking the change in width of a string.
Use Webfont Loader, if loading fonts from Typekit , Fonts.com, Google, Fontdeck or custom location.
This introduces the following events:
BackgroundCheck automatically switches to a darker or a lighter version of an element depending on the brightness of images behind it.
Pretty amazing and useful, when doing long one-pagers with switching section backgrounds and navigation elements hovering above them.
“Snappy is a PHP5 library allowing thumbnail, snapshot or PDF generation from a url or a html page. It uses the excellent webkit-based wkhtmltopdf and wkhtmltoimage available on OSX, Linux, Windows.”
SPLIT PANES / DOCKER allow you to display multiple areas, either side by side or one on top of each other. Nested layouts are often part of it. By dragging a divider that appears between the areas, the user can specify how much of the total width / height goes to each area.
I have been building a backend interface in the past weeks, that forced me to look into ways to organize the workspace more efficiently . I could code my own splitter, but is not a priority right now and makes no sense to always reinvent the wheel :)
Here some of the options out there…
This uses the jQuery UI draggable component and provides limited options :)
“Responsive FileManager is a free open-source file manager and image manager made with jQuery, CSS3, PHP and HTML5 that offers a nice and elegant way to upload and insert files, images and videos.
You can use it as external plugin for TinyMCE, CKEditor and CLEditor or as a stand-alone file manager to manage and select files.”
Responsive filemanager / GitHub
GoldenLayout is a web based docker layout engine that aids in creating flexible user interfaces by enabling panels to be docked on the screen.
GitHub & Demo
I am currently developing a drag and drop interface for a course builder. Courses are split into lessons and lessons into slides. While switching between slides, I wanted to have a small thumbnail representing the current slide content.
One option would have been to use something like PhantomJS / CasperJS. A headless browser , to take a screenshot of the slide. I have done that in the past and it works perfectly.
This time, I decided to go with another solution, that allows me to convert html to a canvas element.
The project is called html2canvas (GitHub).
“This script allows you to take screenshots of webpages or parts of it, directly on the users browser. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.”
I have a slide container (#slideContainer), that holds the active slide for editing and a thumb navigation to switch between slides (.slide.thumb).
When switching between slides, I am doing a snapshot of the current slideContainer and add it as a new background image to the thumb navigation item for that slide. This is done with canvas.toDataURL() and by embedding the resulting image using a data: url.
Works perfectly. html2canvas has no full css support, so the output will not always match 100%, but its close enough to get a glimpse of what is stored per slide ;)
“Gisto is a code snippet manager that runs on GitHub Gists and adds additional features such as searching, tagging and sharing gists while including a rich code editor. All your data is stored on GitHub and you can access it from GitHub Gists at any time with changes carrying over to Gisto.”
The application is multi-platform.