Skip to main content

Posts

Showing posts with the label CSS

Bootstrap 5 - Show/hide images on specific breakpoints

I'm working on upgrading an existing application from Bootstrap 4 to Bootstrap 5. I used the occasion to clean up the CSS logic. One thing I had in the original application was an image in the header that should be cropped on smaller screens. This how the header looks like on bigger screens: And this is on smaller screens: The trick I used originally was by using a media queries: However with the upgrade to Bootstrap 5 I would try to achieve the same thing using the built-in grid system and breakpoints. Breakpoints Breakpoints are the building blocks of responsive design in Bootstrap. You can use them to control when your layout can be adapted at a particular viewport or device size. Bootstrap includes six default breakpoints, sometimes referred to as grid tiers , for building responsively. These breakpoints can be customized if you’re using our source Sass files. Breakpoint Class infix Dimensions X-Small No...

Angular - Refused to apply style from because its MIME type ('') is not a supported stylesheet MIME type

I t has been a while since the last time I did some web development using Angular. Today I had to troubleshoot an existing application, so I compiled the Angular code and opened my browser for a debugging session. First thing I noticed however was that although the Javascript code was executed succesfully, no CSS styling was applied. When I had a look at the browser errors I noticed the following error message: Refused to apply style from ' https://localhost:3000/assets/styles/style.css ' because its MIME type ('') is not a supported stylesheet MIME type, and strict MIME checking is enabled. Whoops! That was an error message that didn’t ring a bell. The error turned out to be more scary than the root cause of the issue. It turned out that the path to the CSS file was incorrect and that a 404 response was returned from the server.  I fixed the path and could happily continue debugging…

Tips from NDC Oslo 2019–Grid Garden

I have to admit that I’m really bad in CSS (although I was really proud on the linear-gradient I created 2 weeks ago). Before I always used the grid layout system of Bootstrap and didn’t worry to much about it. But I feel that the time is right to really start understanding Flexbox and the newer Grid Template . And what is a better way than through gamification. So stop disturbing me as I’m taking care of my carrots …

Tips from NDC Oslo 2019–Flexbox Froggy

I have to admit that I’m really bad in CSS (although I was really proud on the linear-gradient I created last week). Before I always used the grid layout system of Bootstrap and didn’t worry to much about it. But I feel that the time is right to really start understanding Flexbox and the newer Grid Template . And what is a better way than through gamification. So stop disturbing me as I’m trying to get a frog on a lilypad …

Tips from NDC Oslo 2019–The C stands for Cascade

People seems to forget the power of CSS. If you can’t remember how CSS selectors exactly work and why the cascading part is so important, go and improve your CSS skills using CSS Diner . You’ll have 32 levels to go through and solve every challenge by writing the correct CSS selector:

Learning FlexBox layout

I have a confession to make; I’m really bad in CSS. Creating a layout in css is a real pain for me…until I discovered and learned FlexBox layout through Flexbox Zombies . By applying gamification, CSS became fun again. And even better, Dave Geddes, the creator of FlexBox Zombies shares this course for free. Remark: Dave Geddes also created another game Grid critters to learn everything about the CSS grid layout. Definitely worth checking out!

Learning to use Flexbox

Flexbox is a ‘new’ way to layout your html page in CSS. No longer you need to use things like floats and positioning for creating CSS layouts. Instead you get a more flexible approach that scales from smartphone to smarttv. Browsers start to pick up this technique, so it’s time that you start learning it. From MDN : When elements are laid out as flexible boxes, they are laid out along two axes: The main axis is the axis running in the direction the flex items are being laid out in (e.g. as rows across the page, or columns down the page.) The start and end of this axis are called the main start and main end . The cross axis is the axis running perpendicular to the direction the flex items are being laid out in. The start and end of this axis are called the cross start and cross end . The parent element that has display: flex set on it (the <section> in our example) is called the flex container . The items being laid out as flexible boxes...

Using Bootstrap Glyphicons in your css

Bootstrap includes a large set of icons based on the Glyphicon Halflings set . Using these icons is easy as you only need to specify some class information in your html: <button type="button" class="btn btn-default" aria-label="Left Align"> <span class=" glyphicon glyphicon-align-left " aria-hidden="true"></span> </button> However I had a situation recently where I didn’t want to specify the icon inside my html but inside my css instead. This is certainly possible by specifying a font-family and set the icon using the content property alongside a unicode hex entity: span.icon:before {    font-family: 'Glyphicons Halflings';    content: "\f015";  } To add this icon to a page, add this HTML tag anywhere in the body of your page: <span class=" icon "></span> But where does this hex entity comes from? Check out the gly...

Bootstrap 4 Cheat Sheet

A handy, interactive cheat sheet for Bootstrap 4: http://hackerthemes.com/bootstrap-cheatsheet   For every building block inside Bootstrap, it shows you a small code snippet and a preview of the result. A real time-safer!

Embed fonts in your web page using Data URI

In web applications you can embed images into a html page by base64 encoding an image and add it to the css on your page by using Data URI. Data URI is just a URI scheme that provides a way to include data in-line. Usage is simple, you create an ASCII string format representation from your binary data using Base64 encoding. The generated string is then stored in the css. Instead of using an URI to an image, you use the Data URI instead. The format of this URI looks like this: data:[<mediatype>][;base64],<data> An example of an encoded image looks like this: This is nothing new, but did you know that you can do the same thing for fonts?