How to display element on the right between elements using css - css

I have element 1, element 2, element 3 on may page, how can i place element3 on right top below element1 in right top?
It should looks like on the screen below:
I read a lot of examples but it didn't work for me,
i have tried to use
position: absolute;
float: right;
with position: absolutel it places this element on the top of the page but i don't want it,
the maximum i achievedit's right bottom position
Also i tried to use:
margin-top: -150px;
it didn't help neither, while minimizing windows it becomes a mess:
Please help me to solve this issue ?
Edited:
1999,19,1600+,8 is .hero-fact-title,
Founded in Helsinki, Offices, Digital Natives, Design Studios is .hero-fact-description, .fact-summary is that text i want to move also it element3.
.fact-wrapper {
margin-top: 10px;
display: grid;
grid-template-columns: 300px 1fr;
grid-gap: 3px;
//display: inline-block;
&__hero-fact-title {
width: 90px;
height: 42px;
font-family: MaisonNeue;
font-size: 32px;
font-weight: bold;
font-stretch: normal;
font-style: normal;
letter-spacing: -1px;
color: #333333;
}
&__hero-fact-description {
width: 193px;
height: 22px;
font-family: MaisonNeue;
font-size: 16px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
letter-spacing: normal;
color: #333333;
}
}
.fact-summary {
width: 596px;
height: 96px;
font-family: MaisonNeue;
font-size: 24px;
font-weight: normal;
font-stretch: normal;
font-style: normal;
line-height: 1.33;
letter-spacing: normal;
color: #333333;
float: right;
}
to display this mess on page i use the code below:
<div className="fact-wrapper">
{facts.map(obj => {
return (
<div>
<div className="fact-wrapper__hero-fact-title">{obj.title}</div>
<div className="fact-wrapper__hero-fact-descriptio">
{obj.description}
</div>
</div>
)
})}
</div>
<h2 className="fact-summary">{factSummary}</h2>

Use flexbox
.container {
display: flex;
flex-direction: column;
justify-content: center;
width: 80%;
margin: 0 auto;
}
.bottom {
display: flex;
align-items: flex-start;
}
.box {
display: flex;
flex: 1;
margin: 5px;
}
.box-one {
border: 2px solid tomato;
padding: 2rem 5px;
}
.box-two {
border: 2px solid teal;
padding: 2rem 5px;
}
.box-three {
border: 2px solid goldenrod;
padding: 1rem 5px;
}
<div class="container">
<div class="top">
<div class="box box-one">box one</div>
</div>
<div class="bottom">
<div class="box box-two">box two</div>
<div class="box box-three">box three</div>
</div>
</div>

I'd propose you to use flex.
Basically you have here two lines.
The first line is a simple div. The second line is a combination of two divs side by side.
There are multiple options to place them side by side you, but it's usually better for future changes to use flex.
To make it work you need to
1. Add "display: flex" to the parent div.
2. Add "flex-grow: 1" style to children. That's it.
Flex-grow defines the ability for a flex item to grow if necessary.
<div>
<div class='block'>Element 1</div>
<div class='parent'>
<div class='block child'>Elemet 2</div>
<div class='block child'>Elemet 3</div>
</div>
</div>
.parent {
display: flex;
}
.child {
flex-grow: 1;
}
.block {
padding: 10px;
border: 1px solid #ccc
}
Example: https://codepen.io/tony-freed/full/vYOrYVE
You can learn more about it here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/

You could use Flexbox, giving flex-basis: 100% to the first element, e.g.
main {
display: flex;
flex-wrap: wrap;
align-items: flex-start;
justify-content: space-between;
}
div {
box-sizing: border-box;
border: 5px solid currentColor;
flex-basis: calc(50% - 5px);
margin-bottom: 10px;
}
.e1 { color: red; flex-basis: 100%; }
.e2 { color: blue; }
.e3 { color: green; }
<main>
<div class="e1">element 1</div>
<div class="e2">element 2 <br /><br />Lot of text</div>
<div class="e3">element 3</div>
</main>

Related

CSS Flex and transformed text

I am trying to get this kind of effect to display a date
I am using flex and text transform, but am struggling to get it right. I cannot get rid of the extra width to the right of the year.
This is my current result.
Here is my code:
.event {
display: flex;
gap: 20px;
margin-bottom: 5px;
}
.date {
border-radius: 5px;
letter-spacing: 1.2px;
background-color: #f6f5f0;
color: #d8d6c8;
padding: 5px;
}
.date .dayAndMonth {
display: inline-block;
}
.date .month {
text-align: center;
font-size: 13px;
}
.date .day {
text-align: center
}
.date .year {
display: inline-block;
transform-origin: 0 0;
transform: rotate(-90deg);
position: relative;
top: 18px;
}
.event_details {}
<article class="event">
<div class="date">
<div class="dayAndMonth">
<div class="month">Feb</div>
<div class="day">04</div>
</div>
<div class="year">2022</div>
</div>
<div class="event_details">
<div class="title">Event Title</div>
</div>
</article>
I would recommend to use writing-mode: vertical-lr; for more details
.event {
display: flex;
gap: 20px;
margin-bottom: 5px;
}
.date {
border-radius: 5px;
letter-spacing: 1.2px;
background-color: #f6f5f0;
color: #d8d6c8;
padding: 5px;
/*Added css*/
display: flex;
align-items: center;
}
.date .dayAndMonth {
display: inline-block;
}
.date .month {
text-align: center;
font-size: 13px;
}
.date .day {
text-align: center;
}
.date .year {
display: inline-block;
writing-mode: vertical-lr; // use this css
position: relative;
}
.event_details {}
<article class="event">
<div class="date">
<div class="dayAndMonth">
<div class="month">Feb</div>
<div class="day">04</div>
</div>
<div class="year">2022</div>
</div>
<div class="event_details">
<div class="title">Event Title</div>
</div>
</article>
It's because of position relative that anchors .year in the .date container. It will still take space there as it is relative to that position making the container adjust it's dimension to accommodate the .year. There're two ways that I can think of. First, is fix the dimensions of .date: height and width then reposition the right and top of the .year. Or you could just use position: absolute; on .year, just set the parent container's width: 50; and adjust the top property to reposition. See the snippet below:
*{
box-sizing: border-box;
margin: 0;
padding: 0;
}
.event {
display: flex;
gap: 20px;
margin-bottom: 5px;
padding: 1rem;
}
.date {
border-radius: 5px;
letter-spacing: 1.2px;
background-color: #f6f5f0;
color: #d8d6c8;
padding: 5px;
width: 50px;
}
.date .dayAndMonth {
display: inline-block;
}
.date .month {
text-align: center;
font-size: 13px;
}
.date .day {
text-align: center
}
.date .year {
display: inline-block;
transform-origin: 0 0;
transform: rotate(-90deg);
position: absolute;
top: 55px;
}
.event_details {}
<article class="event">
<div class="date">
<div class="dayAndMonth">
<div class="month">Feb</div>
<div class="day">04</div>
</div>
<div class="year">2022</div>
</div>
<div class="event_details">
<div class="title">Event Title</div>
</div>
</article>
More on positions here.
Solution
Add a value for width to .year in your CSS. That is
.date .year {
/* ... (other styles) */
width: 20px; /* newly added value for width */
}
Explanation
On rendering your HTML/CSS code, the browser kind of calculates the widths of elements. At this point, the width of the .year div (containing 2022) has been set. After the rotation is rendered, the width was still retained hence the extra space at the right.
So explicitly setting the width removes the extra space to the right of the vertical 2022.
Note
You may want to set the font sizes of .month, .day, and .year to be sure that their values are not distorted or superimposed on each other when your page is rendered in a browser where the user has scaled up font sizes.

Moving a tag to the top of a todo bar

The spent text with the teal background is meant to be a tag, and I want the tag to appear above the todo bar...kind of like this:
Like a small rectangle on top of a big one. So the tag would be on the top left corner of the todo bar. How would I achieve this? I've tried doing margin to the tag, but that did not work out at all.
CSS for the tag (style.css)
.tag {
color: white;
font-size: 15px;
font-weight: 400;
letter-spacing: 2px;
text-transform: uppercase;
background: #36d1dc;
padding: 3px;
border-radius: 5px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
React JS code for the tag part (Todo.js)
<li className={`todo-item${todo.completed ? "completed" : ""}`}>
{isSpent && <p className="tag">Spent</p>}
{isReceived && <p className="tag">Received</p>} ${text}
</li>
In case anyone needs the whole of the todo.css file: https://pastecode.io/s/s5XZ9e3DRW
If you need anymore information, or if my question was poorly phrased, please tell me. Any help is very much appreciated. Thank you!
I think if yow will separate the tag and the navbar to two different div tags and put them on main div something like:
<div id="wrapper">
<div id="top-left">top left div</div>
<div id="down">down side div</div>
</div>
and the css will be something like (using grid on the main div):
#wrapper {
display: grid;
}
#top-left {
background: green;
width: 250px;
float:left;
margin-right: 20px;
}
#down {
background: blue;
float:left;
width: 500px;
}
the result is:
I would go with something like this, where input:focus could be a class set on on .container, for example, if the input has any values.
I couldn't understand why you used li and p in your original code, because you need to override so much stuff to make it look nice.
Using "rem" over a fixed pixel value is also preferred if you want to create a responsive site, where you just override the font-size in the body to make everything scale.
.container {
position: relative;
display: flex;
}
body,
input {
padding: 1rem;
}
.container.selected > .todo-item,
input:focus ~ .todo-item {
transform: translateY(-1rem);
}
.todo-item {
position: absolute;
left: 1rem;
transform: translateY(1rem);
transition: transform 400ms;
}
.tag {
color: white;
font-size: 15px;
font-weight: 400;
letter-spacing: 2px;
text-transform: uppercase;
background: #36d1dc;
padding: 3px;
border-radius: 5px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
<div class="container">
<input type="number">
<div class="todo-item"><span class="tag">Spent</span></div>
<div style="padding-top: 1rem"><-- select this input</div>
</div>
<div class="selected container" style="padding-top: 2rem">
<input type="number">
<div class="todo-item"><span class="tag">Spent</span></div>
</div>
body {
background-color: #48AEE0;
}
.container {
height: 200px;
width: 500px;
display: flex;
flex-direction: column;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.tag {
color: white;
font-size: 15px;
font-weight: 400;
letter-spacing: 2px;
text-transform: uppercase;
background: #36d1dc;
padding: 3px;
width: 80px;
text-align: center;
border-radius: 5px;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
.other {
margin: 0;
display: inline-flex;
flex-direction: column;
}
input {
height: 30px;
width: 200px;
border: white;
margin: 0;
}
<div class="container">
<div class="tag">spent</div>
<div class="others">
<input type="text">
</div>
</div>

Flexbox: while a group of items is at the very center of the page, put at single item at the bottom

I have used Bootstrap 4 and some custom CSS to make a hero section with all its items but one centered horizontally and vertically.
The exception is one item I want to align at the bottom of the page and still keep it centered horizontally.
html,
body {
padding: 0;
margin: 0;
height: 100%;
}
.page-wrapper {
min-height: 100%;
}
a.inherit {
color: inherit;
}
a.nounderline, a.nounderlie:hover {
text-decoration: none;
}
.page-wrapper {
min-height: 100%;
}
.hero {
height: 100vh;
overflow-y: hidden;
padding-top: 3rem;
padding-bottom: 3rem;
justify-content: center;
align-items: center;
}
.hero img {
width: 100%;
}
.hero.type-text h1 {
color: #000;
}
.hero.hero-short {
max-height: 768px;
}
section.type-text h3 {
font-weight: bold;
font-size: 2rem;
margin-bottom: 0;
}
section.type-text h4 {
font-size: 14px;
font-weight: bold;
margin-bottom: 0;
margin-top: 1.5rem;
}
section.type-text p {
font-weight: 500;
}
.allcases {
text-align: center;
font-weight: 700;
margin-top: auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="page-wrapper">
<section class="container d-flex hero type-text">
<div>
<h4 class="text-center m-0">Next item</h4>
<h1 class="display-1 text-center">
<a class="inherit nounderlie" href="#">Lorem</a>
</h1>
</div>
<p class="allcases">
<a class="inherit" href="#">See all items</a>
</p>
</section>
</div>
"See all items" does stay to the bottom (thanks to margin-top: auto), but it is not centered. Changing the flex-direction from row to column messes the whole layout so it is not the way to go.
What is viable solution?
You should be using flex-direction: column for this. This is an ideal use-case for it. Using row layout to achieve what you want, i.e. have the items horizontally centered is not viable. You'd be better off not using flex at all, and using margins instead. If you really wish to use flex-direction: row then the only solution I can think of is either to use position: absolute or a negative margin. Wouldn't recommend it though, since what you want can so easily be accomplished just by using flex-direction: column.
Here is the result I achieved just by changing 2 properties.
Update styling to
// Only added flex-direction: column to this
.hero {
height: 100vh;
overflow-y: hidden;
padding-top: 3rem;
padding-bottom: 3rem;
justify-content: center;
align-items: center;
flex-direction: column;
}
// This is to target the first div, i.e. the div that contains next item and Lorem, since the div doesn't have a class.
.hero > div {
margin-top: auto;
}
The answer is rather simple. Change the flex-flow of your container to column.
flex-flow:column;
Now you have two flex-items: The div, containing your Title and the other links and the footer-p. The first trick is to make your div grow, while the p-tag stays the same. So assign
flex: 1 auto;
to your div and
flex: 0 auto;
to your p-tag.
After doing so you have to add
display: flex;
justify-content: center;
flex-flow: column;
to your div, too. Making it a flex-box itself.
Your p-tag doesnt require more attention, you can also remove the unnecessary margins.
This should do the trick.
You need to allow wrapping and set a width to the div suppose to stand at top
to allow wrapping, use a class
<section class="container d-flex hero type-text flex-wrap">
for the di, you can do :
.hero>div {
width:100%;
}
html,
body {
padding: 0;
margin: 0;
height: 100%;
}
.page-wrapper {
min-height: 100%;
}
a.inherit {
color: inherit;
}
a.nounderline, a.nounderlie:hover {
text-decoration: none;
}
.hero {
height: 100vh;
overflow-y: hidden;
padding-top: 3rem;
padding-bottom: 3rem;
justify-content: center;
align-items: center;
}
.hero>div {
width:100%;
}
.hero img {
width: 100%;
}
.hero.type-text h1 {
color: #000;
}
.hero.hero-short {
max-height: 768px;
}
section.type-text h3 {
font-weight: bold;
font-size: 2rem;
margin-bottom: 0;
}
section.type-text h4 {
font-size: 14px;
font-weight: bold;
margin-bottom: 0;
margin-top: 1.5rem;
}
section.type-text p {
font-weight: 500;
}
.allcases {
text-align: center;
font-weight: 700;
margin: auto auto 0 auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="page-wrapper">
<section class="container d-flex hero type-text flex-wrap">
<div>
<h4 class="text-center m-0">Next item</h4>
<h1 class="display-1 text-center">
<a class="inherit nounderlie" href="#">Lorem</a>
</h1>
</div>
<p class="allcases">
<a class="inherit" href="#">See all items</a>
</p>
</section>
</div>
Another option is to use the flex-column class
html,
body {
padding: 0;
margin: 0;
height: 100%;
}
.page-wrapper {
min-height: 100%;
}
a.inherit {
color: inherit;
}
a.nounderline, a.nounderlie:hover {
text-decoration: none;
}
.hero {
height: 100vh;
overflow-y: hidden;
padding-top: 3rem;
padding-bottom: 3rem;
justify-content: center;
align-items: center;
}
.hero img {
width: 100%;
}
.hero.type-text h1 {
color: #000;
}
.hero.hero-short {
max-height: 768px;
}
section.type-text h3 {
font-weight: bold;
font-size: 2rem;
margin-bottom: 0;
}
section.type-text h4 {
font-size: 14px;
font-weight: bold;
margin-bottom: 0;
margin-top: 1.5rem;
}
section.type-text p {
font-weight: 500;
}
.allcases {
text-align: center;
font-weight: 700;
margin: auto auto 0 auto;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="page-wrapper">
<section class="container d-flex flex-column hero type-text ">
<div>
<h4 class="text-center m-0">Next item</h4>
<h1 class="display-1 text-center">
<a class="inherit nounderlie" href="#">Lorem</a>
</h1>
</div>
<p class="allcases">
<a class="inherit" href="#">See all items</a>
</p>
</section>
</div>
in both example, margin of allcases is reset to :
margin: auto auto 0 auto;
to stick it at bottom of container, no matter the flex-direction.

Flex item being bumped down exactly half height of previous item

I'll include an image for context, then the code:
The box at far right with "ABC" in it and a left/bottom border is being bumped down exactly half the height of the gradient image next to it. I know a lot of the heights/etc don't make sense, but I've removed them all and the problem persists. Any guidance here?
The HTML:
<div className="thing">
<img src="https://unsplash.it/75/90/?blur" alt="hey there" className="thingImage" />
<div className="content">
<span className="thingName">Jibber Jabb Super Long Title of a Movie or Thing Here</span><br/>
<span className="thingRanks">
Rank1: 1<br/>
Rank2: 2<br/>
Rank3: 2
</span>
</div>
<div className="thingMeta">
<img src="https://unsplash.it/30/30/?blur" alt="name" className="thingIcon" />
<span className="thingAbbrev">ABC</span>
</div>
</div>
(the "className" is from React, just read it as "class" if you're not familiar with React)
The CSS:
.thing{
border: 1px solid #ccc;
width: 564px;
min-height: 68px;
padding: 10px;
font-family: "Helvetica", arial, sans-serif;
font-size: 14px;
line-height: 18px;
display: flex;
}
.thingImage{
border-radius: 5px;
margin-right: 10px;
}
.thingName{
font-weight: bold;
margin-right: 0.3em;
}
.thingMeta{
margin-left: auto;
align-self: flex-start;
height: 35px;
}
.thingAbbrev{
border-bottom: medium solid #000000;
border-left: medium solid #000;
align-self: flex-start;
padding-left: 5px;
padding-bottom: 5px;
margin-left: 10px;
width: 30px;
}
.thingIcon{
height: 30px;
}
The main focus of this project for me is learning React, using Flexbox is just a bonus for me here. Thanks in advance, any help or guidance is greatly appreciated!
Since the thingMeta is not a flex container (doesn't have display: flex;(1)), the thingAbbrev is not a flex item, hence the align-self: flex-start won't apply .
As the img and span in the thingMeta are normal inline elements, they align along the baseline, so i.e. adding vertical-align: top will align them at the top.
.thing{
border: 1px solid #ccc;
width: 564px;
min-height: 68px;
padding: 10px;
font-family: "Helvetica", arial, sans-serif;
font-size: 14px;
line-height: 18px;
display: flex;
}
.thingImage{
border-radius: 5px;
margin-right: 10px;
}
.thingName{
font-weight: bold;
margin-right: 0.3em;
}
.thingMeta{
margin-left: auto;
align-self: flex-start;
height: 35px;
}
.thingAbbrev{
border-bottom: medium solid #000000;
border-left: medium solid #000;
/* align-self: flex-start; removed */
vertical-align: top; /* added */
padding-left: 5px;
padding-bottom: 5px;
margin-left: 10px;
width: 30px;
}
.thingIcon{
height: 30px;
}
<div class="thing">
<img src="https://unsplash.it/75/90/?blur" alt="hey there" class="thingImage" />
<div class="content">
<span class="thingName">Jibber Jabb Super Long Title of a Movie or Thing Here</span><br/>
<span class="thingRanks">
Rank1: 1<br/>
Rank2: 2<br/>
Rank3: 2
</span>
</div>
<div class="thingMeta">
<img src="https://unsplash.it/30/30/?blur" alt="name" class="thingIcon" />
<span class="thingAbbrev">ABC</span>
</div>
</div>
Alternatively you can of course also simply add display: flex to the thingMeta. The downside with that is that your img then becomes a flex item and based on what you want to do with it, there is some cross browser issues, and many of them can be avoided by wrapping the img (which I didn't in below sample)
.thing{
border: 1px solid #ccc;
width: 564px;
min-height: 68px;
padding: 10px;
font-family: "Helvetica", arial, sans-serif;
font-size: 14px;
line-height: 18px;
display: flex;
}
.thingImage{
border-radius: 5px;
margin-right: 10px;
}
.thingName{
font-weight: bold;
margin-right: 0.3em;
}
.thingMeta{
margin-left: auto;
align-self: flex-start;
height: 35px;
display: flex; /* added */
}
.thingAbbrev{
border-bottom: medium solid #000000;
border-left: medium solid #000;
align-self: flex-start;
padding-left: 5px;
padding-bottom: 5px;
margin-left: 10px;
width: 30px;
}
.thingIcon{
height: 30px;
}
<div class="thing">
<img src="https://unsplash.it/75/90/?blur" alt="hey there" class="thingImage" />
<div class="content">
<span class="thingName">Jibber Jabb Super Long Title of a Movie or Thing Here</span><br/>
<span class="thingRanks">
Rank1: 1<br/>
Rank2: 2<br/>
Rank3: 2
</span>
</div>
<div class="thingMeta">
<img src="https://unsplash.it/30/30/?blur" alt="name" class="thingIcon" />
<span class="thingAbbrev">ABC</span>
</div>
</div>
(1) When display: flex is set on an element, it is only its children that becomes flex items
You need to set the below CSS and html
CSS:
.vcenter{
display: flex;
align-item: center;
justify-content: center;
}
Also I wrapped the <span class="thingAbbrev">ABC</span> in another span to get rid of an height issue due to margins.
HTML:
<div class="thingMeta vcenter">
<img src="https://unsplash.it/30/30/?blur" alt="name" class="thingIcon" />
<span class="vcenter"><span class="thingAbbrev">ABC</span></span>
</div>
JSFiddle: here

How do I evenly distribute a group of spans across a div?

I have an aside on the side of my webpage that contains span blocks that contain tags for blog posts. Right now, they're set up with display: inline-table that put multiple on each line and then go to the next line as overflow.
If possible (and JavaScript is okay, but CSS is preferred), how can I get these spans to take up the entire width inside of the div so I don't have the "rough edge" to the right? I'd like to either increase the margins between the span blocks or I'd be okay with increasing the width of the span as well.
Here's the code I currently have:
body {
background-color: #333;
color: #333332;
}
aside {
background-color: white;
width: 300px;
height: 300px;
margin: auto;
}
h2 {
margin: 24px;
padding-top: 24px;
}
.tag-wrapper {
padding: 0px 24px;
}
span {
display: inline-table;
text-transform: uppercase;
background-color: #F77C2F;
margin: 4px 2px;
padding: 8px;
}
<div class="container">
<aside>
<h2>Tags</h2>
<div class="tag-wrapper">
<span>finance</span>
<span>if</span>
<span>pv</span>
<span>pivot tables</span>
<span>vba</span>
<span>test</span>
<span>test</span>
<span>test</span>
</div>
</aside>
</div>
A little flexbox magic will get the job done:
body {
background-color: #333;
color: #333332;
}
aside {
background-color: white;
width: 300px;
height: 300px;
margin: auto;
}
h2 {
margin: 24px;
padding-top: 24px;
}
.tag-wrapper {
padding: 0px 24px;
display: flex;
flex-flow: row wrap;
align-content: stretch;
}
span {
flex: 1 0 auto;
text-transform: uppercase;
background-color: #F77C2F;
margin: 4px 2px;
padding: 8px;
}
<div class="container">
<aside>
<h2>Tags</h2>
<div class="tag-wrapper">
<span>finance</span>
<span>if</span>
<span>pv</span>
<span>pivot tables</span>
<span>vba</span>
<span>test</span>
<span>test</span>
<span>test</span>
</div>
</aside>
</div>
The properties used are:
display: flex: this sets the display type of the container to flex (aka flexbox)
flex-flow: row wrap: makes items order in a row, and wrap as required.
align-content: stretch: makes items stretch to fill the flex direction (row).
flex 1 0 auto: makes the items "growable" (1), but not "shrinkable" (0), and use self base width (auto) before distributing leftover space.
Is this what you are talking about? If so, just change the display of the span to block instead of inline-block.
body {
background-color: #333;
color: #333332;
}
aside {
background-color: white;
width: 300px;
height: 300px;
margin: auto;
}
h2 {
margin: 24px;
padding-top: 24px;
}
.tag-wrapper {
padding: 0px 24px;
}
span {
display: block;
text-transform: uppercase;
background-color: #F77C2F;
margin: 4px 2px;
padding: 8px;
}
<div class="container">
<aside>
<h2>Tags</h2>
<div class="tag-wrapper">
<span>finance</span>
<span>if</span>
<span>pv</span>
<span>pivot tables</span>
<span>vba</span>
<span>test</span>
<span>test</span>
<span>test</span>
</div>
</aside>
</div>

Resources