Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexbox based sticky footer example #26674

Merged
merged 4 commits into from
Jul 25, 2018
Merged

Conversation

ysds
Copy link
Member

@ysds ysds commented Jun 6, 2018

Closes #26656

The sticky footer examples are using specific the height of the footer (60px). I've rewritten it to flexbox based for remove the specific values. The benefitis that the CSS will be more general and more responsive design.

Demo: https://codepen.io/anon/pen/WyxRKp

..I'm worried about using main element selector. Please review it too :)

@MartijnCuppens
Copy link
Member

I was thinking about making a similar PR 😉 Using the main selector might indeed not be the brightest idea.

Maybe we can take this one step further and add some classes which we can use in bootstrap? One class to put on the body and one to put on the main?

@ysds
Copy link
Member Author

ysds commented Jun 7, 2018

Of course. The following custom CSS can be replaced by bootstrap utility classes.

body {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-direction: column;
  flex-direction: column;
  height: 100vh; /* Use height insted of min-height for IE 10/11. */
}
main {
  /* Prevent shrinking the main area in IE 10/11. */
  -ms-flex-negative: 0;
  flex-shrink: 0;
}
.footer {
  padding: 1rem 0;
  margin-top: auto;
  background-color: #f5f5f5;
}

to

<html class="h-100">
<body class="d-flex flex-column h-100">
<main class="flex-shrink-0">
<footer class="py-3 mt-auto bg-light">

In many current examples, it seems inconsistent to use utility classes and custom CSS usage. For example, in the sign-in example, body has just text-center class.

<body class="text-center">

body {
height: 100%;
}
body {
display: -ms-flexbox;
display: flex;
-ms-flex-align: center;
align-items: center;
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}

This can be rewritten as follows:

<body class="d-flex align-items-center h-100 py-5 bg-light text-center">

So should we reduce the custom CSS and replace it with a utility class?

@MartijnCuppens
Copy link
Member

Interesting, I'm more in favour of the utility classes. It stimulates developers to use the build in stuff instead of writing own custom css.

@ysds
Copy link
Member Author

ysds commented Jun 8, 2018

I'm more in favour of the utility classes.

I've updated it :)

Copy link
Collaborator

@andresgalante andresgalante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ysds thanks a lot for this PR, and thanks @MartijnCuppens for helping reviewing it

@andresgalante andresgalante modified the milestone: v4.1 ideas Jun 22, 2018
@mdo mdo merged commit ab53ccc into twbs:v4-dev Jul 25, 2018
@mdo mdo mentioned this pull request Jul 25, 2018
@ysds ysds deleted the sticky-footer-flex-example branch November 4, 2018 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants