how to adjust padding in html/css? - html

I want to give padding on image to close to the remaining section but nothing works for me.
I am trying:
float-right or padding-right:250px; // but nothing happent and also it will spoil my mobile view also.
Kindly check what I am doing:
.fontProfile {
font-family: "Open Sans", Arial, sans-serif;
/* min-height: 100vh;
background-color: #fafafa;
color: #262626;
padding-bottom: 3rem; */
}
.imgProfile {
display: block;
}
.containerProfile {
max-width: 93.5rem;
margin: 0 auto;
padding: 0 2rem;
}
.btnProfileIn {
display: inline-block;
font: inherit;
background: none;
border: none;
color: inherit;
padding: 0;
cursor: pointer;
}
.btnProfileIn:focus {
outline: 0.5rem auto #4d90fe;
}
/* Profile Section */
.profile {
padding: 5rem 0;
}
.profile::after {
content: "";
display: block;
clear: both;
}
.profile-image {
float: left;
width: calc(33.333% - 1rem);
display: flex;
justify-content: center;
align-items: center;
margin-right: 3rem;
}
.imgProfile {
border-radius: 50%;
}
.profile-user-settings,
.profile-stats,
.profile-bio {
float: left;
width: calc(66.666% - 2rem);
}
.profile-user-settings {
margin-top: 1.1rem;
}
.profile-user-name {
display: inline-block;
font-size: 3.2rem;
font-weight: 300;
}
.profile-edit-btn {
font-size: 1.4rem;
line-height: 1.8;
border: 0.1rem solid #dbdbdb;
border-radius: 0.3rem;
padding: 0 2.4rem;
margin-left: 2rem;
}
.profile-settings-btn {
font-size: 2rem;
margin-left: 1rem;
}
.profile-stats {
margin-top: 2.3rem;
}
.profile-stats li {
display: inline-block;
font-size: 1.6rem;
line-height: 1.5;
margin-right: 4rem;
cursor: pointer;
}
.profile-stats li:last-of-type {
margin-right: 0;
}
.profile-bio {
font-size: 1.6rem;
font-weight: 400;
line-height: 1.5;
margin-top: 2.3rem;
}
.profile-real-name,
.profile-stat-count,
.profile-edit-btn {
font-weight: 600;
}
/* Media Query */
#media screen and (max-width: 40rem) {
.profile {
display: flex;
flex-wrap: wrap;
padding: 4rem 0;
}
.profile::after {
display: none;
}
.profile-image,
.profile-user-settings,
.profile-bio,
.profile-stats {
float: none;
width: auto;
}
.profile-image {
width: 3.7rem;
}
.profile-user-settings {
flex-basis: calc(100% - 10.7rem);
display: flex;
flex-wrap: wrap;
margin-top: 1rem;
}
.profile-user-name {
font-size: 2.2rem;
}
.profile-edit-btn {
order: 1;
padding: 0;
text-align: center;
margin-top: 1rem;
}
.profile-edit-btn {
margin-left: 0;
}
.profile-bio {
font-size: 1.4rem;
margin-top: 1.5rem;
}
.profile-edit-btn,
.profile-bio,
.profile-stats {
flex-basis: 100%;
}
.profile-stats {
order: 1;
margin-top: 1.5rem;
}
.profile-stats ul {
display: flex;
text-align: center;
padding: 1.2rem 0;
border-top: 0.1rem solid #dadada;
border-bottom: 0.1rem solid #dadada;
}
.profile-stats li {
font-size: 1.4rem;
flex: 1;
margin: 0;
}
.profile-stat-count {
display: block;
}
}
#supports (display: grid) {
.profile {
display: grid;
grid-template-columns: 1fr 2fr;
grid-template-rows: repeat(3, auto);
grid-column-gap: 3rem;
align-items: center;
}
.profile-image {
grid-row: 1 / -1;
}
.profile-image,
.profile-user-settings,
.profile-stats,
.profile-bio {
width: auto;
margin: 0;
}
#media (max-width: 40rem) {
.profile {
grid-template-columns: auto 1fr;
grid-row-gap: 1.5rem;
}
.profile-image {
grid-row: 1 / 2;
}
.profile-user-settings {
display: grid;
grid-template-columns: auto 1fr;
grid-gap: 1rem;
}
.profile-edit-btn,
.profile-stats,
.profile-bio {
grid-column: 1 / -1;
}
.profile-user-settings,
.profile-edit-btn,
.profile-settings-btn,
.profile-bio,
.profile-stats {
margin: 0;
}
}
}
<header>
<div class="container containerProfile">
<div class="profile">
<div class="profile-image">
<img class="imgProfile" src="https://images.unsplash.com/photo-1513721032312-6a18a42c8763?w=152&h=152&fit=crop&crop=faces" alt="">
</div>
<div class="profile-user-settings">
<h1 class="profile-user-name fontProfile">janedoe_</h1>
<button class="btnProfileIn profile-edit-btn">Edit Profile</button>
<button class="btnProfileIn profile-settings-btn" aria-label="profile settings"><i class="fa fa-cog" aria-hidden="true"></i></button>
</div>
<div class="profile-stats">
<ul>
<li><span class="profile-stat-count">164</span> posts</li>
<li><span class="profile-stat-count">188</span> followers</li>
<li><span class="profile-stat-count">206</span> following</li>
</ul>
</div>
<div class="profile-bio">
<!-- <p><span class="profile-real-name">Jane Doe</span></p> -->
</div>
</div>
<!-- End of profile section -->
</div>
<!-- End of container -->
</header>
I am having so much gap between Image and name. I want that div come close to the remaining part.
This is the problem - The gap
Any idea or suggestions would be welcome.

try on your css part
.imgProfile {
padding-right:250px }

Instead of adding padding to the profile-image what you can do is to try to make the remaining part come close to the image div and for this you can do this:
.profile-user-settings {
width: auto;
margin: 0px;
margin-right: -35px;
}

You can use flex for the image div and justify the content to the end.
.imgProfile {
display: flex;
justify-content: flex-end;
}

If you include margin-left:200px(or whatever you want), you can close the pic to the remaining section.Like this:
.imgProfile { display: block; margin-left: 200px; }

in this part of the
css
`#supports (display: grid){ .profile {
display: grid;
grid-template-columns: auto 1fr;
grid-template-rows: repeat(3, auto);
grid-column-gap: 3rem;
align-items: center;}`
change like i did grid-template-columns:1fr 2fr; to auto 1fr ; and you can remove grid-column-gap

Related

Trying to get two different fig captions side by side in a container

I'm trying to get two separate fig captions side by side instead of one on top of the other, every time i tryed it would just move the teaxtarea.
textarea {
border: none;
overflow: auto;
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
:root {
font-size: 10px;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
sans-serif;
min-height: 100vh;
background-color: #fafafa;
color: #262626;
padding-bottom: 3rem;
}
img {
display: block;
}
.container {
width: 400px;
margin-left: auto;
margin-right: auto;
max-width: 93.5rem;
margin: 0 auto;
padding: 0 2rem;
}
.btn {
display: inline-block;
font: inherit;
background: none;
border: none;
color: inherit;
padding: 0;
cursor: pointer;
}
.btn:focus {
outline: 0.5rem auto #4d90fe;
}
.visually-hidden {
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px);
}
/* Profile Section */
.profile {
padding: 5rem 0;
}
.profile::after {
content: "";
display: block;
clear: both;
}
.profile-user-settings,
.profile-stats,
.profile-bio {
float: left;
width: calc(66.666% - 2rem);
}
.profile-user-settings {
margin-top: 1.1rem;
}
.profile-user-name {
display: inline-block;
font-size: 3.2rem;
font-weight: 300;
}
.profile-edit-btn {
font-size: 1.4rem;
line-height: 1.8;
border: 0.1rem solid #dbdbdb;
border-radius: 0.3rem;
padding: 0 2.4rem;
margin-left: 2rem;
}
.profile-stats li {
display: inline-block;
font-size: 1.6rem;
line-height: 1.5;
margin-right: 4rem;
cursor: pointer;
}
.profile-stats li:last-of-type {
margin-right: 0;
}
.profile-real-name,
.profile-stat-count,
.profile-edit-btn {
font-weight: 600;
}
/* Gallery Section */
.gallery {
display: flex;
flex-wrap: wrap;
margin: -1rem -1rem;
padding-bottom: 3rem;
}
.gallery-item {
position: relative;
flex: 1 0 22rem;
margin: 1rem;
color: #fff;
cursor: pointer;
}
.gallery-item:hover .gallery-item-info,
.gallery-item:focus .gallery-item-info {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
}
.gallery-item-info {
display: none;
}
.gallery-item-info li {
display: inline-block;
font-size: 1.7rem;
font-weight: 600;
}
.gallery-item-likes {
margin-right: 2.2rem;
}
.gallery-item-type {
position: absolute;
top: 1rem;
right: 1rem;
font-size: 2.5rem;
text-shadow: 0.2rem 0.2rem 0.2rem rgba(0, 0, 0, 0.1);
}
.fa-clone,
.fa-comment {
transform: rotateY(180deg);
}
.gallery-image {
width: 100%;
height: 100%;
object-fit: cover;
}
/* Media Query */
#media screen and (max-width: 40rem) {
.profile {
display: flex;
flex-wrap: wrap;
padding: 4rem 0;
}
.profile::after {
display: none;
}
.profile-image,
.profile-user-settings,
.profile-bio,
.profile-stats {
float: none;
width: auto;
}
.profile-user-settings {
flex-basis: calc(100% - 10.7rem);
display: flex;
flex-wrap: wrap;
margin-top: 1rem;
}
.profile-user-name {
font-size: 2.2rem;
}
.profile-edit-btn {
order: 1;
padding: 0;
text-align: center;
margin-top: 1rem;
}
.profile-edit-btn {
margin-left: 0;
}
.profile-bio {
font-size: 1.4rem;
margin-top: 1.5rem;
}
.profile-edit-btn,
.profile-bio,
.profile-stats {
flex-basis: 100%;
}
.profile-stats {
order: 1;
margin-top: 1.5rem;
}
.profile-stats ul {
display: flex;
text-align: center;
padding: 1.2rem 0;
border-top: 0.1rem solid #dadada;
border-bottom: 0.1rem solid #dadada;
}
.profile-stats li {
font-size: 1.4rem;
flex: 1;
margin: 0;
}
.profile-stat-count {
display: block;
}
}
/* Spinner Animation */
#keyframes loader {
to {
transform: rotate(360deg);
}
}
/*
The following code will only run if your browser supports CSS grid.
Remove or comment-out the code block below to see how the browser will fall-back to flexbox & floated styling.
*/
#supports (display: grid) {
.profile {
display: grid;
grid-template-columns: 1fr 2fr;
grid-template-rows: repeat(3, auto);
grid-column-gap: 3rem;
align-items: center;
}
.profile-image {
grid-row: 1 / -1;
}
.gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
grid-gap: 2rem;
}
.profile-image,
.profile-user-settings,
.profile-stats,
.profile-bio,
.gallery-item,
.gallery {
width: auto;
margin: 0;
}
#media (max-width: 40rem) {
.profile {
grid-template-columns: auto 1fr;
grid-row-gap: 1.5rem;
}
.profile-image {
grid-row: 1 / 2;
}
.profile-user-settings {
display: grid;
grid-template-columns: auto 1fr;
grid-gap: 1rem;
}
.profile-edit-btn,
.profile-stats,
.profile-bio {
grid-column: 1 / -1;
}
.profile-user-settings,
.profile-edit-btn,
.profile-settings-btn,
.profile-bio,
.profile-stats {
margin: 0;
}
}
}
#import url(https://fonts.googleapis.com/css?family=Raleway:400,200,300,800);
#import url(https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css);
figure.snip0056 {
font-family: 'Raleway', Arial, sans-serif;
position: relative;
overflow: hidden;
margin: 10px;
min-width: 380px;
max-width: 480px;
width: 100%;
background: #ffffff;
color: #000000;
}
figure.snip0056 * {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
figure.snip0056 > img {
width: 50%;
border-radius: 50%;
border: 4px solid #ffffff;
-webkit-transition: all 0.35s ease-in-out;
transition: all 0.35s ease-in-out;
-webkit-transform: scale(1.6);
transform: scale(1.6);
position: relative;
float: right;
right: -15%;
z-index: 1;
}
figure.snip0056 figcaption {
padding: 20px 30px 20px 20px;
position: absolute;
left: 0;
width: 50%;
}
figure.snip0056 figcaption h2,
figure.snip0056 figcaption p {
margin: 0;
text-align: left;
padding: 10px 0;
width: 100%;
}
figure.snip0056 figcaption h2 {
font-size: 1.3em;
font-weight: 300;
text-transform: uppercase;
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
figure.snip0056 figcaption h2 span {
font-weight: 800;
}
figure.snip0056 figcaption p {
font-size: 0.9em;
opacity: 0.8;
}
figure.snip0056 figcaption .icons {
width: 100%;
text-align: left;
}
figure.snip0056 figcaption .icons i {
font-size: 26px;
padding: 5px;
top: 50%;
color: #000000;
}
figure.snip0056 figcaption a {
opacity: 0.3;
-webkit-transition: opacity 0.35s;
transition: opacity 0.35s;
}
figure.snip0056 figcaption a:hover {
opacity: 0.8;
}
figure.snip0056 .position {
width: 100%;
text-align: left;
padding: 15px 30px;
font-size: 0.9em;
opacity: 1;
font-style: italic;
color: #ffffff;
background: #000000;
clear: both;
}
figure.snip0056.blue .position {
background: #20638f;
}
figure.snip0056.red .position {
background: #962d22;
}
figure.snip0056.yellow .position {
background: #bf6516;
}
figure.snip0056:hover > img,
figure.snip0056.hover > img {
right: -12%;
}
#import url('//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
#social {
position: absolute;
right: 0;
bottom: 0;
margin: 20px 10px;
text-align: center;
}
.smGlobalBtn { /* global button class */
display: inline-block;
position: relative;
cursor: pointer;
width: 50px;
height: 50px;
border:2px solid #ddd; /* add border to the buttons */
box-shadow: 0 3px 3px #999;
padding: 0px;
text-decoration: none;
text-align: center;
color: #fff;
font-size: 25px;
font-weight: normal;
line-height: 2em;
border-radius: 27px;
-moz-border-radius:27px;
-webkit-border-radius:27px;
}
/* facebook button class*/
.facebookBtn{
background: #4060A5;
}
.facebookBtn:before{ /* use :before to add the relevant icons */
font-family: "FontAwesome";
content: "\f09a"; /* add facebook icon */
}
.facebookBtn:hover{
color: #4060A5;
background: #fff;
border-color: #4060A5; /* change the border color on mouse hover */
}
/* twitter button class*/
.twitterBtn{
background: #00ABE3;
}
.twitterBtn:before{
font-family: "FontAwesome";
content: "\f099"; /* add twitter icon */
}
.twitterBtn:hover{
color: #00ABE3;
background: #fff;
border-color: #00ABE3;
}
/* instagram button class*/
.instagramBtn{
background: #4169E1;
}
.instagramBtn:before{
font-family: "FontAwesome";
content: "\f16d"; /* add instagram icon */
}
.instagramBtn:hover{
color: #00FFFF;
background: #fff;
border-color: #4169E1;
}
<div class="container">
<div class="profile">
<form action="testing.php" method="post">
<textarea name="text2" rows="2" cols=0> Family Name</textarea><br>
</form>
<button class="btn profile-edit-btn">Edit Profile</button>
</div>
<!-- End of profile section -->
</div>
<!-- End of container -->
</header>
<main>
<div class="container">
<figure class="snip0056">
<figcaption>
<textarea name="text2" rows="2" cols=0></textarea>
<textarea name="text3" rows="8" cols=20>.</textarea>
</p>
</figcaption><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sq-sample8.jpg" alt="profilepic1" />
<div class="position">
<textarea name="text4" rows="1" cols=9></textarea>
</div>
</h3>
</figure>
<figure class="snip0056 yellow">
<figcaption>
<textarea name="text5" rows="2" cols=0></textarea>
<textarea name="text6" rows="8" cols=20></textarea>
</figcaption><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sq-sample9.jpg" alt="sample9" />
<div class="position">
<textarea name="text4" rows="1" cols=9>Title</textarea>
</figure>
<div id="social">
<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button" data-size="small"><a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&src=sdkpreparse" class="fb-xfbml-parse-ignore">Share</a></div>
<iframe src="https://www.facebook.com/plugins/share_button.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&layout=button&size=small&width=67&height=20&appId" width="67" height="20" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>
Tweet<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</main>
For this particular example you can do it by adding display: flex; into .container style or white-space: nowrap; into .container and display: inline-block; into figure styles:
/* this */
.container
{
display: flex;
}
/* or this */
/*
.container
{
white-space: nowrap;
}
figure
{
display: inline-block;
}
*/
textarea {
border: none;
overflow: auto;
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
:root {
font-size: 10px;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
sans-serif;
min-height: 100vh;
background-color: #fafafa;
color: #262626;
padding-bottom: 3rem;
}
img {
display: block;
}
.container {
width: 400px;
margin-left: auto;
margin-right: auto;
max-width: 93.5rem;
margin: 0 auto;
padding: 0 2rem;
}
.btn {
display: inline-block;
font: inherit;
background: none;
border: none;
color: inherit;
padding: 0;
cursor: pointer;
}
.btn:focus {
outline: 0.5rem auto #4d90fe;
}
.visually-hidden {
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
clip: rect(1px, 1px, 1px, 1px);
}
/* Profile Section */
.profile {
padding: 5rem 0;
}
.profile::after {
content: "";
display: block;
clear: both;
}
.profile-user-settings,
.profile-stats,
.profile-bio {
float: left;
width: calc(66.666% - 2rem);
}
.profile-user-settings {
margin-top: 1.1rem;
}
.profile-user-name {
display: inline-block;
font-size: 3.2rem;
font-weight: 300;
}
.profile-edit-btn {
font-size: 1.4rem;
line-height: 1.8;
border: 0.1rem solid #dbdbdb;
border-radius: 0.3rem;
padding: 0 2.4rem;
margin-left: 2rem;
}
.profile-stats li {
display: inline-block;
font-size: 1.6rem;
line-height: 1.5;
margin-right: 4rem;
cursor: pointer;
}
.profile-stats li:last-of-type {
margin-right: 0;
}
.profile-real-name,
.profile-stat-count,
.profile-edit-btn {
font-weight: 600;
}
/* Gallery Section */
.gallery {
display: flex;
flex-wrap: wrap;
margin: -1rem -1rem;
padding-bottom: 3rem;
}
.gallery-item {
position: relative;
flex: 1 0 22rem;
margin: 1rem;
color: #fff;
cursor: pointer;
}
.gallery-item:hover .gallery-item-info,
.gallery-item:focus .gallery-item-info {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
}
.gallery-item-info {
display: none;
}
.gallery-item-info li {
display: inline-block;
font-size: 1.7rem;
font-weight: 600;
}
.gallery-item-likes {
margin-right: 2.2rem;
}
.gallery-item-type {
position: absolute;
top: 1rem;
right: 1rem;
font-size: 2.5rem;
text-shadow: 0.2rem 0.2rem 0.2rem rgba(0, 0, 0, 0.1);
}
.fa-clone,
.fa-comment {
transform: rotateY(180deg);
}
.gallery-image {
width: 100%;
height: 100%;
object-fit: cover;
}
/* Media Query */
#media screen and (max-width: 40rem) {
.profile {
display: flex;
flex-wrap: wrap;
padding: 4rem 0;
}
.profile::after {
display: none;
}
.profile-image,
.profile-user-settings,
.profile-bio,
.profile-stats {
float: none;
width: auto;
}
.profile-user-settings {
flex-basis: calc(100% - 10.7rem);
display: flex;
flex-wrap: wrap;
margin-top: 1rem;
}
.profile-user-name {
font-size: 2.2rem;
}
.profile-edit-btn {
order: 1;
padding: 0;
text-align: center;
margin-top: 1rem;
}
.profile-edit-btn {
margin-left: 0;
}
.profile-bio {
font-size: 1.4rem;
margin-top: 1.5rem;
}
.profile-edit-btn,
.profile-bio,
.profile-stats {
flex-basis: 100%;
}
.profile-stats {
order: 1;
margin-top: 1.5rem;
}
.profile-stats ul {
display: flex;
text-align: center;
padding: 1.2rem 0;
border-top: 0.1rem solid #dadada;
border-bottom: 0.1rem solid #dadada;
}
.profile-stats li {
font-size: 1.4rem;
flex: 1;
margin: 0;
}
.profile-stat-count {
display: block;
}
}
/* Spinner Animation */
#keyframes loader {
to {
transform: rotate(360deg);
}
}
/*
The following code will only run if your browser supports CSS grid.
Remove or comment-out the code block below to see how the browser will fall-back to flexbox & floated styling.
*/
#supports (display: grid) {
.profile {
display: grid;
grid-template-columns: 1fr 2fr;
grid-template-rows: repeat(3, auto);
grid-column-gap: 3rem;
align-items: center;
}
.profile-image {
grid-row: 1 / -1;
}
.gallery {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
grid-gap: 2rem;
}
.profile-image,
.profile-user-settings,
.profile-stats,
.profile-bio,
.gallery-item,
.gallery {
width: auto;
margin: 0;
}
#media (max-width: 40rem) {
.profile {
grid-template-columns: auto 1fr;
grid-row-gap: 1.5rem;
}
.profile-image {
grid-row: 1 / 2;
}
.profile-user-settings {
display: grid;
grid-template-columns: auto 1fr;
grid-gap: 1rem;
}
.profile-edit-btn,
.profile-stats,
.profile-bio {
grid-column: 1 / -1;
}
.profile-user-settings,
.profile-edit-btn,
.profile-settings-btn,
.profile-bio,
.profile-stats {
margin: 0;
}
}
}
#import url(https://fonts.googleapis.com/css?family=Raleway:400,200,300,800);
#import url(https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css);
figure.snip0056 {
font-family: 'Raleway', Arial, sans-serif;
position: relative;
overflow: hidden;
margin: 10px;
min-width: 380px;
max-width: 480px;
width: 100%;
background: #ffffff;
color: #000000;
}
figure.snip0056 * {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
figure.snip0056 > img {
width: 50%;
border-radius: 50%;
border: 4px solid #ffffff;
-webkit-transition: all 0.35s ease-in-out;
transition: all 0.35s ease-in-out;
-webkit-transform: scale(1.6);
transform: scale(1.6);
position: relative;
float: right;
right: -15%;
z-index: 1;
}
figure.snip0056 figcaption {
padding: 20px 30px 20px 20px;
position: absolute;
left: 0;
width: 50%;
}
figure.snip0056 figcaption h2,
figure.snip0056 figcaption p {
margin: 0;
text-align: left;
padding: 10px 0;
width: 100%;
}
figure.snip0056 figcaption h2 {
font-size: 1.3em;
font-weight: 300;
text-transform: uppercase;
border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
figure.snip0056 figcaption h2 span {
font-weight: 800;
}
figure.snip0056 figcaption p {
font-size: 0.9em;
opacity: 0.8;
}
figure.snip0056 figcaption .icons {
width: 100%;
text-align: left;
}
figure.snip0056 figcaption .icons i {
font-size: 26px;
padding: 5px;
top: 50%;
color: #000000;
}
figure.snip0056 figcaption a {
opacity: 0.3;
-webkit-transition: opacity 0.35s;
transition: opacity 0.35s;
}
figure.snip0056 figcaption a:hover {
opacity: 0.8;
}
figure.snip0056 .position {
width: 100%;
text-align: left;
padding: 15px 30px;
font-size: 0.9em;
opacity: 1;
font-style: italic;
color: #ffffff;
background: #000000;
clear: both;
}
figure.snip0056.blue .position {
background: #20638f;
}
figure.snip0056.red .position {
background: #962d22;
}
figure.snip0056.yellow .position {
background: #bf6516;
}
figure.snip0056:hover > img,
figure.snip0056.hover > img {
right: -12%;
}
#import url('//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
#social {
position: absolute;
right: 0;
bottom: 0;
margin: 20px 10px;
text-align: center;
}
.smGlobalBtn { /* global button class */
display: inline-block;
position: relative;
cursor: pointer;
width: 50px;
height: 50px;
border:2px solid #ddd; /* add border to the buttons */
box-shadow: 0 3px 3px #999;
padding: 0px;
text-decoration: none;
text-align: center;
color: #fff;
font-size: 25px;
font-weight: normal;
line-height: 2em;
border-radius: 27px;
-moz-border-radius:27px;
-webkit-border-radius:27px;
}
/* facebook button class*/
.facebookBtn{
background: #4060A5;
}
.facebookBtn:before{ /* use :before to add the relevant icons */
font-family: "FontAwesome";
content: "\f09a"; /* add facebook icon */
}
.facebookBtn:hover{
color: #4060A5;
background: #fff;
border-color: #4060A5; /* change the border color on mouse hover */
}
/* twitter button class*/
.twitterBtn{
background: #00ABE3;
}
.twitterBtn:before{
font-family: "FontAwesome";
content: "\f099"; /* add twitter icon */
}
.twitterBtn:hover{
color: #00ABE3;
background: #fff;
border-color: #00ABE3;
}
/* instagram button class*/
.instagramBtn{
background: #4169E1;
}
.instagramBtn:before{
font-family: "FontAwesome";
content: "\f16d"; /* add instagram icon */
}
.instagramBtn:hover{
color: #00FFFF;
background: #fff;
border-color: #4169E1;
}
<div class="container">
<div class="profile">
<form action="testing.php" method="post">
<textarea name="text2" rows="2" cols=0> Family Name</textarea><br>
</form>
<button class="btn profile-edit-btn">Edit Profile</button>
</div>
<!-- End of profile section -->
</div>
<!-- End of container -->
</header>
<main>
<div class="container">
<figure class="snip0056">
<figcaption>
<textarea name="text2" rows="2" cols=0></textarea>
<textarea name="text3" rows="8" cols=20>.</textarea>
</p>
</figcaption><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sq-sample8.jpg" alt="profilepic1" />
<div class="position">
<textarea name="text4" rows="1" cols=9></textarea>
</div>
</h3>
</figure>
<figure class="snip0056 yellow">
<figcaption>
<textarea name="text5" rows="2" cols=0></textarea>
<textarea name="text6" rows="8" cols=20></textarea>
</figcaption><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/331810/sq-sample9.jpg" alt="sample9" />
<div class="position">
<textarea name="text4" rows="1" cols=9>Title</textarea>
</figure>
<div id="social">
<div class="fb-share-button" data-href="https://developers.facebook.com/docs/plugins/" data-layout="button" data-size="small"><a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&src=sdkpreparse" class="fb-xfbml-parse-ignore">Share</a></div>
<iframe src="https://www.facebook.com/plugins/share_button.php?href=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fplugins%2F&layout=button&size=small&width=67&height=20&appId" width="67" height="20" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allow="encrypted-media"></iframe>
Tweet<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
</main>

Grid tile Design

Hi I'm trying to replicate this pen:[1]: https://codepen.io/freeCodeCamp/full/zNBOYG
I've use the grid concept but I'm new to it so Grid Tile/item design is not accurate.
My code is as follows:-
/*Base */
html {
scroll-behavior: smooth;
}
*,
html {
margin: 0;
}
/* Typography*/
li {
font-family: sans-serif;
}
h1,
h2 {
font-family: 'Raleway', sans-serif;
font-weight: 700;
font-size: 3rem;
}
h2 {
font-size: 1.8rem;
}
.welcome-section>p {
font-size: 1.5rem;
font-weight: 200;
}
/* layout */
nav {
text-align: right;
position: sticky;
top: 0;
margin: 0;
}
ul li {
list-style-type: none;
padding: 20px 30px;
height: 100%;
display: inline-block;
}
.welcome-section {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.projects-gird {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
grid-gap: 2rem;
}
.project-tile {
margin-top: 2rem;
border: 1px solid black;
margin-bottom: 0;
}
.project-tile span {
display: none;
}
.project-tile p:hover span {
color: orange;
display: inline;
font-weight: 200;
}
/*Decoration*/
nav {
background-color: #BE3144;
}
li {
color: white;
}
a {
color: white;
text-decoration: none;
font-weight: bold;
}
ul li:hover {
background-color: #5A7384;
}
.welcome-section {
background-color: #000;
}
h1 {
color: white;
}
.welcome-section>p {
color: red;
font-style: italic;
}
.projects-section {
text-align: center;
padding: 4rem 2rem;
background-color: #8878c3;
}
.projects-section-header {
color: white;
border-bottom: 0.2rem solid white;
}
.project-tile p {
background-color: black;
margin-top: 0;
}
img {
margin: 0;
width: 100%;
}
<section id="projects" class="projects-section">
<h2 class="projects-section-header">These are some of my projects</h2>
<div class="projects-grid">
<div class="project-tile">
<a href="#welcome-section"><img src="https://i.postimg.cc/JnPffRyN/project-fiddle.png">
<p>
<span><</span> work1
<span>/></span>
</p>
</a>
</div>
<div class="project-tile">
<a href="#welcome-section"><img src="#">
<p>
<span><</span> work1
<span>/></span>
</p>
</a>
</div>
</div>
</section>
As you can see the result, there is a space between img and p elements and the tile design is also not accurate.Also if I want to fit two tiles in a row what should be the arguments to minmax()function .
please help me with this (Note: margin:0 has no effect)
The reason there's a margin between then img and the p tag is the the img tag is not floated, if you use the following code:
img {
margin: 0;
width: 100%;
float:left;
}
the margin should be gone.
hope this help
I know one way to make it work is to add this, your img was display: inline by default:
.project-tile img {
display: block;
}
/*Base */
html {
scroll-behavior: smooth;
}
*,
html {
margin: 0;
}
/* Typography*/
li {
font-family: sans-serif;
}
h1,
h2 {
font-family: 'Raleway', sans-serif;
font-weight: 700;
font-size: 3rem;
}
h2 {
font-size: 1.8rem;
}
.welcome-section>p {
font-size: 1.5rem;
font-weight: 200;
}
/* layout */
nav {
text-align: right;
position: sticky;
top: 0;
margin: 0;
}
ul li {
list-style-type: none;
padding: 20px 30px;
height: 100%;
display: inline-block;
}
.welcome-section {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.projects-gird {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
grid-gap: 2rem;
}
.project-tile {
margin-top: 2rem;
border: 1px solid black;
margin-bottom: 0;
}
.project-tile img {
display: block;
}
.project-tile span {
display: none;
}
.project-tile p:hover span {
color: orange;
display: inline;
font-weight: 200;
}
/*Decoration*/
nav {
background-color: #BE3144;
}
li {
color: white;
}
a {
color: white;
text-decoration: none;
font-weight: bold;
}
ul li:hover {
background-color: #5A7384;
}
.welcome-section {
background-color: #000;
}
h1 {
color: white;
}
.welcome-section>p {
color: red;
font-style: italic;
}
.projects-section {
text-align: center;
padding: 4rem 2rem;
background-color: #8878c3;
}
.projects-section-header {
color: white;
border-bottom: 0.2rem solid white;
}
.project-tile p {
background-color: black;
margin-top: 0;
}
img {
margin: 0;
width: 100%;
}
<section id="projects" class="projects-section">
<h2 class="projects-section-header">These are some of my projects</h2>
<div class="projects-grid">
<div class="project-tile">
<a href="#welcome-section"><img src="https://i.postimg.cc/JnPffRyN/project-fiddle.png">
<p>
<span><</span> work1
<span>/></span>
</p>
</a>
</div>
<div class="project-tile">
<a href="#welcome-section"><img src="#">
<p>
<span><</span> work1
<span>/></span>
</p>
</a>
</div>
</div>
</section>

Why are my css grid items overlapping when arranged in a particular layout?

I am a noob trying to learn css grid layout. I'm trying to create a grid-layout using grid-template-areas.
However,the items keep overlapping because I have to explicitly specify the height of the map item. As soon I change it to auto, the map disappears.
To complicate matter, I am using nested grids but its the map content that's the culprit, I have also tried to arrange my grid in 3x1 grid in the mobile display. However, my map keeps overshooting its boundaries. I tried to remedy that by using grid-template-rows, but the final results still dont look good.
I am lost at this and would appreciate a little help in the right direction.
#maincontent {
background-color: #f3f3f3;
min-height: 100%;
height: auto;
width: 100%;
max-width: 100%;
overflow-x: hidden;
overflow-y: hidden;
position: relative;
}
#footer {
background-color: #444;
color: #aaa;
font-size: 8pt;
letter-spacing: 1px;
padding: 25px;
text-align: center;
text-transform: uppercase;
width: auto;
/*width: calc(50% - 80px);*/
}
/* ====================== Map ====================== */
#map {
height: 300px;
width: 100%;
background-color: #ccc;
}
#map-container {
grid-area: content;
}
/* ====================== Restaurant Filtering ====================== */
.filter-options {
display: grid;
width: 100%;
height: 50px;
background-color: #3397DB;
align-items: center;
grid-template-areas: "select1 select2";
}
.filter-options h2 {
color: white;
font-size: 1rem;
font-weight: normal;
line-height: 1;
margin: 0 20px;
}
.filter-options select {
background-color: white;
border: 1px solid #fff;
font-family: Arial, sans-serif;
font-size: 11pt;
height: 35px;
letter-spacing: 0;
margin: 10px;
padding: 0 10px;
width: 200px;
}
/* ====================== Restaurant Listing ====================== */
#restaurants-list {
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 10px;
grid-auto-flow: row;
grid-area: auto;
background-color: #f3f3f3;
list-style: outside none none;
margin: 0;
padding: 30px 15px 60px;
text-align: center;
}
#restaurants-list li {
background-color: #fff;
border: 2px solid #ccc;
font-family: Arial, sans-serif;
margin: 15px;
min-height: 380px;
padding: 0 30px 25px;
text-align: left;
width: 270px;
}
#restaurants-list .restaurant-img {
background-color: #ccc;
display: block;
margin: 0;
max-width: 100%;
min-height: 248px;
min-width: 100%;
}
#restaurants-list li h1 {
color: #f18200;
font-family: Arial, sans-serif;
font-size: 14pt;
font-weight: 200;
letter-spacing: 0;
line-height: 1.3;
margin: 20px 0 10px;
text-transform: uppercase;
}
#restaurants-list p {
margin: 0;
font-size: 11pt;
}
#restaurants-list li a {
background-color: orange;
border-bottom: 3px solid #eee;
color: #fff;
display: inline-block;
font-size: 10pt;
margin: 15px 0 0;
padding: 8px 30px 10px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
}
#neighborhoods-select {
grid-area: select1;
}
#cuisines-select {
grid-area: select2;
}
/* ====================== Restaurant Details ====================== */
.inside {
width: 100%;
}
.wrapper {
display: grid;
width: 100%;
grid-template-columns: 1fr;
grid-template-areas: "restaurantHeader" "mainRestaurantContent" "restaurantFooter";
justify-content: space-evenly;
}
.restaurant-header {
grid-area: restaurantHeader;
position: fixed;
top: 0;
width: 100%;
z-index: 1000;
}
#footer.restaurant-footer {
grid-area: restaurantFooter;
bottom: 0;
position: absolute;
width: 100%;
}
.restaurant-header {
top: 0;
width: 100%;
z-index: 1000;
}
.inside #map {
background-color: #ccc;
height: 100%;
width: 100%;
}
#map-container.map-container-class {
grid-area: restaurantMap;
height: auto;
position: fixed;
right: 0;
top: 125px;
width: 50%;
z-index: 999;
overflow: hidden;
}
#restaurant-name {
color: #f18200;
font-family: Arial, sans-serif;
font-size: 20pt;
font-weight: 200;
letter-spacing: 0;
text-transform: uppercase;
line-height: 1.1;
}
#restaurant-name-div {
grid-area: restaurantName;
text-align: center;
}
#restaurant-img {
display: block;
margin-left: auto;
margin-right: auto;
max-width: 100%;
min-width: 100%;
width: 100%;
height: auto;
}
#restaurant-img-div {
grid-area: restaurantImage;
width: 100%;
height: 100%;
overflow: hidden;
border: 10px solid geen;
border-radius: 5px;
}
#restaurant-address {
grid-area: address;
font-size: 12pt;
text-align: center;
align-self: center;
}
#restaurant-cuisine {
grid-area: cuisine;
background-color: #333;
color: #ddd;
font-size: 12pt;
font-weight: 300;
letter-spacing: 10px;
margin: 0 0 20px;
padding: 2px 0;
text-align: center;
text-transform: uppercase;
font-weight: bold;
width: auto;
}
#restaurant-container,
#reviews-container {
border-bottom: 1px solid #d9d9d9;
border-top: 1px solid #fff;
padding: 140px 40px 30px;
width: auto;
}
#restaurant-container {
grid-area: restaurantContainer;
position: relative;
}
#restaurant-container {
display: grid;
grid-template-columns: 1fr;
grid-template-areas: "restaurantName" "restaurantImage" "cuisine" "address" "hours";
justify-content: center;
height: auto;
}
#reviews-container-div {
grid-area: reviewsContainer;
}
#reviews-container {
padding: 30px 40px 80px;
}
#reviews-container h2 {
color: #f58500;
font-size: 24pt;
font-weight: 300;
letter-spacing: -1px;
padding-bottom: 1pt;
}
#reviews-list {
margin: 0;
padding: 0;
}
#reviews-list li {
background-color: #fff;
border: 2px solid #f3f3f3;
display: block;
list-style-type: none;
margin: 0 0 30px;
overflow: hidden;
padding: 0 20px 20px;
position: relative;
width: 85%;
}
#reviews-list li p {
margin: 0 0 10px;
}
#restaurant-hours-div {
grid-area: hours;
position: relative;
border-radius: 5px;
}
#restaurant-hours {
table-layout: auto;
width: 100%;
}
#restaurant-hours td {
color: #666;
text-align: center;
resize: both;
overflow: auto;
}
#maincontent.restaurantMainContent {
grid-area: mainRestaurantContent;
width: 100%;
height: auto;
position: relative;
}
#maincontent.restaurantMainContent {
display: inline-grid;
width: 100%;
grid-template-columns: 1fr 1fr;
grid-template-areas: "restaurantContainer restaurantMap" "reviewsContainer restaurantMap";
justify-content: space-evenly;
}
#media (min-width: 320px) and (max-width: 480px) {
#displayTag {
font-size: 1em !important;
}
#index-body {
grid-template-columns: 1fr;
grid-template-areas: "header " "content" "footer ";
}
#restaurants-list {
grid-template-columns: 1fr;
justify-content: center;
padding-left: 0;
}
.filter-options {
grid-template-columns: 1fr 1fr;
grid-template-areas: "select1 select2";
justify-content: start;
}
.filter-options select {
width: 150px;
}
#map-container.map-container-class {
height: 50%;
position: fixed;
left: 0;
top: 10px;
width: auto;
}
#restaurantContainer {
position: relative;
top: 150px;
left: 0px;
right: 0px;
bottom: 0px;
grid-row-start: 2;
}
#maincontent.restaurantMainContent {
grid-template-columns: 1fr;
grid-template-areas: "restaurantMap" "restaurantContainer" "reviewsContainer";
clear: both;
}
}
<!-- language: lang-html -->
<body class="inside">
<div class="wrapper">
<!-- Beginning header -->
<header class="restaurant-header">
<!-- Beginning nav -->
<nav>
<h1>Restaurant Reviews</h1>
</nav>
<!-- Beginning breadcrumb -->
<ul id="breadcrumb">
<li>Home</li>
</ul>
<!-- End breadcrumb -->
<!-- End nav -->
</header>
<!-- End header -->
<!-- Beginning main -->
<div id="maincontent" class="restaurantMainContent">
<!-- Beginning map -->
<section id="map-container" class="map-container-class">
<div id="map"></div>
</section>
<!-- End map -->
<!-- Beginning restaurant -->
<div id="restaurant-container">
<div id="restaurant-name-div"> <p><h1 id="restaurant-name"></h1></div>
<div id="restaurant-img-div"><img id="restaurant-img" alt="Image of the restaurant selected"></div>
<div id="restaurant-cuisine"></div>
<div id="restaurant-address"></div>
<div id="restaurant-hours-div">
<table id="restaurant-hours"></table>
</div>
</div>
<!-- end restaurant -->
<!-- Beginning reviews -->
<div id="reviews-container-div">
<section id="reviews-container">
<ul id="reviews-list"></ul>
</section>
</div>
<!-- End reviews -->
</div>
<!-- End main -->
<!-- Beginning footer -->
<footer id="footer" class="restaurant-footer">
Copyright (c) 2017 <strong>Restaurant Reviews</strong> All Rights Reserved.
</footer>
</div>
I figured out the solution, I added grid-auto-rows: minmax(300px, auto) to the grid that holds my map, restaurant and reviews containers. Worked like a charm!

Reducing Gap in CSS Grid UL/LI

I am having some issues reducing the space on my footer using CSS grid. I've gotten to the point where my list items are on one line but I cannot find a way to reduce the gap in between. This may be because of my centering of it but I cannot figure it out after googling/playing.
https://codepen.io/DanielPeterHill/pen/pxjpzM
html,
body {
width: 100%;
height: 100%;
margin: 0;
}
body {
font-family: 'Oswald', sans-serif;
color: #FEDCD2;
}
.nav-container {
width: 100%;
background: #DF744A;
margin: 0;
}
nav {
max-width: 1720px;
margin: 0 auto;
display: grid;
grid-template-columns: 1fr auto 1fr;
}
.left-menu {
grid-column: 1;
align-self: center;
}
.logo {
grid-column: 2;
}
#nav-toggle,
.burger-menu {
display: none;
}
nav a {
color: white;
text-decoration: none;
text-transform: uppercase;
transition: .3s all ease-in-out;
}
nav a:hover {
opacity: .7;
color: blue;
}
.left-menu a {
padding: 10px 0;
margin-left: 15px;
font-size: 14px;
font-weight: 300;
letter-spacing: 0.5px;
}
.logo {
font-size: 40px;
padding: 1rem;
}
.burger-menu {
grid-column: 1;
align-self: center;
margin-left: 20px;
}
.footer {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: #DF744A;
color: white;
text-align: center;
}
footer {
display: grid;
grid-template-rows: auto 3fr auto;
}
.footer-left {
grid-column: 1;
align-self: center;
}
.footer-right {
grid-column: 3;
align-self: center;
list-style-type: none;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-row-gap: 50px;
}
.footer-right li {
text-decoration: none;
}
.footer-right li a {
color: white;
}
.footer-right li a:hover {
opacity: .7;
color: blue;
}
.underlineremove {
text-decoration: none;
text-decoration-style: none;
}
#media only screen and (max-width: 1025px) {
.burger-menu {
display: inline-block;
width: 40px;
}
.left-menu {
display: none;
}
#nav-toggle:checked~.left-menu {
display: grid;
grid-row: 2;
}
}
<link href="https://fonts.googleapis.com/css?family=Oswald:600" rel="stylesheet">
<div class="nav-container">
<nav>
<input type="checkbox" id="nav-toggle">
<label for="nav-toggle" class="burger-menu">
<img src="images/hamburger.png" alt="">
</label>
<div class="left-menu">
Shop
Blog
About
Contact
</div>
Dill's Delight's
</nav>
</div>
<div class="footer">
<footer>
<p class="footer-left"> © FarHill Deisgns </p>
<ul class="footer-right">
<li>TEST</li>
<li>TEST</li>
<li>TEST</li>
<li>TEST</li>
</ul>
</footer>
</div>
My example is above and any help would be amazing! My outcome would be to be able to reduce the gap beween the 4 TESTS in the bottom right to make it look a bit cleaner.
Thank you,
Dan
You can try this:
.footer-right
{
grid-column: 3;
align-self: center;
list-style-type: none;
display: grid;
grid-template-columns: repeat(4, 50px);
grid-row-gap: 50px;
}
I changed grid template columns to this grid-template-columns: repeat(4, 50px); to give to the columns 50px width. But, if this does not suite you, you can always use some other width in % or in some other measure.
One option...don't use CSS-Grid at all on the footer. Flexbox would be simpler.
html,
body {
width: 100%;
height: 100%;
margin: 0;
}
body {
font-family: 'Oswald', sans-serif;
color: #FEDCD2;
}
.footer {
/* not required for demo
position: fixed;
left: 0;
bottom: 0;
width: 100%;
*/
background-color: #DF744A;
color: white;
text-align: center;
}
footer {
display: flex;
}
.footer-left {
grid-column: 1;
align-self: center;
}
.footer-right {
margin-left: auto;
list-style-type: none;
display: flex;
}
.footer-right li {
text-decoration: none;
margin: .25em;
/* manages spacing */
}
.footer-right li a {
color: white;
}
.footer-right li a:hover {
opacity: .7;
color: blue;
}
.underlineremove {
text-decoration: none;
text-decoration-style: none;
}
<div class="footer">
<footer>
<p class="footer-left"> © FarHill Deisgns </p>
<ul class="footer-right">
<li>TEST</li>
<li>TEST</li>
<li>TEST</li>
<li>TEST</li>
</ul>
</footer>
</div>
Alternatively, if you must use CSS-Grid, then consider a two column grid and flex the ul...
footer {
display: grid;
grid-template-columns:1fr auto;
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
}
body {
font-family: 'Oswald', sans-serif;
color: #FEDCD2;
}
.footer {
/* not required for demo
position: fixed;
left: 0;
bottom: 0;
width: 100%;
*/
background-color: #DF744A;
color: white;
text-align: center;
}
footer {
display: grid;
grid-template-columns: 1fr auto;
}
.footer-left {
grid-column: 1;
align-self: center;
}
.footer-right {
margin-left: auto;
list-style-type: none;
display: flex;
}
.footer-right li {
text-decoration: none;
margin: .25em;
}
.footer-right li a {
color: white;
}
.footer-right li a:hover {
opacity: .7;
color: blue;
}
.underlineremove {
text-decoration: none;
text-decoration-style: none;
}
<div class="footer">
<footer>
<p class="footer-left"> © FarHill Deisgns </p>
<ul class="footer-right">
<li>TEST</li>
<li>TEST</li>
<li>TEST</li>
<li>TEST</li>
</ul>
</footer>
</div>

Altering a flexbox layout to display block format

I have a section in which is displaying via a flex box. This works great, but when the viewport gets to a 640px or less size, I want to be able to make all three section be shown in a display: block fashion with a width of 100%. I tried changing the #contact-section to display: block, but it went completely out of the format I have with flex.
I am wanting it to appear like this under 640px's.
Does anyone know how I can do it without losing the flex format, or at least making it work in this viewport?
Here is a fiddle which will allow the sections to be seen in a 640 or less viewport.
#contact-section {
display: flex;
justify-content: space-around;
align-items: center;
color: #FFF;
background: #00a16d;
padding: 1em;
}
#contact-section:before {
content: "";
flex: 0 0 1px;
height: 3em;
background: #FFF;
order: 2;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
font-style: italic;
}
#contact-section-right {
background: url("../icons/envelope.png") center / contain no-repeat;
font-size: 2em;
order: 3;
padding: 1em 0;
}
#contact-section-right a {
color: #FFF;
text-decoration: none;
}
/*--------------------------MEDIA QUERY 640------------------------------------*/
#media screen and (max-width:640px) {
#contact-section {
display: flex;
justify-content: space-around;
align-items: center;
padding: 1em 2em;
}
#contact-section:before {
flex: 0 0 1px;
height: 3em;
order: 2;
display: block;
width: 100%;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
display: block;
width: 100%;
}
#contact-section-right {
font-size: 2em;
order: 3;
padding: 1em 0;
display: block;
width: 100%;
}
}
<div id="contact-section">
<div id="contact-section-left">Tell us more about your digital marketing project.</div>
<div id="contact-section-right">Contact us</div>
</div>
I have changed the direction to column, seems that now it works
#contact-section {
display: flex;
justify-content: space-around;
align-items: center;
color: #FFF;
background: #00a16d;
padding: 1em;
}
#contact-section:before {
content: "";
flex: 0 0 1px;
height: 3em;
background: #FFF;
order: 2;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
font-style: italic;
}
#contact-section-right {
background: url("../icons/envelope.png") center / contain no-repeat;
font-size: 2em;
order: 3;
padding: 1em 0;
}
#contact-section-right a {
color: #FFF;
text-decoration: none;
}
/*--------------------------MEDIA QUERY 640------------------------------------*/
#media screen and (max-width: 640px) {
#contact-section {
display: flex;
flex-direction: column;
justify-content: space-around;
align-items: center;
padding: 1em 2em;
}
#contact-section:before {
flex: 0 0 10px;
order: 2;
display: block;
width: 100%;
background-color: red;
}
#contact-section-left {
font-size: 1.5em;
order: 1;
display: block;
width: 100%;
}
#contact-section-right {
font-size: 2em;
order: 3;
padding: 1em 0;
display: block;
width: 100%;
text-align: center;
}
}
<div id="contact-section">
<div id="contact-section-left">Tell us more about your digital marketing project.</div>
<div id="contact-section-right">Contact us
</div>
</div>
You could use min-width instead mediaqueries and flex-wrap:wrap and eventually border(s) on the first element to drop the pseudo ::before. See Fiddle test 1 & Fiddle test 2 .
#contact-section {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
color: #FFF;
background: #00a16d;
}
#contact-section:before {} #contact-section-left {
font-size: 1.5em;
font-style: italic;
min-width: 320px;
border-top: 1em solid transparent;
border-bottom: 1em solid transparent;
border-right: 1px solid white;
padding: 1em;
flex: 1;
}
#contact-section-right {
background: url("../icons/envelope.png") center / contain no-repeat;
font-size: 2em;
padding: 1em;
flex: 1;
min-width: 320px;
}
#contact-section-right a {
color: #FFF;
text-decoration: none;
}
<div id="contact-section">
<div id="contact-section-left">Tell us more about your digital marketing project.</div>
<div id="contact-section-right">Contact us
</div>
</div>
edit
if you still want to use a pseudo of 3em height, then you can draw it from the first box https://jsfiddle.net/mq41hgkp/3/