I have done a flexbox grid, it combines text cells with image cells. All the cells have the same height in each resolution, also text cells. Text cells have the text centered vertically, and this is a must. Now I need to assign each text cell a different background-color, but here I have the problem.
With align-items: center the text is centered vertically, but the background color is only applied to the text. Without align-items: center the background expands to all the cell, but the content is not centered vertically.
Here is the codepen
Any suggestions in how to achieve the two features at same time?
vertically centered text
different background-color for each text cell
Thanks!
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0;
background: #333;
padding: 30px;
font-family: Helvetica;
}
a {
color: white;
text-decoration: none;
}
h2 {
font-size: 1.2em;
}
.wrap-items {
background-color: #ccc;
padding: 0;
margin: 0 auto;
display: -ms-flexbox;
-ms-flex-wrap: wrap;
-ms-flex-direction: row;
-webkit-flex-flow: row wrap;
flex-flow: row wrap;
display: -webkit-box;
display: flex;
justify-content: center;
align-items: center;
align-content: center;
}
.wrap-items .item {
-webkit-box-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 1 0 33.333%;
width: 33.33333%;
margin: 0;
padding: 0;
color: white;
font-size: 0;
border: none;
background-color: steelblue;
}
.wrap-items .item.span-2 {
-webkit-box-flex: 2 0 auto;
-ms-flex: 2 0 auto;
flex: 2 0 auto;
width: 66.6666%;
height: auto;
}
.wrap-items .item img {
width: 100%;
height: auto;
}
.wrap-items .item > .text {
padding: 10px;
font-size: 20px;
height: 100%;
}
.item.un .text{
background-color: orange;
}
.item.dos {
background-color: brown;
}
.item.tres {
background-color: violet;
}
#media screen and (max-width: 760px) {
.wrap-items .item {
margin: 0;
flex: 50%
}
}
#media screen and (max-width: 400px) {
.wrap-items .item {
margin: 0;
flex: 100%;
}
}
Use transforms instead of flexbox to vertically center the text.
1) Remove align-items: center from the .wrap-items class
2) Adjust the .wrap-items .item > .text class like this:
.wrap-items .item > .text {
padding: 10px;
font-size: 20px;
position: absolute;
top: 50%;
transform: translateY(-50%);
}
Updated Codepen
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body {
margin: 0;
background: #333;
padding: 30px;
font-family: Helvetica;
}
a {
color: white;
text-decoration: none;
}
h2 {
font-size: 1.2em;
}
.wrap-items {
background-color: #ccc;
padding: 0;
margin: 0 auto;
display: -ms-flexbox;
-ms-flex-wrap: wrap;
-ms-flex-direction: row;
-webkit-flex-flow: row wrap;
flex-flow: row wrap;
display: -webkit-box;
display: flex;
justify-content: center;
//align-items: center;
//align-content: center;
}
.wrap-items .item {
-webkit-box-flex: 0 1 auto;
-ms-flex: 0 1 auto;
flex: 1 0 33.333%;
width: 33.33333%;
margin: 0;
padding: 0;
color: white;
font-size: 0;
border: none;
background-color: steelblue;
position: relative;
}
.wrap-items .item.span-2 {
-webkit-box-flex: 2 0 auto;
-ms-flex: 2 0 auto;
flex: 2 0 auto;
width: 66.6666%;
height: auto;
}
.wrap-items .item img {
width: 100%;
height: auto;
}
.wrap-items .item > .text {
padding: 10px;
font-size: 20px;
position: absolute;
top: 50%;
transform: translate(0, -50%);
}
.item.un {
background-color: orange;
}
.item.dos {
background-color: brown;
}
.item.tres {
background-color: purple;
}
#media screen and (max-width: 760px) {
.wrap-items .item {
margin: 0;
flex: 50%
}
}
#media screen and (max-width: 400px) {
.wrap-items .item {
margin: 0;
flex: 100%;
}
}
<div class="wrap-items">
<!-- row 1 -->
<div class="item span-2">
<div class="text">
<h2>THE TITLE</h2>
<p>Just be water my friend</p>
<p>Small people can do very big things.</p>
</div>
</div>
<div class="item">
<img src="https://placekitten.com/g/800/600" alt>
</div>
<!-- row 2 -->
<div class="item un">
<div class="text ">
one or more lines of text inside the box
</div>
</div>
<div class="item">
<img src="https://placekitten.com/g/800/600" alt>
</div>
<div class="item dos">
<div class="text">
text in the middle
</div>
</div>
<!-- row 3 -->
<div class="item">
<img src="https://placekitten.com/g/800/600" alt="">
</div>
<div class="item tres">
<div class="text">
three lines of text centered vertically in the middle of the box
</div>
</div>
<div class="item">
<img src="https://placekitten.com/g/800/600" alt>
</div>
</div>
Related
I have made a calculator using one parent div and plenty of child divs, the children are in html. After that I styled it using flex-box and it is almost done; nevertheless there is an empty space between first div (.result) and the rest of the divs (.btn).
I want to remove that empty space which is shown in picture below:
I tried to use flex-box method to arrange these div elements like blocks.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
h1 {
margin: 0 auto 0 auto;
background-color: gray;
text-align: center;
margin-bottom: 5vh;
}
.kalkulator {
display: flex;
flex-wrap: wrap;
height: 50vh;
width: 30vw;
margin: 0 auto 0 auto;
}
.kalkulator .result {
flex-basis: 100%;
height: 10vh;
background-color: #333;
}
.kalkulator div {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
flex-basis: 33%;
background-color: #666;
border: 1px solid black;
}
.btn:nth-last-child(2),
.btn:nth-last-child(1) {
flex-basis: 50%;
}
<h1>kalkulator</h1>
<div class="kalkulator">
<div class="result">wynik</div>
<div class="btn">1</div>
<div class="btn">2</div>
<div class="btn">3</div>
<div class="btn">4</div>
<div class="btn">5</div>
<div class="btn">6</div>
<div class="btn">7</div>
<div class="btn">8</div>
<div class="btn">9</div>
<div class="btn">+</div>
<div class="btn">0</div>
<div class="btn">-</div>
<div class="btn">/</div>
<div class="btn">.</div>
<div class="btn">*</div>
<div class="btn">C</div>
<div class="btn">=</div>
</div>
Apply align-content: flex-start to the flex container.
The default setting is align-content: stretch, which will spread the items across the container. With flex-start, they'll be packed together at the top.
Your code:
.kalkulator {
display: flex;
flex-wrap: wrap;
height: 50vh;
width: 30vw;
margin: 0 auto 0 auto;
border: 2px dashed red;
background-color: yellow;
}
.kalkulator .result {
flex-basis: 100%;
height: 10vh;
background-color: #333;
}
.kalkulator div {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
flex-basis: 33%;
background-color: #666;
border: 1px solid black;
}
.btn:nth-last-child(2),
.btn:nth-last-child(1) {
flex-basis: 50%;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
h1 {
margin: 0 auto 0 auto;
background-color: gray;
text-align: center;
margin-bottom: 5vh;
}
<h1>kalkulator</h1>
<div class="kalkulator">
<div class="result">wynik</div>
<div class="btn">1</div>
<div class="btn">2</div>
<div class="btn">3</div>
<div class="btn">4</div>
<div class="btn">5</div>
<div class="btn">6</div>
<div class="btn">7</div>
<div class="btn">8</div>
<div class="btn">9</div>
<div class="btn">+</div>
<div class="btn">0</div>
<div class="btn">-</div>
<div class="btn">/</div>
<div class="btn">.</div>
<div class="btn">*</div>
<div class="btn">C</div>
<div class="btn">=</div>
</div>
Modified code:
.kalkulator {
display: flex;
flex-wrap: wrap;
height: 50vh;
width: 30vw;
margin: 0 auto 0 auto;
border: 2px dashed red;
background-color: yellow;
align-content: flex-start;
}
.kalkulator .result {
flex-basis: 100%;
height: 10vh;
background-color: #333;
}
.kalkulator div {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
flex-basis: 33%;
background-color: #666;
border: 1px solid black;
}
.btn:nth-last-child(2),
.btn:nth-last-child(1) {
flex-basis: 50%;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
h1 {
margin: 0 auto 0 auto;
background-color: gray;
text-align: center;
margin-bottom: 5vh;
}
<h1>kalkulator</h1>
<div class="kalkulator">
<div class="result">wynik</div>
<div class="btn">1</div>
<div class="btn">2</div>
<div class="btn">3</div>
<div class="btn">4</div>
<div class="btn">5</div>
<div class="btn">6</div>
<div class="btn">7</div>
<div class="btn">8</div>
<div class="btn">9</div>
<div class="btn">+</div>
<div class="btn">0</div>
<div class="btn">-</div>
<div class="btn">/</div>
<div class="btn">.</div>
<div class="btn">*</div>
<div class="btn">C</div>
<div class="btn">=</div>
</div>
It seems too much* for one flexbox. Create the layout with two nested ones: one for the vertical partition of the calculator to the result and the buttons, and another one for the fluid positioning of the buttons within the buttons div:
<div class="kalkulator">
<div class="result">wynik</div>
<div class="buttons">[...]</div>
</div>
.kalkulator {
display: flex;
flex-direction: column;
}
.result {
flex-basis: 10vh;
}
.buttons {
flex-grow: 1; /* Fill the rest */
display: flex;
flex-wrap: wrap;
}
.btn {
flex-grow: 1;
flex-basis: 33%;
justify-content: center;
align-items: center;
display: flex;
}
For placing the buttons under the result box you need a flexbox with a vertical main axis (flex-direction: column). For placing the buttons in a row, a flexbox with a horizontal main axis (the default flex-direction: row).
See the following code, here I removed height: 50vh; property from .kalkulator class:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
h1 {
margin: 0 auto 0 auto;
background-color: gray;
text-align: center;
margin-bottom: 5vh;
}
.kalkulator {
display: flex;
flex-wrap: wrap;
/* height: 50vh; */
width: 30vw;
margin: 0 auto 0 auto;
}
.kalkulator .result {
flex-basis: 100%;
height: 10vh;
background-color: #333;
}
.kalkulator div {
display: flex;
justify-content: center;
align-items: center;
flex-grow: 1;
flex-basis: 33%;
background-color: #666;
border: 1px solid black;
}
.btn:nth-last-child(2),
.btn:nth-last-child(1) {
flex-basis: 50%;
}
<h1>kalkulator</h1>
<div class="kalkulator">
<div class="result">wynik</div>
<div class="btn">1</div>
<div class="btn">2</div>
<div class="btn">3</div>
<div class="btn">4</div>
<div class="btn">5</div>
<div class="btn">6</div>
<div class="btn">7</div>
<div class="btn">8</div>
<div class="btn">9</div>
<div class="btn">+</div>
<div class="btn">0</div>
<div class="btn">-</div>
<div class="btn">/</div>
<div class="btn">.</div>
<div class="btn">*</div>
<div class="btn">C</div>
<div class="btn">=</div>
</div>
Viewport Height (vh): This unit is based on the height of the viewport. A value of 1vh is equal to 1% of the viewport height.
Height of container is 50vh and height of result is 10vh. This leaves 40vh for button panel, or 6.67vh per row. If you want to preserve container height, you can just add height: 6.67vh; to .kalkulator div. This will set button height to fixed value, so there won't be any empty space.
I have two pictures that are equal size on desktop, but on mobile the heights are not the same. How can I keep the heights the same on mobile too without setting a specific height?
See here for screenshots: https://imgur.com/a/agz5T2z.
Here's my code (ReactJS):
HTML:
<div className="container beigeBackground">
<h1>Gallery</h1>
<div className="homeGalleryContainer">
<img src="https://images.pexels.com/photos/1449773/pexels-photo-1449773.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="Homepage Gallery 1"></img>
<img src="https://images.pexels.com/photos/6341164/pexels-photo-6341164.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" alt="Homepage Gallery 2"></img>
</div>
<button>GALLERY</button>
</div>
CSS:
.container {
padding: 4em;
background-color: rgb(240, 240, 240);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.beigeBackground {
background-color: var(--Beige);
padding: 4em 2em;
}
.beigeBackground * {
color: white;
}
.homeGalleryContainer {
display: flex;
flex-direction: column;
padding-top: 4em;
padding-bottom: 3em;
}
.homeGalleryContainer img {
width: 100%;
margin-bottom: 2em;
object-fit: cover;
}
.beigeBackground button {
border-color: white;
}
.beigeBackground button:hover {
background-color: white;
color: var(--Beige);
}
#media screen and (min-width: 768px) {
.beigeBackground {
padding: 4em 0;
}
.homeGalleryContainer {
flex-direction: row;
padding: 4em 0;
padding-left: 2em;
/* to balance out margin-right of each img */
justify-content: center;
align-items: initial;
}
.homeGalleryContainer img {
width: 40%;
margin-bottom: 0;
margin-right: 2em;
}
}
Thank you.
this will make img responsive
.homeGalleryContainer img {
max-width: 100%;
height: auto;
}
I know how to keep elements center but now I want the whole page center (i.e. the horizonal scrollbar should be in the middle) when zooming in. Now the scrollbar is at the very left end when zooming in.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100%;
height: 100%;
margin: 0 auto;
}
#p {
width: 100%;
display: flex;
justify-content: space-around;
align-items: center;
}
.c1,
.c2,
.c3 {
margin: 1rem;
min-width: 15rem;
height: 5rem;
text-align: center;
}
.c1 {
background-color: red;
}
.c2 {
background-color: green;
}
.c3 {
background-color: blue;
}
<div id="p">
<div class="c1">
aaa
</div>
<div class="c2">
bbb
</div>
<div class="c3">
ccc
</div>
</div>
You can see when it zooms in to a certain level the red div will be out of the view and cannot be reached.
This impossible with only CSS. You can consider using Javascript.
const container = document.querySelector("#p");
const centerEl = document.querySelector(".center-element");
container.scrollLeft = centerEl.offsetLeft + centerEl.offsetWidth / 2 - container.offsetWidth / 2;
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 100%;
height: 100%;
margin: 0 auto;
}
#p {
width: 100%;
display: flex;
/* removed:
justify-content: space-around;
align-items: center;
*/
overflow-x: scroll; /* added. so that it does not affect the whole page. */
}
.c1,
.c2,
.c3 {
margin: 1rem;
min-width: 15rem;
height: 5rem;
text-align: center;
}
.c1 {
background-color: red;
}
.c2 {
background-color: green;
}
.c3 {
background-color: blue;
}
<div id="p">
<div class="c1">
aaa
</div>
<div class="c2 center-element">
bbb
</div>
<div class="c3">
ccc
</div>
</div>
I have a nested flexbox situation. The first one is to establish two responsive columns:
.ColWrap,
{
width: 100%;
box-sizing: border-box;
background-color: #fff;
padding: 50px 10px 50px 25px;
display: flex;
flex-wrap: wrap;
}
.ColWrap .col,
{
flex: 1;
padding: 20px 20px 20px 0;
margin: auto;
}
#media screen and (max-width: 600px) {
.ColWrap {
flex-direction: column;
}
.ColWrap .col,
{
width: 100%;
padding-left: 0;
}
}
The second is a series of what I'm called "nuggets" inside the right column. These should wrap as necessary:
.nuggetHolder {
width: 100%;
margin: 20px;
display: flex;
flex-wrap: wrap;
}
.nugget {
flex: 0 1 40%;
margin: 10px;
padding: 10px;
border: 2px solid rgba(0,0,0,.2);
}
Putting it together looks like this:
<div class="ColWrap">
<div class="col">
<h2>Left-hand text</h2>
</div>
<div class="col">
<div class="nuggetHolder">
<div class="nugget">Nugget NuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNugget</div>
<div class="nugget">Nugget</div>
<div class="nugget">Nugget</div>
<div class="nugget">Nugget</div>
<div class="nugget">Nugget</div>
<div class="nugget">Nugget</div>
</div>
</div>
The problem I am having is that the nugget with all the text is overflowing outside the container.
Do you think I should set up the 2-column container as a grid and then each "nugget" as a flexbox?
Use word-break: break-word;
word-break: break-word; keep all the text in the size the div already have.
for looking good I add:
flex-grow: 1; in .nugget - it also like change flex: 0 1 40%; to flex: 1 1 40%;
and in .nuggetHolder I replace the margin in padding and add box-sizing: border-box; that calculate the box size with border and padding, and it not break with scroll-x.
.ColWrap,
{
width: 100%;
box-sizing: border-box;
background-color: #fff;
padding: 50px 10px 50px 25px;
display: flex;
flex-wrap: wrap;
}
.ColWrap .col,
{
flex: 1;
padding: 20px 20px 20px 0;
margin: auto;
}
#media screen and (max-width: 600px) {
.ColWrap {
flex-direction: column;
}
.ColWrap .col,
{
width: 100%;
padding-left: 0;
}
}
.nuggetHolder {
width: 100%;
// margin: 20px;
padding: 20px;
display: flex;
flex-wrap: wrap;
box-sizing: border-box;
}
.nugget {
flex: 0 1 40%;
margin: 10px;
padding: 10px;
border: 2px solid rgba(0,0,0,.2);
word-break: break-word;
flex-grow: 1;
}
<div class="ColWrap">
<div class="col">
<h2>Left-hand text</h2>
</div>
<div class="col">
<div class="nuggetHolder">
<div class="nugget">Nugget NuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNuggetNugget</div>
<div class="nugget">Nugget</div>
<div class="nugget">Nugget</div>
<div class="nugget">Nugget</div>
<div class="nugget">Nugget</div>
<div class="nugget">Nugget</div>
</div>
</div>
Add the following to .nugget:
max-width: 40%;
overflow-wrap: break-word;
To center it add justify-content: center to .nuggetHolder.
Added max-width so that any overflowed content, i.e. over 40% will be consistent.
This question already has answers here:
A grid layout with responsive squares
(5 answers)
Closed 5 years ago.
In process of learning flexbox, and confused about having perfect CSS circles that are responsive. How do I do that? As it stands, my current code has circle1, circle2, and circle3 at 100 width, and height. I don't want to hard-code their height but rather make it responsive. Is there a way to have a perfect circle in %? So it scales each time the browser is resized?
Or are media queries the only option to fix this?
Thank you for your help.
* {
box-sizing: border-box;
}
html, body {
height: 100%;
font-family: sans-serif;
font-weight: 100;
}
body {
display: flex;
margin: 0;
flex-direction: column;
}
main {
display: flex;
flex: 1 0 100%;
/*for content and sidebar */
flex-direction: row;
}
/* main */
#content {
flex: 1 0 80%;
/* for header/logo and description */
display: flex;
flex-direction: column;
}
#description img {
display: block;
}
#header {
flex: 1 0 5%;
padding: 10px;
/* for test */
display: flex;
justify-content: center;
}
#test {
display: flex;
flex-direction: row;
}
#header h1 {
text-align: center;
font-size: 5em;
padding: 0;
margin: 0;
font-family: 'Satisfy', cursive;
}
h1 {
font-family: 'Satisfy', cursive;
}
#description {
flex: 1 0 10%;
padding: 30px;
display: flex;
}
#description p {
padding-left: 20px;
font-size: 20px;
}
#description img {
width: 250px;
height: 250px;
border-radius: 50%;
border: 6px solid #db6525;
border: 6px solid #00B2AC;
}
#name {
font-size: 35px;
color: #db6525;
font-family: 'Satisfy', cursive;
}
#test img {
display: inline;
vertical-align: text-top;
width: 100px;
height: 100px;
/* for the following image and description */
display: flex;
flex-direction: row;
align-content: center;
align-items: center;
}
#sidebar {
flex: 1 0 20%;
/* background-color: green; */
text-align: center;
line-height: 90%;
/* for sidebar contents */
display: flex;
flex-direction: column;
}
#js {
flex: 1 0 33.33333%;
/* background-color: red; */
background-color: #db6525;
border: 20px solid #00B2AC;
padding: 10px;
}
#js h1 {
font-size: 50px;
}
#forms {
flex: 1 0 33.33333%;
/* background-color: gray; */
background-color: #db6525;
border: 20px solid #00B2AC;
padding: 10px;
}
#forms h1 {
font-size: 50px;
}
#sites {
flex: 1 0 33.33333%;
/* background-color: Chartreuse; */
background-color: #db6525;
border: 20px solid #00B2AC;
padding: 10px;
}
#sites h1 {
font-size: 50px;
}
.circles {
flex: 0 0 5%;
/* for circles within */
display: flex;
justify-content: center;
align-items: center;
width: 100%;
}
.circle1 {
flex: 0 1 33.33333%;
display: flex;
justify-content: center;
}
.circle1 h1{
font-size: 12px;
color: #fff !important;
background-color: #db6525;
border: 4px solid #00B2AC;
border-radius:50%;
height: 100px;
width: 100px;
text-align: center;
vertical-align: middle;
}
.circle2 {
flex: 0 1 33.33333%;
display: flex;
justify-content: center;
}
.circle2 h1 {
font-size: 12px;
color: #fff !important;
background-color: #db6525;
border: 4px solid #00B2AC;
border-radius:50%;
height: 100px;
width: 100px;
text-align: center;
vertical-align: middle;
}
.circle3 {
flex: 0 1 33.33333%;
display: flex;
justify-content: center;
}
.circle3 h1 {
font-size: 12px;
color: #fff !important;
background-color: #db6525;
border: 4px solid #00B2AC;
border-radius:50%;
height: 100px;
width: 100px;
text-align: center;
vertical-align: middle;
}
<main>
<section id="content">
<article id="header">
<section id="test">
<h1>My Website</h1>
</section>
</article>
<article id="description">
<img src='images/profilePic.png' />
<p></p>
</article>
<article class="circles">
<div class="circle1">
<h1>Twitter</h1>
</div>
<div class="circle2">
<h1>Blog</h1>
</div>
<div class="circle3">
<h1>Contact</h1>
</div>
</article>
</section>
<section id="sidebar">
<article id="js">
<h1>Javascript</h1>
<p>Mini JS Projects</p>
<p class="subtitle">Work in progress
</article>
<article id="forms">
<h1>Free Forms</h1>
<p>Feel free to download the forms</p>
</article>
<article id="sites">
<h1>Portfolio</h1>
<p>Combination of previous work and additional sites</p>
</article>
</section>
</main>
The question now is How to have a perfect responsive css square? Because when you have a square, you will easily have a circle with border-radius: 50%. Now you can found so many solution for it in SO. Here is a nice solution with flexbox item.
.flex-container {
padding: 0;
margin: 0;
display: flex;
}
.flex-item {
background: tomato;
margin: 5px;
color: white;
flex: 1 0 auto;
border-radius: 50%;
}
.flex-item:before {
content:'';
float:left;
padding-top:100%;
}
<div class="flex-container">
<div class="flex-item ">
</div>
<div class="flex-item ">
</div>
<div class="flex-item ">
</div>
</div>
Updated answer
I reworked the flex containers to a minimal working example. The flex-items should all be set to
flex: 1 1 auto /* flex-grow flex-shrink flex-basis */
This allows the circle h1 flex-items to grow and shrink as necessary. It might be necessary to use js to obtain the height of a circle from its expanded width when you apply the example to your code.
Hope this helps.
html,
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
.circles {
/* for circles within */
display: flex;
justify-content: center;
height: 100%;
width: 100%;
}
.circle1,
.circle2,
.circle3 {
display: flex;
flex: 1 1 auto;
width: 33vw;
height: 33vw;
}
.circle1 h1,
.circle2 h1,
.circle3 h1 {
flex: 1 1 auto;
width: 100%;
height: 100%;
font-size: 12px;
color: #fff !important;
background-color: #db6525;
border: 4px solid #00B2AC;
border-radius: 50%;
text-align: center;
vertical-align: middle;
}
<article class="circles">
<div class="circle1">
<h1>Twitter</h1>
</div>
<div class="circle2">
<h1>Blog</h1>
</div>
<div class="circle3">
<h1>Content</h1>
</div>
</article>