css flexbox IE11 flex item content breaks out of container - html

Managed to get a flexbox layout work in Firefox, Chrome, Edge, Opera.
Would like to make this work in IE11, or know for sure that it is not possible.
I have read about IE11 issues and tried setting height 100% on the container, without success. IE11 content overflows vertically all containers except body.
html,
body {
width: 100%;
height: 100%;
padding: 0;
margin: 0;
}
body {
display: flex;
flex-direction: column;
}
.header,
.footer {
height: 2em;
flex: none;
background-color: orange;
}
.content-wrapper {
flex: 1 0 auto;
width: 100%;
background-color: white;
display: flex;
flex-direction: column;
}
.content {
flex: 1;
width: 100%;
max-width: 60em;
margin: 0 auto;
display: flex;
flex-direction: row;
background-color: red;
}
.main {
flex: 1;
padding: 1em 1em 0;
min-width: 12em;
display: flex;
flex-direction: column;
background-color: blue;
}
.main-body {
flex: 1 0;
background-color: yellow;
}
.main-toc {
order: -1;
background-color: green;
}
.nav {
order: -1;
flex: 0 0 auto;
width: 12em;
}
pre {
position: relative;
padding: 1em;
margin: .5em 0;
overflow: auto;
border-radius: 0.3em;
max-width: 100%;
background-color: silver;
}
<header class="header">
header
</header>
<div class="content-wrapper">
<div class="content">
<main id="main" role="main" class="main">
<div id="main-body" class="main-body">
<h1>H1</h1>
<p>link
</p>
<p>On the other hand, we denounce with righteous indignation ...</p>
<pre><code class="language-php">
public function publicMethodOptionalParam($p1 = null)
{
return true;
}
</code></pre>
<p>On the other hand, we denounce with righteous indignation ...</p>
</div>
<div id="main-toc" class="main-toc">
table of contents
</div>
</main>
<nav id="nav" role="navigation" class="nav">
<ul>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
<li class="is-active">Getting Started
<ul>
<li class="is-active">Introduction
</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
<footer class="footer">
footer
</footer>
Codepen with the above code

Add flex: 1 0 auto; to .content (in css).
See Codepen.
From michaPau's comment. Doing it on his behalf so this question can be resolved since he was unresponsive, and for the solution to be more accessible/explicit to people looking for it.

Related

Footer background color don't take full width and height [duplicate]

This question already has answers here:
How wide is the default `<body>` margin?
(4 answers)
Closed 7 months ago.
For a project, I need to create the following footer
However like I said in the title, my footer's background-color neither take the full width or 'bottom' of the screen, there is a white space.
I tried to apply width:100% on footer but it doesn't work. I also tried to fiddle a bit with flexbox, but it was also fruitless.
Here is my code:
footer {
display: flex;
flex-flow: row wrap;
justify-content: space-around;
background-color: #F2F2F2;
margin-top: 30px;
}
footer a {
position: relative;
right: 36px;
color: black;
text-decoration: none;
}
footer a:hover {
color: #0065FC;
}
.footer-nav {
display: flex;
flex-flow: column wrap;
list-style: none;
}
.footer-item {
margin-top: 6px;
}
<footer>
<nav>
<h4>About</h4>
<ul class="footer-nav">
<li class="footer-item">Site Map</li>
<li class="footer-item">General Terms and Conditions</li>
<li class="footer-item">Data and Privacy</li>
</ul>
</nav>
<nav>
<h4>Our Accommodations</h4>
<ul class="footer-nav">
<li class="footer-item">Quality Assessments</li>
<li class="footer-item">You have a hotel ?</li>
</ul>
</nav>
<nav>
<h4>Assistance</h4>
<ul class="footer-nav">
<li class="footer-item">Help Desk</li>
<li class="footer-item">Contact Us</li>
</ul>
</nav>
</footer>
I thank in advance anybody who will take the time to help me.
for solving the issue about the space on the right and left use this code:
body {
margin: 0;
}
this happens because the browser applies by default some margin, you just need to reset it. (override it)
body {
margin: 0;
}
footer {
display: flex;
flex-flow: row wrap;
justify-content: space-around;
background-color: #f2f2f2;
margin-top: 30px;
}
footer a {
position: relative;
right: 36px;
color: black;
text-decoration: none;
}
footer a:hover {
color: #0065fc;
}
.footer-nav {
display: flex;
flex-flow: column wrap;
list-style: none;
}
.footer-item {
margin-top: 6px;
}
<body>
<footer>
<nav>
<h4>About</h4>
<ul class="footer-nav">
<li class="footer-item">Site Map</li>
<li class="footer-item">
General Terms and Conditions
</li>
<li class="footer-item">Data and Privacy</li>
</ul>
</nav>
<nav>
<h4>Our Accommodations</h4>
<ul class="footer-nav">
<li class="footer-item">Quality Assessments</li>
<li class="footer-item">You have a hotel ?</li>
</ul>
</nav>
<nav>
<h4>Assistance</h4>
<ul class="footer-nav">
<li class="footer-item">Help Desk</li>
<li class="footer-item">Contact Us</li>
</ul>
</nav>
</footer>
</body>
another solution can be using a fixed position or something similar to remove the element from the normal flow of the page, so you can position it where you want to.
footer {
position: fixed;
bottom: 0;
left: 0;
}
but is better to use the <body> solution

Flex box sticky side menu

Hi guy i'm working on a portfolio for my freecodecamp responsive web design project i already made my wireframe as you can see above but im kind of stuck using flexbox to make a sticky side menu i can't get the 100% height for my main-menu secton here is what i wrote
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
nav,
ul,
#main-menu {}
.box {
height: 100%;
background: #DDD;
width: 15%;
display: flex;
flex-direction: column;
}
.menu-item {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0;
text-align: center;
border: 1px solid black;
}
<main>
<section id="main-menu" class="menu">
<nav>
<ul class="box">
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
</ul>
</nav>
</section>
<section id="main"></section>
</main>
use min-height: 100vh; this will change the height of the element to the height of the available viewport (visible area in the page). check the snippet below:
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
nav,
ul,
#main-menu {
min-height: 100vh;
}
.box {
height: 100%;
background: #DDD;
width: 15%;
display: flex;
flex-direction: column;
}
.menu-item {
flex-grow: 1;
flex-shrink: 1;
flex-basis: 0;
text-align: center;
border: 1px solid black;
}
<main>
<section id="main-menu" class="menu">
<nav>
<ul class="box">
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
<li class="menu-item"></li>
</ul>
</nav>
</section>
<section id="main"></section>
</main>

Making NavBar with Display: Flex [duplicate]

This question already has answers here:
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
(6 answers)
Closed 2 years ago.
I'm a beginner. I tried to build a navbar with flex but failed to get the desired result.
what I want is
Logo Home About Services Contact
* {
margin: 0;
padding: 0;
font-family: monospace;
}
.nav {
display: flex;
background-color: gray;
}
.menu {
list-style: none;
display: inline-block;
padding: 20px
}
a {
text-decoration: none;
}
.con {
float: right;
}
<header class="nav">
<img src="./Logo.png" width="80px" class="logo" alt="">
<nav>
<ul>
<li id="home" class="menu">Home </li>
<li id="about" class="menu">About </li>
<li id="services" class="menu">Services </li>
<li id="contact" class="menu con">Contact </li>
</ul>
</nav>
</header>
* {
margin: 0;
padding: 0;
font-family: monospace;
}
.header {
display: flex;
background-color: gray;
width: 100%;
}
nav {
width: 100%;
}
ul {
display: flex;
justify-content: space-between;
}
.menu {
list-style: none;
display: inline-block;
padding: 20px
}
a {
text-decoration: none;
}
.con {
float: right;
}
<header class="header">
<nav>
<ul>
<img src="./Logo.png" width="80px" class="logo" alt="">
<div>
<li id="home" class="menu">Home </li>
<li id="about" class="menu">About </li>
<li id="services" class="menu">Services </li>
</div>
<li id="contact" class="menu con">Contact </li>
</ul>
</nav>
</header>
I believe this is what you are looking for
You can use display flex and justify-content property to move items.
.nav
{
width:100%;
display:flex;
justify-content:space-evenly;
align-items:center
}
.img-wrapper
{
width:33.33%;
}
.nav-items-center
{
width:33.33%;
display:flex;
justify-content:space-evenly;
align-items:center;
}
.nav-item-right
{
width:33.33%;
display:flex;
justify-content:space-evenly;
align-items:center;
}
<header class="nav">
<div class="img-wrapper">
<img src="./Logo.png" width="80px" class="logo" alt="Logo">
</div>
<ul class="nav-items-center">
<li id="home" class="menu">Home </li>
<li id="about" class="menu">About </li>
<li id="services" class="menu">Services </li>
</ul>
<ul class="nav-item-right">
<li id="contact" class="menu con">Contact </li>
</ul>
</header>

center unordered lists without container

I am trying to create a footer with unordered list elements. Below these lists I want to have a second div container with the copyright in it.
This is what I want to achieve
And this is my code so far
.list {
list-style: none;
display: inline-block;
}
#imprintContent {
border-bottom: 1px solid #656a70;
}
<div id="imprint">
<div id="imprintContent">
<ul class="list">
<li>Company</li>
<li>Street</li>
<li>Location</li>
<li>
Mail
</li>
</ul>
<ul class="list">
<li>Small text</li>
<li>
Privacy
</li>
</ul>
</div>
<div id="copyright">
© Copyright
</div>
</div>
How can I center these lists, place a small line below them (maybe a bottom border) and place the copyright below this border?
A free space should remain on the left and right. You can see a working example footer here
https://www.hashicorp.com/contact
if your issee is making footer center, just use text-align to center
.list {
list-style: none;
display: inline-block;
}
#imprintContent {
border-bottom: 1px solid #656a70;
}
#imprint {
text-align:center
}
<div id="imprint">
<div id="imprintContent">
<ul class="list">
<li>Company</li>
<li>Street</li>
<li>Location</li>
<li>
Mail
</li>
</ul>
<ul class="list">
<li>Small text</li>
<li>
Privacy
</li>
</ul>
</div>
<div id="copyright">
© Copyright
</div>
</div>
Hi
This problem can be easily solved with flexbox.
#imprint{
margin: 0% 20%; /*this make the free space to the sides, adjust the 20% to the desired number*/
}
#imprintContent{
display: flex;
justify-content: center;
align-items: center;
}
#green{
background: green;
}
#red{
background: red;
}
#copyright{
text-align: center;
}
.list{
padding: 10%;
margin: 10%;
}
.list > li{
margin-top: 4%;
margin-bottom: 4%;
}
<div id="imprint">
<div id="imprintContent">
<ul id="green" class="list">
<li>Company</li>
<li>Street</li>
<li>Location</li>
<li>
Mail
</li>
</ul>
<ul id="red" class="list">
<li>Small text</li>
<li>
Privacy
</li>
</ul>
</div>
<hr>
<div id="copyright">
© Copyright
</div>
</div>
You can do this
#imprint { display:table; margin:0 auto; }
This is a start. . .
body * {...} is just a reset.
body * {
margin: 0;
padding: 0;
}
footer {
max-width: 60%;
margin: 0 auto;
}
li {
list-style-type: none;
}
.lists {
display: flex;
margin-bottom: 2rem;
}
.lists__list {
flex: 1 auto;
}
.footer__copyright {
border-top: 1px solid black;
padding-top: 2rem;
text-align: center;
}
<footer>
<div class="lists">
<ul class="lists__list">
<li>Company</li>
<li>Street</li>
<li>Location</li>
<li>
Mail
</li>
</ul>
<ul class="lists__list">
<li>Small text</li>
<li>
Privacy
</li>
</ul>
</div>
<div class="footer__copyright">
© Copyright
</div>
</footer>

How to make a nested list to appear like a table with collapsed borders?

I have some information with the following semantic structure:
Company
Project 1
Monday
Activity 1
Activity 2
Tuesday
Activity 3
...
Project 2
Day of the week
Activity 1...n
Company 2
...
And I chose to use lists in the markup because of how the information is related. However, it has to be laid out to appear like a table for printing purposes. I used flexboxes to make it look like so, the only thing is that I can't make the borders to collapse. I can't use tables because the responsive version does lay the information out like a list, and tables break the semantic structure of the information. So the question is:
How can I make it appear like a table (with collapsed borders)? Or is there a better solution for this?
This is how the markup looks:
<ul class="container">
<li class="company-item">
Company
<ul class="projects-container">
<li class="project-item">
Project 1
<ul class="days-container">
<li class="day-item">Monday
<ul class="activities-container">
<li class="activity-item">Activities</li>
<li class="activity-item">Activities</li>
</ul>
</li>
<li class="day-item">Saturday
<ul class="activities-container">
<li class="activity-item">Activities</li>
<li class="activity-item">Activities</li>
</ul>
</li>
</ul>
</li>
<li class="project-item">
Project 2
<ul class="days-container">
<li class="day-item">Monday
<ul class="activities-container">
<li class="activity-item">Activities</li>
<li class="activity-item">Activities</li>
</ul>
</li>
<li class="day-item">Saturday
<ul class="activities-container">
<li class="activity-item">Activities</li>
<li class="activity-item">Activities</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
And the CSS rules I used to lay it out like a table:
/* resest for this example */
ul {
margin: 0;
padding: 0;
list-style: none;
}
/* using flex */
.container {
display: flex;
flex-direction: column;
}
.projects-container {
display: flex;
flex-direction: column;
}
.days-container {
display: flex;
flex-direction: row;
}
.activities-container {
display: flex;
flex-direction: column;
}
.project-item {
flex-grow: 1;
}
.day-item {
flex-grow: 1;
}
.activity-item {
padding: 10pt;
}
li {
border: 1px solid silver;
text-align: center;
}
Here's the jsfiddle. Don't mind the layout at the activities level.
Done. I found out that there's not a simple way to do this, instead, the solution was to fiddle with the border rules for each element and changing a couple things on the markup, like surrounding the "headers" with spans with a block display. Here's the final markup:
<ul id="container">
<li class="company-item">
<span class="company-title">Company</span>
<ul class="projects-container">
<li class="project-item">
<span class="project-title">Project 1</span>
<ul class="days-container">
<li class="day-item">
<span class="day-title">Monday</span>
<ul class="activities-container">
<li class="activity-item">Activities</li>
<li class="activity-item">Activities</li>
</ul>
</li>
<li class="day-item">
<span class="day-title">Saturday</span>
<ul class="activities-container">
<li class="activity-item">Activities</li>
<li class="activity-item">Activities</li>
</ul>
</li>
</ul>
</li>
<li class="project-item">
<span class="project-title">Project 2</span>
<ul class="days-container">
<li class="day-item">
<span class="day-title">Monday</span>
<ul class="activities-container">
<li class="activity-item">Activities</li>
<li class="activity-item">Activities</li>
</ul>
</li>
<li class="day-item">
<span class="day-title">Saturday</span>
<ul class="activities-container">
<li class="activity-item">Activities</li>
<li class="activity-item">Activities</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
Here's the final CSS:
/* resest for this example */
ul {
margin: 0;
padding: 0;
list-style: none;
}
li {
text-align: center;
border-style: solid;
border-color: grey;
border-width: 0;
}
span {
border-style: solid;
border-color: grey;
}
/* using flex */
#container {
display: flex;
flex-direction: column;
border-width: 0 0 1pt 0;
}
.company-item {
border-width: 1pt 0 1pt 1pt;
}
.company-title {
display: block;
border-width: 0 1pt 0 0;
}
.projects-container {
display: flex;
flex-direction: column;
}
.project-item {
flex-grow: 1;
border-width: 1pt 0 0 0;
}
.project-title {
display: block;
border-width: 0 1pt 0 0;
}
.days-container {
display: flex;
flex-direction: row;
}
.day-item {
flex-grow: 1;
border-width: 1pt 1pt 0 0;
}
.day-title {
display: block;
border-width: 0 0 1pt 0;
}
.activities-container {
display: flex;
flex-direction: column;
}
.activity-item {
padding: 10pt;
}
.activity-item:not(:last-child) {
border-width: 0 0 1pt 0;
}
Here's the final jsfiddle.