Vertically Centered, 2-Col Responsive Content Overflowing - css

I'm trying to set up 2-columns that are responsive (e.g., collapse with one on top of the other). The left column has text and the right has some buttons.
I want both to center align with each other vertically within the container. However, when I test for responsiveness, my buttons overflow out of the container instead of wrapping with the 2nd column:
.boxContent {
max-width: 1024px;
margin-left: auto;
margin-right: auto;
padding: 20px;
display: flex;
flex-direction: row;
align-items: center;
}
.boxCol {
flex: 0 0 50%;
box-sizing: border-box;
padding-right: 75px;
}
a.boxBtn {
display: block;
padding: 0.35em 1.2em;
border: 0.1em solid #1e1e1e;
margin: 0 0.3em 0.3em 0;
border-radius: 2%;
box-sizing: border-box;
text-decoration: none;
background-color: #fff;
text-align: left;
transition: all 0.2s;
}
.boxBtn:hover {
color: #000;
background-color: #e5bc73;
cursor: pointer;
}
#media all and (max-width: 30em) {
a.boxBtn {
margin: 0.4em auto;
}
}
#media screen and (max-width: 800px) {
.boxCol {
flex: 0 1 100%;
padding-right: 0;
padding-bottom: 75px;
}
}
<div class="Container">
<div class="boxContent">
<div class="boxCol">
<h1>Heading</h1>
</div>
<div class="boxCol">
<a class="boxBtn">
Button 1
</a>
<a class="boxBtn">
Button 2
</a>
<a class="boxBtn">
Button 3
</a>
</div>
</div>
</div>

from my comment :
you need either to reset flex-direction or allow wrapping on smaller screen. Your media queries do not reset any of them rules
If it is only to pile them without reordering purpose, display reset is good enough ,
possible example:
.boxContent {
max-width: 1024px;
margin-left: auto;
margin-right: auto;
padding: 20px;
display: flex;
flex-direction: row;
align-items: center;
}
.boxCol {
flex: 0 0 50%;
box-sizing: border-box;
padding-right: 75px;
}
a.boxBtn {
display: block;
padding: 0.35em 1.2em;
border: 0.1em solid #1e1e1e;
margin: 0 0.3em 0.3em 0;
border-radius: 2%;
box-sizing: border-box;
text-decoration: none;
background-color: #fff;
text-align: left;
transition: all 0.2s;
}
.boxBtn:hover {
color: #000;
background-color: #e5bc73;
cursor: pointer;
}
#media all and (max-width: 30em) {
a.boxBtn {
margin: 0.4em auto;
}
}
#media screen and (max-width: 800px) {
.boxContent {display:block;}
}
<div class="Container">
<div class="boxContent">
<div class="boxCol">
<h1>Heading</h1>
</div>
<div class="boxCol">
<a class="boxBtn">
Button 1
</a>
<a class="boxBtn">
Button 2
</a>
<a class="boxBtn">
Button 3
</a>
</div>
</div>
</div>
Tip: another approach would be to trigger the flex display at min-width:800px only, before no need for a 1 column layout.

Related

Bottom aligned container using flexbox causing problem with media screen

I have the following...
...and I want to stack the blue container (with box 10 and 20) when outer green container width falls below 500px, like this:
I'm using media screen to do this but the fiddle shows how the stacking doesn't work properly and enters the brown container. The stacking works fine when the blue container is allowed to locate at the top of the green container using a relative position, but it fails when I locate it at the bottom using absolute. Can anyone show me what I'm doing wrong?
#TOTALcontainer {
border: 1px solid green;
position: absolute;
margin: 5px;
}
#outerLHcontainer {
position: relative;
border: 1px solid brown;
margin: 5px;
}
#LHcontainer {
position: relative;
border: 1px solid red;
margin: 30px 0 30px 10px;
margin-right: 12vw;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-flex-flow: row wrap;
justify-content: space-around;
}
#div1,
#div2,
#div3 {
width: 250px;
height: 10px;
padding: 10px;
border: 1px solid #aaaaaa;
float: left;
clear: left;
margin: 10px;
}
#RHcontainer {
position: relative;
border: 1px solid blue;
margin: 5px;
display: flex;
bottom: 0;
right: 0;
float: right;
}
#div10,
#div20 {
width: 60px;
height: 10px;
margin-right: 30px;
padding: 10px;
border: 1px solid #aaaaaa;
}
#media screen and (min-width: 500px) {
#outerLHcontainer {
width: 50%;
float: left;
}
}
<div id="TOTALcontainer">
<div id="outerLHcontainer">
<div id="LHcontainer">
<div id="div1">1</div>
<div id="div2">2</div>
<div id="div3">3</div>
</div>
</div>
<div id="RHcontainer">
<div id="div10">10</div>
<div id="div20">20</div>
</div>
</div>
http://jsfiddle.net/pb2gckL5/3/
You could go probaly another way to do it. Simply with flexbox:
<div class="container">
<div class="left">
the item of the left <br>left <br>left <br>left <br>left <br>left <br>left <br>left <br>
</div>
<div class="right">
<div class="right-block">
blue block
</div>
</div>
</div>
.container {
width: 100%;
border: 1px solid red;
display: flex;
align-items: flex-end;
}
.left, .right {
flex: 1 0 0;
margin: 5px;
}
.left {
border: 1px solid green;
}
.right {
border: 1px solid blue;
}
#media screen and (max-width: 499px) {
.container {
flex-direction: column;
}
.left, .right {
width: calc(100% - 10px);
}
}
https://codepen.io/priatelko/pen/oNYoKga

Custom card component using Flex

I think I'm quite close to getting it right but the problem I'm having right now is that the texts overflow when the screen gets really small..which is unlikely to happen but I want to fix it so that the texts will never overflow out of the box.
How can I achieve that?
Here's my fiddle - https://jsfiddle.net/q3vue7wy/
.wrapper {
display: flex;
justify-content: center;
align-items: center;
font-size: 1rem;
height: 7.75rem;
transition: all 300ms;
box-shadow: 0 2px 4px 0 rgba(224, 224, 224, 0.5);
border: solid 1px #F5F5F5;
}
.imageContainer {
flex: 0 0 33%;
height: 100%;
}
.image {
width: 100%;
height: 100%;
object-fit: cover;
}
.content {
flex: 1;
text-align: left;
margin: 0 1.1825rem;
}
.title {
font-size: 1rem;
margin: 0 0 0.25rem 0;
padding: 0;
}
.price {
color: #BAA082;
font-size: 0.875rem;
text-transform: uppercase;
margin: 2rem 0 0;
padding: 0;
}
#media(min-width: 46.5rem) {
.wrapper {
height: 8.75rem;
}
.title {
font-size: 1.1875rem;
}
.price {
font-size: 1rem;
}
}
<div class="wrapper">
<div class="content">
<h4 class="title">Point of sale</h4>
<p>Point of sale</p>
<p class="price">From £165</p>
</div>
<div class="imageContainer">
<img src="https://images.unsplash.com/photo-1556742521-9713bf272865?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2134&q=80" alt="" class="image"></div>
</div>
A simple solution is to make the image width shrink when the card gets too small. To do this, change the following properties:
.wrapper {
justify-content: space-between;
}
.imageContainer {
flex: 0 1 33%;
}
.content {
flex: 0 0 auto;
}
Which should give:
.wrapper {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 1rem;
height: 7.75rem;
transition: all 300ms;
box-shadow: 0 2px 4px 0 rgba(224, 224, 224, 0.5);
border: solid 1px #F5F5F5;
}
.imageContainer {
flex: 0 1 33%;
height: 100%;
}
.image {
width: 100%;
height: 100%;
object-fit: cover;
}
.content {
flex: 0 0 auto;
text-align: left;
margin: 0 1.1825rem;
}
.title {
font-size: 1rem;
margin: 0 0 0.25rem 0;
padding: 0;
}
.price {
color: #BAA082;
font-size: 0.875rem;
text-transform: uppercase;
margin: 2rem 0 0;
padding: 0;
}
#media(min-width: 46.5rem) {
.wrapper {
height: 8.75rem;
}
.title {
font-size: 1.1875rem;
}
.price {
font-size: 1rem;
}
}
<div class="wrapper">
<div class="content">
<h4 class="title">Point of sale</h4>
<p>Point of sale</p>
<p class="price">From £165</p>
</div>
<div class="imageContainer">
<img src="https://images.unsplash.com/photo-1556742521-9713bf272865?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2134&q=80" alt="" class="image"></div>
</div>
JSFiddle: https://jsfiddle.net/wq1cev3y/
HTML- Replace the below code to your HTML code
<div class="wrapper">
<div class="content">
<h4 class="title">
Point of sale
</h4>
<p class="dec">
Point of sale
</p>
<p class="price">
From £165
</p>
</div>
<div class="imageContainer">
<img src="https://images.unsplash.com/photo-1556742521-9713bf272865?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2134&q=80" alt="" class="image">
</div>
</div>
CSS- Replace the below code to your media query code.
#media only screen and (max-width: 600px)
{
.wrapper{
height: 8.75rem;
}
.title{
font-size: 0.8rem;
margin:0;
padding-bottom:8%;
}
.dec{
font-size: 0.8rem;
margin:0;
padding-bottom:8%;
}
.price{
font-size: 0.8rem;
margin:0;
padding-bottom:8%;
}
}

unable to move elements in flexbox

I'm unable to move the submit button to the left 1vw without disturbing the anchor tags in the right. Also, there's plenty of room in the anchor borders but I can't get the text and image to stay on the same line when decreasing the width of the browser.
UPDATE: was able to keep img and text on same line in anchor by changing anchor display:block to display:inline-flex.
Still unable to move the submit buttom to the right without disturbing the anchor tags
#footer-top{
background-color:white;
padding: 0 2.87rem;
}
h3{
color:#b3d7f8;
font-size: 1.5vw;
padding-top:3vw;
padding-left:2vw;
background-color:#538231;
margin:0
}
#footer-container{
padding: 0 2.87rem;
background-color:white;
}
.myFooter{
background-color:white;
display: flex;
flex-wrap: nowrap;
}
.myFooter .left{
flex: 1 1 auto;
background-color:#538231;
padding-top:3vw;
padding-left:2vw;
padding-bottom:2vw;
}
.myFooter label{
display: block;
color: #c2d59b;
margin-bottom:1vw;
font-size:1vw;
}
.myFooter input{
padding: .5vw .5vw;
}
#email{
height:1vw;
line-height:1;
font-size:1vw;
width:25vw;
}
.submit-button {
background-color: white!important;
border: none!important;
color: black!important;
padding: .5vw .5vw!important;
text-align: center!important;
text-decoration: none!important;
display: inline-block!important;
font-size: 1vw!important;
height:2vw!important;
width:5vw!important;
line-height:1vw!important;
}
.myFooter .right{
flex: 1 1 ;
background-color:#538231;
padding-bottom:2vw;
}
.myFooter .right a{
display: inline-flex;
color: white;
border: 1px solid white;
width: 71%;
margin: 1vw 0;
text-decoration:none;
}
.myFooter .right img{
width: 1.5vw;
height: 100%;
padding: .59vw 0;
display:block;
float:left;
margin:0 1vw;
}
.myFooter .right span{
font-size:1vw;
padding:1vw 0;
display:inline-block;
line-height:1;
}
#media screen and (max-width: 961px) {#footer-top,#footer-container{
padding:0 1.7rem;}
}
<div id ="footer-top">
<h3>Help create a sustainable and healthy town of Weston</h3>
</div>
<div id="footer-container">
<div class="myFooter">
<div class="left">
<form name="message" method="post">
<section>
<label for="email">Join our mailing list:</label><input id="email" type="email" name="email" placeholder="enter email">
<input class="submit-button" type="submit" value="Submit">
</section>
</form>
</div>
<div class="right">
<a href="https://www.facebook.com/groups/1960906387454685">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/facebook-square-brands-green.png">
<span class="foot-txt">Like us on Facebook</span>
</a>
<a href="https://www.instagram.com/sustainablewestonactiongroup/">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/instagram-brands-green.png">
<span class="foot-txt">follow us on Instagram</span>
</a>
<a href="https://twitter.com/Weston_SWAG">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/twitter-square-brands-green.png">
<span class="foot-txt">Retweet us on Twitter</span>
</a>
</div>
</div>
<div>
Since your .left and .right elements have flex-grow: 1 applied (via the flex shorthand) they have expanded across all free space and are touching. So anything that changes the width of one element will impact the other.
First thing I would suggest is to get rid of that rule and instead use justify-content: space-between on the container.
Then, prevent the anchors on the right from wrapping by giving them white-space: nowrap. Also remove the width limitation so the text doesn't overflow.
#footer-top {
background-color: white;
padding: 0 2.87rem;
}
h3 {
color: #b3d7f8;
font-size: 1.5vw;
padding-top: 3vw;
padding-left: 2vw;
background-color: #538231;
margin: 0
}
#footer-container {
padding: 0 2.87rem;
background-color: white;
}
.myFooter {
/* background-color: white; */
background-color: #538231; /* adjustment */
display: flex;
flex-wrap: nowrap;
justify-content: space-between; /* new */
}
.myFooter .left {
/* flex: 1 1 auto; */
background-color: #538231;
padding-top: 3vw;
padding-left: 2vw;
padding-bottom: 2vw;
}
.myFooter label {
display: block;
color: #c2d59b;
margin-bottom: 1vw;
font-size: 1vw;
}
.myFooter input {
padding: .5vw .5vw;
}
#email {
height: 1vw;
line-height: 1;
font-size: 1vw;
width: 25vw;
}
.submit-button {
background-color: white !important;
border: none !important;
color: black !important;
padding: .5vw .5vw !important;
text-align: center !important;
text-decoration: none !important;
display: inline-block !important;
font-size: 1vw !important;
height: 2vw !important;
width: 5vw !important;
line-height: 1vw !important;
margin-left: 5px; /* change values here; right anchors don't move anymore */
}
.myFooter .right {
/* flex: 1 1; */
background-color: #538231;
padding-bottom: 2vw;
padding-right: 2vw; /* new */
}
.myFooter .right a {
display: block;
color: white;
border: 1px solid white;
/* width: 71%; */
margin: 1vw 0;
text-decoration: none;
white-space: nowrap; /* new */
padding-right: 2vw; /* new */
}
.myFooter .right img {
width: 1.5vw;
height: 100%;
padding: .59vw 0;
display: block;
float: left;
margin: 0 1vw;
}
.myFooter .right span {
font-size: 1vw;
padding: 1vw 0;
display: inline-block;
line-height: 1;
}
#media screen and (max-width: 961px) {
#footer-top,
#footer-container {
padding: 0 1.7rem;
}
}
<div id="footer-top">
<h3>Help create a sustainable and healthy town of Weston</h3>
</div>
<div id="footer-container">
<div class="myFooter">
<div class="left">
<form name="message" method="post">
<section>
<label for="email">Join our mailing list:</label><input id="email" type="email" name="email" placeholder="enter email">
<input class="submit-button" type="submit" value="Submit">
</section>
</form>
</div>
<div class="right">
<a href="https://www.facebook.com/groups/1960906387454685">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/facebook-square-brands-green.png">
<span class="foot-txt">Like us on Facebook</span>
</a>
<a href="https://www.instagram.com/sustainablewestonactiongroup/">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/instagram-brands-green.png">
<span class="foot-txt">follow us on Instagram</span>
</a>
<a href="https://twitter.com/Weston_SWAG">
<img class="foot-icons" src="https://sustainablewestonma.000webhostapp.com/wp-content/uploads/2019/08/twitter-square-brands-green.png">
<span class="foot-txt">Retweet us on Twitter</span>
</a>
</div>
</div>
<div>
jsFiddle demo

Two responsive/flexible divs side by side

I have two responsive divs side by side.
When screen size is smaller than 600px wide, those two divs rearrange one on top of the other, like they should do, BUT... I can't get those two divs to be flexible and 100% wide when screen size gets smaller than 600px.
I've tried flexbox and many other things but just can't get divs flexible. Anyone knows?
body
{
background-color: #fcfcfc;
}
.columns
{
text-align: center;
padding-right: 15px;
padding-left: 15px;
padding-top: 0;
}
.left-div
{
display: inline-block;
max-width: 400px;
text-align: left;
padding: 10px;
background-color: #ddd;
border-radius: 3px;
margin: 5px;
vertical-align: top;
}
.right-div
{
display: inline-block;
max-width: 400px;
text-align: left;
padding: 10px;
background-color: #ddd;
border-radius: 3px;
margin: 5px;
}
.left-text, .right-text
{ text-align:justify;
}
#media screen and (max-width: 600px)
{
.left-div, .right-div
{
max-width: 100%;
}
}
<div class="columns">
<div class="left-div left-text">
<p> Lorem ipsum LEFT.</p>
</div>
<div class="right-div right-text">
<p> Lorem ipsum RIGHT.</p>
</div>
</div>
You need to also make width:100% in addition to specifying the max-width:100%. You also need to add box-sizing:border-box; to avoid some overflow due to the use of padding.
Check the full code, i used 800px instead of 600px so we can see the result here.
body {
background-color: #fcfcfc;
}
.columns {
text-align: center;
padding-right: 15px;
padding-left: 15px;
padding-top: 0;
}
.left-div {
display: inline-block;
max-width: 400px;
text-align: left;
padding: 10px;
background-color: #ddd;
border-radius: 3px;
margin: 5px;
vertical-align: top;
}
.right-div {
display: inline-block;
max-width: 400px;
text-align: left;
padding: 10px;
background-color: #ddd;
border-radius: 3px;
margin: 5px;
}
.left-text,
.right-text {
text-align: justify;
}
#media screen and (max-width: 800px) {
.left-div,
.right-div {
max-width: 100%;
width: 100%;
box-sizing: border-box;
}
}
<div class="columns">
<div class="left-div left-text">
<p> Lorem ipsum LEFT.</p>
</div>
<div class="right-div right-text">
<p> Lorem ipsum RIGHT.</p>
</div>
</div>
Display your elements as block so that they can occupy the full horizontal width available, e.g: display: block;
And for good measure, declare width: 100%
#media screen and (max-width: 600px) {
.left-div,
.right-div {
max-width: 100%;
/* Additional */
width: 100%;
display: block;
}
}
body {
background-color: #fcfcfc;
}
.columns {
text-align: center;
padding-right: 15px;
padding-left: 15px;
padding-top: 0;
}
.left-div {
display: inline-block;
max-width: 400px;
text-align: left;
padding: 10px;
background-color: #ddd;
border-radius: 3px;
margin: 5px;
vertical-align: top;
}
.right-div {
display: inline-block;
max-width: 400px;
text-align: left;
padding: 10px;
background-color: #ddd;
border-radius: 3px;
margin: 5px;
}
.left-text,
.right-text {
text-align: justify;
}
#media screen and (max-width: 600px) {
.left-div,
.right-div {
max-width: 100%;
/* Additional */
width: 100%;
display: block;
}
}
<div class="columns">
<div class="left-div left-text">
<p> Lorem ipsum LEFT.</p>
</div>
<div class="right-div right-text">
<p> Lorem ipsum RIGHT.</p>
</div>
</div>
Or you could "Just use Flex"...
#media screen and (max-width: 600px) {
.columns {
display: flex;
justify-content: center;
flex-direction: column;
}
.left-div,
.right-div {
max-width: 100%;
}
}
body {
background-color: #fcfcfc;
}
.columns {
text-align: center;
padding-right: 15px;
padding-left: 15px;
padding-top: 0;
}
.left-div {
display: inline-block;
max-width: 400px;
text-align: left;
padding: 10px;
background-color: #ddd;
border-radius: 3px;
margin: 5px;
vertical-align: top;
}
.right-div {
display: inline-block;
max-width: 400px;
text-align: left;
padding: 10px;
background-color: #ddd;
border-radius: 3px;
margin: 5px;
}
.left-text,
.right-text {
text-align: justify;
}
#media screen and (max-width: 600px) {
.columns {
display: flex;
justify-content: center;
flex-direction: column;
}
.left-div,
.right-div {
max-width: 100%;
}
}
<div class="columns">
<div class="left-div left-text">
<p> Lorem ipsum LEFT.</p>
</div>
<div class="right-div right-text">
<p> Lorem ipsum RIGHT.</p>
</div>
</div>
Heads up! flex-box has poor or limited support for legacy browsers, so if this is going to be a concern for you, it's probably better not to use it in production.
IE <= 9 - Not Supported
IE 10,11 - Partial Support
See more: https://caniuse.com/#feat=flexbox
Edit: As #TemaniAfif has pointed out in the comments, you should set a border-box property as well, e.g: box-sizing: border-box
.left-text,
.right-text {
text-align: justify;
box-sizing: border-box;
}
Typically, this is set as a global rule, using a global selector, e.g: * { box-sizing: border-box; }
border-box tells the browser to account for any border and padding
in the value you specify for width and height. If you set an element's
width to 100 pixels, that 100 pixels will include any border or
padding you added, and the content box will shrink to absorb that
extra width. This typically makes it much easier to size elements.
Want to learn more? https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

how to have a perfect responsive css circles? [duplicate]

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>

Resources