.fm-bubbles {
display: flex;
flex-wrap: wrap;
width: 100%;
height: 100px;
}
.fm-bubble {
flex: 1 1 10%;
height: max-content;
border: 1px solid royalblue;
border-radius: 5px;
}
<div >
<div >
<p >Lorem, ipsum.</p>
<p >lorem</p>
<p >adsadad</p>
<p >sss</p>
<p >asdasda asdasda</p>
<p >asss</p>
<p >sss</p>
<p >asdas asd</p>
<p >adadaddd</p>
<p >adadasd</p>
<p >addd</p>
<p >adadd</p>
<p >ss</p>
</div>
At the moment my boxes are only touching each other horizontally, but i also want them to be touching vertically. I have tried to search for information about this, but when I do find something that works, it gives them more height than they need.
CodePudding user response:
I had prepared the code for your solution take it hope soo you will like it...
HTML
<body>
<div >
<div >
<p >Lorem, ipsum.</p>
<p >lorem</p>
<p >sss</p>
<p >adsadad</p>
</div>
<div >
<p >asdasda</p>
<p >asss</p>
</div>
<div >
<p >adadasd</p>
<p >addd</p>
<p >adadd</p>
<p >ss</p>
</div>
</div>
</body>
CSS
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.container { width: 100%;
height: 100px;
background-color: lightblue;
display: flex;
flex-direction: column;
}
.fm-bubble {
width: 100%;
height: max-content;
border: 1px solid royalblue;
border-radius: 5px;
}
.fm-content-1 {
width: 100%;
display: flex;
height: max-content;
justify-content: space-between;
}
.fm-content-2 {
width: 100%;
display: flex;
height: 60%;
align-items: stretch;
justify-content: space-between;
}
.bubble2 {
height: 100%;
width: fit-content;
}
.fm-content-3 {
width: 100%;
display: flex;
height: max-content;
justify-content: space-between;
}
CodePudding user response:
p
tags have a margin
property by default. Set the margin: 0
to fix the vertical spacing.
EDIT: This does not create a masonry layout, just removes the space between the boxes.
.fm-bubbles {
display: flex;
flex-wrap: wrap;
width: 100%;
height: 100px;
}
.fm-bubble {
flex: 1 1 10%;
border: 1px solid royalblue;
border-radius: 5px;
margin: 0;
}
<div >
<div >
<p >Lorem, ipsum.</p>
<p >lorem</p>
<p >adsadad</p>
<p >sss</p>
<p >asdasda asdasda</p>
<p >asss</p>
<p >sss</p>
<p >asdas asd</p>
<p >adadaddd</p>
<p >adadasd</p>
<p >addd</p>
<p >adadd</p>
<p >ss</p>
</div>
</div>
EDIT 2
You can:
align-items: flex-start;
align-content: flex-start;
to the parent fm-bubbles
. This will keep the children the height of their content, and remove the space between the children vertically.
.fm-bubbles {
display: flex;
flex-wrap: wrap;
width: 100%;
height: 100px;
align-items: flex-start;
align-content: flex-start;
}
.fm-bubble {
flex: 1 1 10%;
border: 1px solid royalblue;
border-radius: 5px;
margin: 0;
}
<div >
<div >
<p >Lorem, ipsum.</p>
<p >lorem</p>
<p >adsadad</p>
<p >sss</p>
<p >asdasda asdasda</p>
<p >asss</p>
<p >sss</p>
<p >asdas asd</p>
<p >adadaddd</p>
<p >adadasd</p>
<p >addd</p>
<p >adadd</p>
<p >ss</p>
</div>
</div>