Can you use if/else conditions in CSS?

Not in the traditional sense, but you can use classes for this, if you have access to the HTML. Consider this: and in your CSS file: That’s the CSS way to do it. Then there are CSS preprocessors like Sass. You can use conditionals there, which’d look like this: Disadvantages are, that you’re bound to pre-process your stylesheets, and that … Read more

Outline radius?

Old question now, but this might be relevant for somebody with a similar issue. I had an input field with rounded border and wanted to change colour of focus outline. I couldn’t tame the horrid square outline to the input control. So instead, I used box-shadow. I actually preferred the smooth look of the shadow, but the shadow … Read more

Bootstrap NavBar with left, center or right aligned items

2021 Update Bootstrap 5 (beta) Bootstrap 5 also has a flexbox Navbar, and introduces new RTL support. For this reason the concept of “left” and “right” has been replaced with “start” and “end”. Therefore the margin utilities changed for Bootstrap 5 beta: ml-auto => ms-auto mr-auto => me-auto Also note that data-toggle and data-target have changed too: data-toggle => data-bs-toggle data-target => data-bs-target Navbar Demo for Bootstrap … Read more

Change color of PNG image via CSS?

You can use filters with -webkit-filter and filter: Filters are relatively new to browsers but supported in over 90% of browsers according to the following CanIUse table: https://caniuse.com/#feat=css-filters You can change an image to grayscale, sepia and lot more (look at the example). So you can now change the color of a PNG file with filters. Source

How to add a color overlay to a background image?

I see 2 easy options: multiple background with a translucent single gradient over image huge inset shadow gradient option: shadow option: an old codepen of mine with few examples a third option with background-blen-mode :The background-blend-mode CSS property sets how an element’s background images should blend with each other and with the element’s background color.