This is just my own collection of Bootstrap 4 enhancements. I recommend putting the SCSS snippets into an .scss/.sass file that imports bootstrap.scss at the top, but you're welcome to use them however you'd like.
I also included enhancements_compiled.css
gist, which is a compiled version of these enhancements using Bootstrap 4 default sizes & colors, for those who don't re-compile SASS from BS4 source.
The buttons.css
gist contains the following enhancements :
cursor:pointer
on hovercursor:not-allowed
on:disabled
and.disabled
buttons- an
:active
class (the default buttons show no change in button state/color when pressed)
The BS4 docs reference this Safari bug, so I went ahead and included it in my custom CSS, just in case.
I love the new BS4 cards. They're great, they're beautiful, they're utilitarian. However! I ran into an issue when building an example layout (to teach myself BS4, having used BS3 for many years), and I made myself a few classes to "fix" it.
Since a card group (and a card deck) just use Flexbox to fill the width of their container, there's no easy way to build something like "I want 3 cards per row for this breakpoint, 2 per row at this breakpoint..." and so on.
Sure, you could wrap the cards in col-*
classes, but then you lose the awesome unified footer option, and height-matching.
You could also apply col-*
to the card directly, like I do in my example, (<div class="card col-6">
) but the cards themselves have a white background, whereas the card's content would be padded by Bootstrap's natural spacing.
Example :
Disgusting, right?
So, what I do is wrap my group of cards in cards-col
(which works just like a .row
), and remove the background from the .card
itself, applying it only to the .card-body
. By doing it this way, you can have happy little cards using nicely-spaced columns, or use the .no-gutters
class in addition to the .card-cols
class and have happy little cards connecting to each other.
With gutters :
Without gutters :
(I applied a .bg-dark
class to the footer in the HTML, not the css. Also, you can add border-0
on a card's HTML to kill the border)
Just a personal preference, I sometimes like a little more "oomph" in my border radiuses, so I made a .card-biground
class I can use on a card to double the size of the border-radius.
As stated in the Bootstrap 4 docs for the Custom Form File Browser :
The file input is the most gnarly of the bunch and require additional JavaScript if you’d like to hook them up with functional Choose file… and selected file name text.
...but, alas, no Javascript is provided. A cursory Googling showed some great options, but many of them were based on BS4 Alpha builds that have since changed. The initial Javascript & CSS came from this post & reply on StackOverflow, which is like 98% of the way there.
Two minor issues :
- The filename preview always showed "C:\fakepath<filename>" (curious why? here's the answer)
- The filename preview would wrap to another line, or cutoff in an ugly way that ruined the effect of looking like a native file input control
For the Javascript, I simply strip out those first 12 characters. There might be some browsers that don't show that, but it was first implemented in IE8 so I kinda doubt it. If you wish, you can test the string for the existence of "C:\fakepath" or just "fakepath", but I was being lazy.
For the preview, I increased the padding-right
to match the standard Browse button width, forced the text not to wrap, added an overflow:hidden, and used text-overflow: ellipsis
to give it that native look & feel.
Before/After Comparison :
Those cards look Sweet!