How to make flexible columns by content?
In this case, I need 4 columns if there is everything okay, but in any cases if list item is bigger than it needed I need make less columns. Prefer only CSS solution.
It is logical that this grid-template-columns: repeat(auto-fill, minmax(min-content, 1fr)); expression should have worked, but min-content and max-content is not working with "fr" units.
.parent {
display: flex;
}
.wrapper {
width: 450px;
padding: 15px;
margin: 0 auto;
box-sizing: border-box;
background-color: #d4d1d1;
}
.wrapper:first-child {
background-color: #cc8b8b;
}
.list {
display: grid;
grid-gap: 10px;
grid-template-columns: repeat(4, 1fr);
// grid-template-columns: repeat(auto-fill, minmax(min-content, 25%));
justify-content: center;
padding: 0;
margin: 0;
border: 1px dashed green;
}
.list__item {
display: flex;
flex-direction: column;
list-style: none;
align-items: center;
text-align: center;
border: 1px solid black;
}
.list__item-img {
width: 91px;
height: 91px;
background-color: #eaeaea;
}
<div class="parent">
<div class="wrapper">
<ul class="list">
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Lorem</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Lorem</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Lorem</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Lorem</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Lorem</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Lorem</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Lorem</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Lorem</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Lorem</span>
</li>
</ul>
</div>
<div class="wrapper">
<ul class="list">
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Very/long/word</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Very/long/word</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Very/long/word</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Very/long/word</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Very/long/word</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Very/long/word</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Very/long/word</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Very/long/word</span>
</li>
<li class="list__item">
<div class="list__item-img"></div>
<span class="list__item-caption">Very/long/word</span>
</li>
</ul>
</div>
</div>
Have you tried using display: flex on .list element instead of using grid? Once that's set, you need to set a min-width property for the columns and by using flex-wrap: wrap the rows can collapse if the width of the items put together exceeds the full width of the container.
Related
What should I change in the following code to get my output right?
I want the skills and the bullets side-by-side but it's coming on the top of the skills.
I tried looking at different references but it spoiled my layout even more.
Below are my HTML and CSS codes:
.skills__content,
.languages__content {
grid-template-columns: repeat(2, 1fr);
}
.skills__content,
.experience__content {
gap: 1;
}
.languages__content {
gap: 0;
}
.skills__name,
.languages__name {
display: flex;
align-items: center;
margin-bottom: var(--mb-3);
}
.skills__circle,
.languages__circle {
display: inline-block;
width: 5px;
height: 5px;
background-color: var(--text-color);
border-radius: 50%;
margin-right: 0.75rem;
}
<!-- Skills -->
<section class="skills section" id="skills">
<h2 class="section-title">Skills</h2>
<div class="skills__content bd-grid">
<ul class="skills__data">
<li class="skills__name">
<span class="skills__circle">C </span>
</li>
<li class="skills__name">
<span class="skills__circle">C++</span>
</li>
<li class="skills__name">
<span class="skills__circle">Python</span>
</li>
<li class="skills__name">
<span class="skills__circle">Java</span>
</li>
<li class="skills__name">
<span class="skills__circle">Linux</span>
</li>
</ul>
<ul class="skills__data">
<li class="skills__name">
<span class="skills__circle">Html</span>
</li>
<li class="skills__name">
<span class="skills__circle">Css</span>
</li>
<li class="skills__name">
<span class="skills__circle">Javascript</span>
</li>
<li class="skills__name">
<span class="skills__circle">React.js</span>
</li>
<li class="skills__name">
<span class="skills__circle">Firebase</span>
</li>
</ul>
<ul class="skills__data">
<li class="skills__name">
<span class="skills__circle">MYSQL</span>
</li>
<li class="skills__name">
<span class="skills__circle">Excel</span>
</li>
</ul>
</div>
</section>
Attaching pics for references:
This is how it is right now
and This is how I want it to look,
You can do like this by adding some properties to <li> tag also . Below is the correct implementation.
Removed some unnecessary styling also
ul {
display: grid;
grid-template-columns: repeat(2,1fr);
list-style: none;
grid-row-gap: 20px;
}
li {
display: flex;
flex-direction: row;
}
.skills__name {
align-items: center;
}
.skills__circle,
.languages__circle {
display: flex;
align-items: center;
justify-content: left;
width: 5px;
height: 5px;
background-color: green;
border-radius: 50%;
margin-right: 5px;
}
<section class="skills section" id="skills">
<h2 class="section-title">Skills</h2>
<div class="skills__content">
<ul class="skills__data">
<li class="skills__name">
<span class="skills__circle"> </span>C
</li>
<li class="skills__name">
<span class="skills__circle"></span>C++
</li>
<li class="skills__name">
<span class="skills__circle"></span>Python
</li>
<li class="skills__name">
<span class="skills__circle"></span>Java
</li>
<li class="skills__name">
<span class="skills__circle"></span>Linux
</li>
</ul>
<ul class="skills__data">
<li class="skills__name">
<span class="skills__circle"></span>Html
</li>
<li class="skills__name">
<span class="skills__circle"></span>Css
</li>
<li class="skills__name">
<span class="skills__circle"></span>Javascript
</li>
<li class="skills__name">
<span class="skills__circle"></span>React.js
</li>
<li class="skills__name">
<span class="skills__circle"></span>Firebase
</li>
</ul>
<ul class="skills__data">
<li class="skills__name">
<span class="skills__circle"></span>MYSQL
</li>
<li class="skills__name">
<span class="skills__circle"></span>Excel
</li>
</ul>
</div>
</section>
I'm trying to create a grid in HTML that layouts all it's children to have the same width. I'd also like to have that Flexbox wrap-behavior meaning it should create new rows once the window gets resized. I'dont want the items to have a fixed size for every dimension. The height of the rows should be determined by its largest child [Image 2]. So far I've managed to get the children equally sized only if every row contains the same amount of items. I've already tried to manipulate the flex-shrink and flex-grow properties and I've also added invisible placeholders. Neither managed to achieve my desired result. I'm rather new to CSS, any help would be highly appreciated. Cheers!
.collection-container {
display: flex;
flex-wrap: wrap;
margin: 0px auto;
max-width: 700px;
border: 1px solid red;
}
.collection-item {
margin: 10px;
flex-basis: 0;
flex-grow: 1;
border: 1px solid blue;
}
<span class="collection-container">
<div class="collection-item">
<h5>Headline 1</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>very long Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Short HL</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Longer Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
<li >feature</li>
<li >feature</li>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Longer Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
</span>
What I've got so far
What I'm trying to achieve
This looks working.
I added justify-content: flex-start to .collection-container ...
... and commented out in flex-basis and flex-grow in .collection-container
.collection-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
margin: 0px auto;
max-width: 700px;
border: 1px solid red;
justify-content: flex-start;
}
.collection-item {
margin: 10px;
//flex-basis: 0;
//flex-grow: 1;
border: 1px solid blue;
}
<span class="collection-container">
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
<li >feature</li>
<li >feature</li>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
<div class="collection-item">
<h5>Headline</h5>
<ul>
<li >feature</li>
</ul>
</div>
</span>
With the following code, I'm trying to make it so that the 'scroll' div occupies exactly the remaining space of the 'frame' div's height (ending at its padding boundary).
I would like to avoid a situation where the height of the scroll div is hardcoded, as it should scale with its parent (according to the window height).
I haven't been able to figure out a CSS-based solution, and would much appreciate suggestions.
:root {
--dlgMW: 0px; --dlgW: 0px;
--dlgMH: 0px; --dlgH: 0px;
}
html, body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
}
.editor {
width:100vw;
height:100vh;
background-color: #393939;
overflow: hidden;
}
.dialog.show {
position: absolute;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
}
.dialog {
color: #CCC;
}
.dialog > .window {
position: absolute;
left: 50%;
top: 50%;
-ms-transform: translate(-50%,-50%);
transform: translate(-50%,-50%);
min-width: var(--dlgMW);
width: var(--dlgW);
min-height: var(--dlgMH);
height: var(--dlgH);
border-radius: 40px;
background-color: rgba(0,0,0,0.2);
}
.dialog > .window > .frame {
box-sizing: border-box;
padding: 30px;
height: 100%;
/*overflow: hidden;*/ /* FIXME - Should not be needed */
}
.dialog > .window > .frame > .body {
position: relative;
height: 80%;
}
.dialog .content > .scroll {
overflow-y: auto; /* FIXME Scroll should be visible when div would exceed frame's padding */
}
li.series {
display: block;
height: 3em;
border-bottom: 1px solid #CCC;
}
li.series:hover {
cursor: pointer;
}
<html lang="en_US" dir="LTR" style="--dlgMW:500px; --dlgW:50%; --dlgMH:0px; --dlgH:80%;">
<head>
<link rel="stylesheet" href="main.css">
<title></title>
</head>
<body>
<div class="editor">
<div class="dialog show">
<div class="window">
<div class="frame">
<div class="body">
<div class="content">
<h2>Switch Series</h2>
<div class="scroll">
<ol id="series_list">
<li class="series">
<span class="series_title">Create New Series</span>
</li>
<li class="series">
<span class="series_title">Main Timeline</span>
</li>
<!-- For testing scroll behavior -->
<li class="series">
<span class="series_title">Custom series 1</span>
</li>
<li class="series">
<span class="series_title">Custom series 2</span>
</li>
<li class="series">
<span class="series_title">Custom series 3</span>
</li>
<li class="series">
<span class="series_title">Custom series 4</span>
</li>
<li class="series">
<span class="series_title">Custom series 5</span>
</li>
<li class="series">
<span class="series_title">Custom series 6</span>
</li>
<li class="series">
<span class="series_title">Custom series 7</span>
</li>
<li class="series">
<span class="series_title">Custom series 8</span>
</li>
<li class="series">
<span class="series_title">Custom series 9</span>
</li>
<li class="series">
<span class="series_title">Custom series 10</span>
</li>
<li class="series">
<span class="series_title">Custom series 11</span>
</li>
<li class="series">
<span class="series_title">Custom series 12</span>
</li>
<li class="series">
<span class="series_title">Custom series 13</span>
</li>
<li class="series">
<span class="series_title">Custom series 14</span>
</li>
</ol>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
Not sure why so many elements and position/transform, anyway, going down to .content, where it seems to happen, you may use the flex model :
:root {
--dlgMW: 0px;
--dlgW: 0px;
--dlgMH: 0px;
--dlgH: 0px;
}
html,
body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
}
.editor {
width: 100vw;
height: 100vh;
background-color: #393939;
overflow: hidden;
}
.dialog.show {
position: absolute;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
}
.dialog {
color: #CCC;
}
.dialog>.window {
position: absolute;
left: 50%;
top: 50%;
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
min-width: var(--dlgMW);
width: var(--dlgW);
min-height: var(--dlgMH);
height: var(--dlgH);
border-radius: 40px;
background-color: rgba(0, 0, 0, 0.2);
}
.dialog>.window>.frame {
box-sizing: border-box;
padding: 1vh;
height: 100%;
/*overflow: hidden;*/
/* FIXME - Should not be needed */
}
.dialog>.window>.frame>.body {
position: relative;
height: 80%;
}
/*---------------*/
/* -------update-*/
/*---------------*/
.dialog .content {
display: flex;
flex-direction: column;
min-height: 0;
height: 100%;
}
/*---------------*/
/* ---end-update-*/
/*---------------*/
.dialog .content>.scroll {
overflow-y: auto;
/* FIXME Scroll should be visible when div would exceed frame's padding */
}
li.series {
display: block;
height: 3em;
border-bottom: 1px solid #CCC;
}
li.series:hover {
cursor: pointer;
}
<html lang="en_US" dir="LTR" style="--dlgMW:500px; --dlgW:50%; --dlgMH:0px; --dlgH:80%;">
<head>
<link rel="stylesheet" href="main.css">
<title></title>
</head>
<body>
<div class="editor">
<div class="dialog show">
<div class="window">
<div class="frame">
<div class="body">
<div class="content">
<h2>Switch Series</h2>
<div class="scroll">
<ol id="series_list">
<li class="series">
<span class="series_title">Create New Series</span>
</li>
<li class="series">
<span class="series_title">Main Timeline</span>
</li>
<!-- For testing scroll behavior -->
<li class="series">
<span class="series_title">Custom series 1</span>
</li>
<li class="series">
<span class="series_title">Custom series 2</span>
</li>
<li class="series">
<span class="series_title">Custom series 3</span>
</li>
<li class="series">
<span class="series_title">Custom series 4</span>
</li>
<li class="series">
<span class="series_title">Custom series 5</span>
</li>
<li class="series">
<span class="series_title">Custom series 6</span>
</li>
<li class="series">
<span class="series_title">Custom series 7</span>
</li>
<li class="series">
<span class="series_title">Custom series 8</span>
</li>
<li class="series">
<span class="series_title">Custom series 9</span>
</li>
<li class="series">
<span class="series_title">Custom series 10</span>
</li>
<li class="series">
<span class="series_title">Custom series 11</span>
</li>
<li class="series">
<span class="series_title">Custom series 12</span>
</li>
<li class="series">
<span class="series_title">Custom series 13</span>
</li>
<li class="series">
<span class="series_title">Custom series 14</span>
</li>
</ol>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
If it's not a duplicate of Fill remaining vertical space with CSS using display:flex , it is very similar :)
I am trying to style a main navigation component, but I'm having trouble getting the background to stretch for a dynamic number of wrapped columns in the submenu popup. Can anyone help with this jsfiddle? I have exhausted my admitidly limited knowledge of CSS as well as anything I could find through google.
The markup comes from a content management system, so I have limited control of the generated markup, other than adding additional CSS classes, although I have full control over the CSS.
I almost got it working properly using column-count, but the number of columns need to be dynamic. I found other posts mentioning using display: flex, but still can't quite get the combination of flex and inline-block working properly.
This is the layout I am trying to achieve:
.container {
display: flex;
position: relative;
}
.container a {
text-decoration: none;
color: #424242;
}
ul {
list-style: none;
}
.main-navitation>.component-content {
position: absolute;
bottom: 0;
right: 0;
}
.rel-level1 {
display: inline-block;
padding: 10px;
position: relative;
}
.rel-level1>ul {
display: flex;
position: absolute;
top: 30px;
left: 0;
background: #e1e1e1;
border: 1px solid #c2c2c2;
padding: 5px;
max-height: 200px;
flex-wrap: wrap;
flex-direction: column;
}
.rel-level1>ul>li {
display: block;
}
.rel-level2 {
display: inline-block;
flex-grow: 1;
flex-shrink: 1 auto;
flex-basis: 100%;
width: 85px;
}
.rel-level2>a>.navigation-title {
display: inline-block;
font-weight: bold;
}
.rel-level2>ul {
padding-left: 0;
}
.rel-level3 {
padding-top: 3px;
display: inline-block;
width: 85px;
}
.rel-level3>a>.navigation-title {
border-bottom: solid 1px transparent;
display: inline-block;
font-size: 14px;
}
<div class="container">
<div class="navigation main-navigation">
<div class="component-content">
<nav>
<ul>
<li class="rel-level1">
<div class="navigation-title">Level 1</div>
<ul>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 1</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 2</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 3</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
Thanks!
It's a combination of factors:
You have your flex-direction set to column, when you're wanting row (which is actually the default, so you can remove the property from your CSS entirely), have a look at https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction
You've set a max-height to try to force the child elements to flow horizontally, alongside using flex-wrap: wrap. Neither of these properties are required if you change your flex-direction.
FYI, you can further simplify your HTML code, and even if you don't know CSS well, remove those rules which reference the unnecessary HTML code that can be removed:
ul {
list-style: none;
}
.rel-level1 {
display: inline-block;
padding: 10px;
position: relative;
}
.rel-level1>ul {
display: flex;
position: absolute;
top: 30px;
left: 0;
background: #e1e1e1;
border: 1px solid #c2c2c2;
padding: 5px;
max-height: 200px;
flex-wrap: wrap;
flex-direction: column;
}
.rel-level1>ul>li {
display: block;
}
.rel-level2 {
display: inline-block;
flex-grow: 1;
flex-shrink: 1 auto;
flex-basis: 100%;
width: 85px;
}
.rel-level2>a>.navigation-title {
display: inline-block;
font-weight: bold;
}
.rel-level2>ul {
padding-left: 0;
}
.rel-level3 {
padding-top: 3px;
display: inline-block;
width: 85px;
}
.rel-level3>a>.navigation-title {
border-bottom: solid 1px transparent;
display: inline-block;
font-size: 14px;
}
<ul>
<li class="rel-level1">
<ul>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 1</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 2</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 3</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
That said, your question is a duplicate of this post.
I was wondering what will be the best practice for me to use the | i.e. do I wrap it in a div class or store it in a span tag? Basically what I want to achieve is the following.
Ask a question | Privacy | Statement
<!DOCTYPE html>
<html>
<body>
<footer role="contentinfo">
<div class="footer-bottom hidden-print">
<div class="Container">
<div class="row">
<div class="col-12">
<ul class="list list--inline" role="menu" aria-label="Navigation">
<li role="menuitem" aria-label="Ask a question">
Ask a question |
</li>
<li role="menuitem" aria-label="Privacy">
Privacy |
</li>
<li role="menuitem" aria-label="Statement">
Statement
</li>
</ul>
</div>
</div>
</div>
</div>
</footer></body>
</html>
Please advise.
No need to have special characters at all.
Just use a right-border...
ul {
display:flex;
justify-content:center;
list-style:none;
}
li {
padding:0 1em;
}
li:not(:last-child) {
border-right:3px solid red;
}
<footer role="contentinfo">
<div class="footer-bottom hidden-print">
<div class="Container">
<div class="row">
<div class="col-12">
<ul class="list list--inline" role="menu" aria-label="Navigation">
<li role="menuitem" aria-label="Ask a question">
Ask a question
</li>
<li role="menuitem" aria-label="Privacy">
Privacy
</li>
<li role="menuitem" aria-label="Statement">
Statement
</li>
</ul>
</div>
</div>
</div>
</div>
</footer>
Alternatively, use a pseudo-element
ul {
display: flex;
justify-content: center;
list-style: none;
}
li {
padding: 0 1em;
position: relative;
}
li:not(:last-child):after {
content: "";
position: absolute;
right: 0;
top: 10%;
height: 80%;
width: 3px;
background: green;
}
<footer role="contentinfo">
<div class="footer-bottom hidden-print">
<div class="Container">
<div class="row">
<div class="col-12">
<ul class="list list--inline" role="menu" aria-label="Navigation">
<li role="menuitem" aria-label="Ask a question">
Ask a question
</li>
<li role="menuitem" aria-label="Privacy">
Privacy
</li>
<li role="menuitem" aria-label="Statement">
Statement
</li>
</ul>
</div>
</div>
</div>
</div>
</footer>
You can use CSS border-right with pseudo-selectors for this so you don't have to have the pipe (|) in your markup.
Pseudo-Selectors
:not() -- exclude what is inside the brackets
:first-child -- first of this type of descendant
:last-child -- last of this type of descendant
descendant, as in your markup, as li is the child (descendant) of ul.
ul[role="menu"].list {
list-style: none;
display: flex;
}
li[role="menuitem"]:not(:first-child) {
padding-left: 0.5rem;
}
li[role="menuitem"]:not(:last-child) {
padding-right: 0.5rem;
border-right: 1px solid grey;
}
<footer role="contentinfo">
<div class="footer-bottom hidden-print">
<div class="Container">
<div class="row">
<div class="col-12">
<ul class="list list--inline" role="menu" aria-label="Navigation">
<li role="menuitem" aria-label="Ask a question">
Ask a question
</li>
<li role="menuitem" aria-label="Privacy">
Privacy
</li>
<li role="menuitem" aria-label="Statement">
Statement
</li>
</ul>
</div>
</div>
</div>
</div>
</footer>