Why are my div elements not growing properly? - html

I tried to put the elements of social networks together and when I hover the mouse over each element it grows to a size of 200 pixels. I wrote all the code, but when the mouse is placed on the element, the element does not grow properly and looks like an ellipse. Is there anyone who can help me with this?
<style>
:root {
--color-orange: #ff6600;
--color-green: #22d122;
--color-cyan: #33ffff;
--color-magenta: #f33192;
--color-white: #ffffff;
--color-blue: #166fd4;
--color-magenta-dark:#831a4e;
--color-gray:#d6d6d6;
--color-red:#ff0000;
--color-graydark:#333;
--color-blue-dark:#103d68;
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: "Nunito", sans-serif;
}
.wrapper {
display: grid;
grid-template-columns: repeat(4, auto);
place-content: center;
width: 100%;
height: 100vh;
background-color: var(--color-gray);
}
.button {
display: inline-block;
background-color: var(--color-white);
width: 60px;
height: 60px;
overflow: hidden;
box-shadow: 0 10px 10px rgba(0,0,0,0.1);
transition: all 0.3s ease-out;
border-radius: 50%;
margin: 0 5px;
cursor: pointer;
}
.button:hover {
width: 200px;
}
.button .icon {
display: inline-block;
text-align: center;
font-size: 20px;
border-radius: 50%;
height: 60px;
width: 60px;
line-height: 60px;
transition: all 0.3s ease-out;
}
.button:hover .icon i {
color: var(--color-white);
}
.button:nth-child(1):hover .icon {
background-color: var(--color-blue-dark);
}
.button:nth-child(2):hover .icon {
background-color: var(--color-blue);
}
.button:nth-child(3):hover .icon {
background-color: var(--color-magenta);
}
.button:nth-child(4):hover .icon {
background-color: var(--color-red);
}
.button span {
font-size: 20px;
font-weight: bold;
margin-left: 10px;
}
.button:nth-child(1) span {
color: var(--color-blue-dark);
}
.button:nth-child(2) span {
color: var(--color-blue);
}
.button:nth-child(3) span {
color: var(--color-magenta);
}
.button:nth-child(4) span {
color: var(--color-red);
}
</style>
<div class="wrapper">
<div class="button">
<div class="icon">
<i class="fab fa-facebook-f"></i>
</div>
<span>Facebook</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-twitter"></i>
</div>
<span>Twitter</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-instagram"></i>
</div>
<span>Instagram</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-youtube"></i>
</div>
<span>Youtube</span>
</div>
</div>

Change the value of your border-radius on .button:hover
:root {
--color-orange: #ff6600;
--color-green: #22d122;
--color-cyan: #33ffff;
--color-magenta: #f33192;
--color-white: #ffffff;
--color-blue: #166fd4;
--color-magenta-dark: #831a4e;
--color-gray: #d6d6d6;
--color-red: #ff0000;
--color-graydark: #333;
--color-blue-dark: #103d68;
}
* {
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: "Nunito", sans-serif;
}
.wrapper {
display: grid;
grid-template-columns: repeat(4, auto);
place-content: center;
width: 100%;
height: 100vh;
background-color: var(--color-gray);
}
.button {
display: inline-block;
background-color: var(--color-white);
width: 60px;
height: 60px;
overflow: hidden;
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease-out;
border-radius: 50%;
margin: 0 5px;
cursor: pointer;
}
.button:hover {
width: 200px;
border-radius: 50px;
}
.button .icon {
display: inline-block;
text-align: center;
font-size: 20px;
border-radius: 50%;
height: 60px;
width: 60px;
line-height: 60px;
transition: all 0.3s ease-out;
}
.button:hover .icon i {
color: var(--color-white);
}
.button:nth-child(1):hover .icon {
background-color: var(--color-blue-dark);
}
.button:nth-child(2):hover .icon {
background-color: var(--color-blue);
}
.button:nth-child(3):hover .icon {
background-color: var(--color-magenta);
}
.button:nth-child(4):hover .icon {
background-color: var(--color-red);
}
.button span {
font-size: 20px;
font-weight: bold;
margin-left: 10px;
}
.button:nth-child(1) span {
color: var(--color-blue-dark);
}
.button:nth-child(2) span {
color: var(--color-blue);
}
.button:nth-child(3) span {
color: var(--color-magenta);
}
.button:nth-child(4) span {
color: var(--color-red);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.0/css/all.min.css">
<div class="wrapper">
<div class="button">
<div class="icon">
<i class="fab fa-facebook-f"></i>
</div>
<span>Facebook</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-twitter"></i>
</div>
<span>Twitter</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-instagram"></i>
</div>
<span>Instagram</span>
</div>
<div class="button">
<div class="icon">
<i class="fab fa-youtube"></i>
</div>
<span>Youtube</span>
</div>
</div>

You also need to change height on hover.
.button:hover {
width: 200px;
height: 200px;
border-radius: 50px;
}
But I recommend you to use transform: scale(2) if you aiming for performance.

when you hover the button its height increases and the width
.button:hover{
transform:scale(1.015deg)
}

Related

body content goes of out of container

I am trying to create a responsive layout and hence faced an issue. Issue is that body content exceeds the the layout on minimizing below 250px; however i know below 320px it doesn't matter if it loses responsivity still it looks unprofessional. i hope experts will help me in this regard.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/NjMWV.png
function toggleMobileMenu(menu){
menu.classList.toggle('open');
}
function toggleSidebar(menu){
menu.classList.toggle('open');
}
html{
height: 100%;
box-sizing: border-box;
}
*,*:after,*:before{
box-sizing: inherit;
}
body{
position: relative;
min-height: 100%;
min-width: 100%;
box-sizing: border-box;
margin: 0;
padding-bottom:12rem;
font-family: 'Roboto', sans-serif !important;
background: #f2f2f2;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.body-content{
padding-bottom: 0.5rem;
width: 100%;
}
/*Main ends here*/
/*Global*/
h2{
color: #007bff;
font-size: 20px;
}
li,a{
list-style: none;
text-decoration: none;
}
.button{
padding: 9px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
color: #fff;
}
/*Global*/
header{
padding:0 20px;
background: #007991; /* fallback for old browsers */
background: -webkit-linear-gradient(to left, #78ffd6, #007991); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #78ffd6, #007991); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
-webkit-box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.75);
height: 50px;
width: 100%;
min-width: 100%;
display:flex;
justify-content:space-between;
z-index: 1001;
position: -moz-sticky;
position: -webkit-sticky;
position: sticky;
top: 0;
}
.logo{
width: 30px;
height: 30px;
justify-self: start;
margin: 10px 20px;
cursor: pointer;
}
header nav {
overflow: hidden;
margin-right: auto;
}
header nav ul{
list-style: none;
}
header nav ul li{
display: inline-block;
padding-left: 20px;
}
.active a{
color: #fff;
}
header nav ul li:hover{
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
header nav ul li a{
color: #f2f3f5;
padding: 10px;
text-decoration: none;
font-weight:400 !important;
}
header nav ul li a:hover{
color: #fff;
font-weight: 400 !important;
}
.access{
margin: 9px;
list-style: none;
display: block;
position: relative;
z-index: 100;
}
.access button{
padding: 9px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
color: #fff;
}
.access button:hover{
background: rgba(0, 136, 169, 0.8);
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
.access li{
list-style: none;
cursor: pointer;
}
.access li a{
text-decoration: none;
}
.access li ul{
background-color: rgba(0, 136, 169, 1);
display: none; /*submenu dissappears when set to none*/
text-align: center;
padding: 10px 25px;
margin-top: 8px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
.access li:hover ul{
display : block;
}
.access-menu li a{
color: #fff !important;
font-weight: 400!important;
}
.access-menu.reveal{
display: block;
}
.access li ul li{
padding: 5px;
color: #fff;
display: block;
font-weight:500;
}
.access li ul li:hover{
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
/*mobile-menu*/
#hamburger-icon{
margin: auto 0;
display: none;
cursor: grab;
background: rgba(0, 136, 169, 1);
border-radius: 5px;
padding: 3px 10px;
}
#hamburger-icon div{
width: 25px;
height:3px;
background-color: #fff;
margin: 5px 0;
transition: all 0.3s ease 0s;
}
.open .bar1{
-webkit-transform: rotate(-45deg) translate(-6px, 5px);
transform: rotate(-45deg) translate(-6px, 5px);
}
.open .bar2{
opacity: 0;
}
.open .bar3{
-webkit-transform: rotate(45deg) translate(-6px,-6px);
transform: rotate(45deg) translate(-6px,-6px);
}
.open .mobile-menu{
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
position: absolute;
}
.mobile-menu{
display: none;
position: fixed;
top: 24px;
left: 0;
width: 100%;
height: calc(100vh - 50px);
overflow: hidden;
height: auto;
text-align: center;
background: #007991; /* fallback for old browsers */
background: -webkit-linear-gradient(to left, #78ffd6, #007991); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #78ffd6, #007991); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
color: #fff;
z-index:100;
}
.mobile-menu li{
padding : 10px;
font-weight: 400 !important;
}
.mobile-menu li a{
color: #fff;
}
.mobile-menu li:hover{
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
#media(max-width: 768px){
header{
height: 40px;
}
.logo{
height: 25px;
width: 25px;
margin: 8px 10px;
}
header nav,header .access{
display: none;
}
#hamburger-icon{
display: block;
padding: 2px 7px;
margin-right: 5px;
}
#hamburger-icon div{
width: 20px;
height:3px;
}
.mobile-menu li{
margin-right: 15px;
}
}
media(min-width: 769px) and (max-width: 1020px){
.logo{
margin: 10px;
}
nav ul li{
padding-left: 10px;
font-size: 16px;
}
nav ul li a{
padding: 5px;
}
}
#media(min-width: 250px) and (max-width: 281px){
.logo{
margin-left: -10px;
}
#hamburger-icon{
margin-right: -10px;
}
}
#media(min-width: 282px) and (max-width: 320px){
.logo{
margin-left: -10px;
}
#hamburger-icon{
margin-right: -10px;
}
}
/*Card*/
.card{
min-width: 15rem;
flex: 1;
-webkit-box-flex: 1;
-ms-flex: 1;
height: 100%;
width: 100%;
border: 1px solid #ccc;
background: #fff;
font-weight: 300 !important;
position: relative;
}
.card .category{
position: absolute;
top: -10px;
left: 0;
background: #FF7F50;
color: #fff;
font-weight: 300 !important;
padding: 5px 9px;
font-size: 10px;
text-transform: uppercase;
}
.card .flag{
top:0;
right: -15px;
position: absolute;
}
.card .flag button{
position: absolute;
top: -10px;
right: 0;
background: 0;
color: #fff;
font-size: 20px;
}
.flag #report{
display:none;
float: left;
padding:0;
margin-top: 22px;
margin-right: 22px;
background: #fff;
color: #007bff;
}
#report p{
padding: 2px 5px;
top:-10px;
font-size:10px;
line-height:0.1rem;
cursor:pointer;
}
.card img{
flex-wrap: wrap;
pointer-events: none;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
width: 100%;
float: none;
display:block;z
object-fit: fill;
height: 180px;
}
.card-panel{
display: flex;
align-items: center;
justify-content: center;
margin-top: -10px;
}
.card-panel .icon{
cursor: pointer;
display: flex;
/*flex-direction: row;*/
align-items: center;
justify-content: center;
position: relative;
z-index: 1;
}
.card-panel .icon img{
height: 60px;
width: 60px;
border: 5px solid #FFF;
border-radius: 50%;
background-color: #007bff;
text-align: center;
color: #fff;
margin: -25px 10px 0 10px;
pointer-events: none;
cursor: pointer;
}
.card-panel .icon i{
font-size: 15px;
line-height: 30px;
height: 40px;
width: 40px;
border: 5px solid #fff;
border-radius: 50%;
background-color: #007bff;
text-align: center;
color: #fff;
margin: -20px 5px 0 5px;
}
.card-panel .icon .tooltip,
.card-panel .icon .tooltip1{
text-align: center;
position: absolute;
top: 0;
background: #fff;
color: #007bff;
font-size: 10px;
padding: 10px 10px;
border-radius: 25px;
box-shadow: 0 10px 10px rgba(0,0,0,0.1);
opacity: 0;
pointer-events: none;
z-index: 1;
transition: all 0.2s cubic-bezier(0.68,-0.55,0.265,1.55);
}
.card-panel .icon .tooltip:before,
.card-panel .icon .tooltip1:before{
position: absolute;
content: "";
height: 7px;
width: 7px;
background:#fff;
bottom: -3px;
left: 50%;
transform: translate(-50%) rotate(45deg);
transition: all 0.2s cubic-bezier(0.68,-0.55,0.265,1.55);
}
.card-panel .icon:hover .tooltip,
.card-panel .icon:focus .tooltip{
position: absolute;
top: -60px;
opacity: 1;
pointer-events: auto;
}
.card-panel .icon:hover .tooltip1,
.card-panel .icon:focus .tooltip1{
top: -92px;
opacity: 1;
pointer-events: auto;
text-align: center;
}
.card-panel .icon:hover i,
.card-panel .icon:active i,
.card-panel .icon:hover .tooltip,
.card-panel .icon:focus .tooltip,
.card-panel .icon .tooltip1:before{
text-shadow: 0px -1px 0px rgba(0,0,0,0.4);
}
.card-panel .tooltip1 i{
font-size: 8px;
line-height:13px;
height: 20px;
width: 20px;
border: 3px solid #fff;
border-radius: 50%;
background-color: #007bff;
text-align: center;
color: #fff;
margin: -20px 5px 0 5px;
}
.card .text {
padding: 10px 10px;
}
.card .text h3{
margin-top: 0;
text-align: justify;
text-justify: inter-word;
font-weight: 500 !important;
}
.card button{
background-color: #007bff;
border-radius: 10px;
color:#fff;
padding: 10px 20px;
border: none;
cursor: pointer;
position: relative;
margin: 0 auto;
display: block;
}
.card button:hover{
opacity: 0.8;
}
.card .see-more{
top: 40%;
text-align: center;
position: relative;
}
.card .see-more i{
font-size: 60px;
color:#007bff;
}
.container-a,
.container-b{
margin:10px auto;
padding:0;
width: calc(100% - 100px);
position:relative;
}
.wrapper{
height:100%;
display:grid;
grid-template-columns:repeat(5, 1fr);
grid-template-areas: "blog-container blog-container blog-container blog-container blog-sidebar";
grid-gap:10px;
}
.wrapper .blog-container{
grid-area: blog-container;
}
.wrapper .blog-sidebar{
grid-area: blog-sidebar;
}
.wrapper .blog-container span,
.wrapper .blog-sidebar span{
background-color: #007bff;
padding: 5px 10px;
position:relative;
color: #fff;
z-index: -1;
background-blend-mode: multiply;
font-family: 'Roboto', sans-serif !important;
}
.blog-container hr,
.blog-sidebar hr{
width: 100%;
color:#007bff;
margin-top: 3.5px;
position: relative;
z-index: -2;
}
.blog-container .blog-cards{
display: grid;
grid-template-columns: repeat(auto-fill, minmax(270px,1fr));
grid-gap: 10px;
}
.widgets{
background: #fff;
border: 1px solid #ccc;
margin-bottom: 10px;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(270px,1fr));
grid-gap: 10px;
padding: 5px;
}
.widgets img{
width: 100%;
float: none;
display:block;
object-fit: fill;
}
.container-a .widgets,.container-b .widgets{
margin-bottom: 10px;
}
.load-more{
text-align: center;
grid-column: 1/-1;
margin-bottom: 10px;
}
.load-more button{
padding: 9px 150px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
color: #fff;
font-size: 13px;
}
.load-more button:hover{
background: rgba(0, 136, 169, 0.8);
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
/*--MEDIA QUERIES--*/
#media(max-width: 768px){
.carousel{
width: calc(100% - 60px);
margin: 10px auto;
}
.carousel span,
.wrapper .blog-container span,
.wrapper .blog-sidebar span{
font-size: 12px;
}
.carousel hr{
margin-top: 3px;
}
.horizontal-scroll .btn-scroll{
padding: 0 5px;
font-size: 30px;
}
.horizontal-scroll #btn-scroll-left{
top: calc(430px/2);
}
.horizontal-scroll #btn-scroll-right{
top: calc(430px/2);
}
.container-a,
.container-b{
width: 99%;
padding: 5px;
}
.wrapper{
grid-template-rows: auto;
grid-template-columns: 1fr;
grid-template-areas: "blog-container"
"blog-sidebar";
}
.card{
min-width: 14.8rem;
}
.card .category{
font-size: 8px;
padding: 4px 7px;
top: -8px;
}
.card img{
height: 150px;
}
.card .flag{
right: -7px;0
}
.card .flag button{
font-size: 15px;
top: -5px;
}
.flag #report{
margin-top: 17px;
margin-right: 12px;
}
#report p{
padding: 1px 4px;
font-size:9px;
}
.card-panel .icon i{
font-size: 10px;
line-height: 22px;
height: 30px;
width: 30px;
margin: -12px 4px 0 4px;
border: 4px solid #FFF;
}
.card-panel .icon img{
width: 50px;
height: 50px;
border: 4px solid #FFF;
margin: -20px 10px 0 10px;
}
.card-panel .icon .tooltip,
.card-panel .icon .tooltip1{
padding: 8px 8px;
font-size: 8px;
}
.card-panel .icon .tooltip:before,
.card-panel .icon .tooltip1:before{
width: 5px;
height: 5px;
bottom: -2px;
}
.card-panel .icon:hover .tooltip{
top: -45px;
}
.card-panel .icon:hover .tooltip1{
top: -75px;
}
.card-panel .tooltip1 i{
font-size: 8px;
line-height:14px;
height: 18px;
width: 18px;
border: 2px solid #fff;
}
.card .text h3{
font-size: 15px;
}
.card button{
padding: 5px 10px;
font-size: 12px;
}
.widgets{
grid-template-columns: repeat(auto-fill, minmax(244px,1fr));
}
.card .see-more{
top: 40%;
}
.card .see-more i{
font-size: 50px;
}
.load-more button{
padding: 5px 30px;
font-size: 12px;
}
}
#media(max-width: 281px) {
.wrapper .blog-container {
padding-right: 0;
}
.blog-container .blog-cards {
grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
}
.widgets {
grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
}
}
<section class="body-content">
<header>
<img src="img/Logo.jpg" class="logo" alt="Logo">
<nav>
<ul>
<li class="active"><i class="fas fa-home"></i> Home</li>
<li><i class="fas fa-pen-nib"></i> Blogs</li>
<li><i class="far fa-images"></i> product</li>
</ul>
</nav>
<ul class="access">
<li><button class="accessBtn"><i class="fas fa-sign-in-alt"></i> Access <i class="fas fa-caret-down"></i></button>
<ul class ="access-menu">
<li id="signup">Signup</li>
<li id="signin">Signin</li>
</ul>
</li>
</ul>
<div id="hamburger-icon" onclick="toggleMobileMenu(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<ul class="mobile-menu">
<li class="active"><i class="fas fa-home"></i> Home</li>
<li><i class="fas fa-pen-nib"></i> contact</li>
<li><i class="far fa-images"></i> Product</li>
<li>Signup</li>
<li>Signin</li>
</ul>
</div>
</header>
<section class="container-a" aria-label="blog-content">
<div class="wrapper">
<div class="blog-container">
<span>Blogs</span><hr>
<div class="blog-cards">
<div class="card">
<img src="images/1.jpg">
<p class="category">Fashion</p>
<div class="flag">
<button onclick=myFunction()>&#8942</button>
<div id="report">
<p>Report</p>
<p>Not-interested</p>
</div>
</div><!--flag-->
<div class="card-panel">
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-star"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-comment"></i>
</div>
<div class="icon">
<div class="tooltip1"><i class="fas fa-crown"></i>Umananda goswami
</div>
<img src="images/4.jpeg">
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-user-plus"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-share"></i>
</div>
</div><!--card-panel-->
<div class="text">
<h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</h3>
<button>Read it</button>
</div>
</div><!--card-->
<div class="card">
<img src="images/1.jpg">
<p class="category">Fashion</p>
<div class="flag">
<button onclick=myFunction()>&#8942</button>
<div id="report">
<p>Report</p>
<p>Not-interested</p>
</div>
</div><!--flag-->
<div class="card-panel">
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-star"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-comment"></i>
</div>
<div class="icon">
<div class="tooltip1"><i class="fas fa-crown"></i>Umananda goswami
</div>
<img src="images/4.jpeg">
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-user-plus"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-share"></i>
</div>
</div><!--card-panel-->
<div class="text">
<h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</h3>
<button>Read it</button>
</div>
</div><!--card-->
<div class="card">
<img src="images/1.jpg">
<p class="category">Fashion</p>
<div class="flag">
<button onclick=myFunction()>&#8942</button>
<div id="report">
<p>Report</p>
<p>Not-interested</p>
</div>
</div><!--flag-->
<div class="card-panel">
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-star"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-comment"></i>
</div>
<div class="icon">
<div class="tooltip1"><i class="fas fa-crown"></i>Umananda goswami
</div>
<img src="images/4.jpeg">
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-user-plus"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-share"></i>
</div>
</div><!--card-panel-->
<div class="text">
<h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</h3>
<button>Read it</button>
</div>
</div><!--card-->
<div class="card">
<img src="images/1.jpg">
<p class="category">Fashion</p>
<div class="flag">
<button onclick=myFunction()>&#8942</button>
<div id="report">
<p>Report</p>
<p>Not-interested</p>
</div>
</div><!--flag-->
<div class="card-panel">
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-star"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-comment"></i>
</div>
<div class="icon">
<div class="tooltip1"><i class="fas fa-crown"></i>Umananda goswami
</div>
<img src="images/4.jpeg">
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-user-plus"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-share"></i>
</div>
</div><!--card-panel-->
<div class="text">
<h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</h3>
<button>Read it</button>
</div>
</div><!--card-->
<div class="card">Card5</div>
<div class="load-more">
<button>Load More</button>
</div>
</div><!--cards-->
</div>
<div class="blog-sidebar">
<span>Sidebar</span><hr>
<div class="widgets">
<img src="images/5.jpg">
<img src="images/4.jpeg">
</div>
</div>
</div>
</section>
The problem here is, that you set the .card class a min-width: 14.8rem, so it would be bigger than the actual body with at a certian point. You can resolve this by remove the absolute min-width.
Working code:
function toggleMobileMenu(menu) {
menu.classList.toggle('open');
}
function toggleSidebar(menu) {
menu.classList.toggle('open');
}
html {
height: 100%;
box-sizing: border-box;
}
*,
*:after,
*:before {
box-sizing: inherit;
}
body {
position: relative;
min-height: 100%;
min-width: 100%;
box-sizing: border-box;
margin: 0;
padding-bottom: 12rem;
font-family: 'Roboto', sans-serif !important;
background: #f2f2f2;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.body-content {
padding-bottom: 0.5rem;
width: 100%;
}
/*Main ends here*/
/*Global*/
h2 {
color: #007bff;
font-size: 20px;
}
li,
a {
list-style: none;
text-decoration: none;
}
.button {
padding: 9px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
color: #fff;
}
/*Global*/
header {
padding: 0 20px;
background: #007991;
/* fallback for old browsers */
background: -webkit-linear-gradient(to left, #78ffd6, #007991);
/* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #78ffd6, #007991);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
-webkit-box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.75);
-moz-box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.75);
box-shadow: 0px 0px 2px 0px rgba(0, 0, 0, 0.75);
height: 50px;
width: 100%;
min-width: 100%;
display: flex;
justify-content: space-between;
z-index: 1001;
position: -moz-sticky;
position: -webkit-sticky;
position: sticky;
top: 0;
}
.logo {
width: 30px;
height: 30px;
justify-self: start;
margin: 10px 20px;
cursor: pointer;
}
header nav {
overflow: hidden;
margin-right: auto;
}
header nav ul {
list-style: none;
}
header nav ul li {
display: inline-block;
padding-left: 20px;
}
.active a {
color: #fff;
}
header nav ul li:hover {
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
header nav ul li a {
color: #f2f3f5;
padding: 10px;
text-decoration: none;
font-weight: 400 !important;
}
header nav ul li a:hover {
color: #fff;
font-weight: 400 !important;
}
.access {
margin: 9px;
list-style: none;
display: block;
position: relative;
z-index: 100;
}
.access button {
padding: 9px 25px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
color: #fff;
}
.access button:hover {
background: rgba(0, 136, 169, 0.8);
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
.access li {
list-style: none;
cursor: pointer;
}
.access li a {
text-decoration: none;
}
.access li ul {
background-color: rgba(0, 136, 169, 1);
display: none;
/*submenu dissappears when set to none*/
text-align: center;
padding: 10px 25px;
margin-top: 8px;
border-bottom-right-radius: 10px;
border-bottom-left-radius: 10px;
}
.access li:hover ul {
display: block;
}
.access-menu li a {
color: #fff !important;
font-weight: 400!important;
}
.access-menu.reveal {
display: block;
}
.access li ul li {
padding: 5px;
color: #fff;
display: block;
font-weight: 500;
}
.access li ul li:hover {
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
/*mobile-menu*/
#hamburger-icon {
margin: auto 0;
display: none;
cursor: grab;
background: rgba(0, 136, 169, 1);
border-radius: 5px;
padding: 3px 10px;
}
#hamburger-icon div {
width: 25px;
height: 3px;
background-color: #fff;
margin: 5px 0;
transition: all 0.3s ease 0s;
}
.open .bar1 {
-webkit-transform: rotate(-45deg) translate(-6px, 5px);
transform: rotate(-45deg) translate(-6px, 5px);
}
.open .bar2 {
opacity: 0;
}
.open .bar3 {
-webkit-transform: rotate(45deg) translate(-6px, -6px);
transform: rotate(45deg) translate(-6px, -6px);
}
.open .mobile-menu {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
position: absolute;
}
.mobile-menu {
display: none;
position: fixed;
top: 24px;
left: 0;
width: 100%;
height: calc(100vh - 50px);
overflow: hidden;
height: auto;
text-align: center;
background: #007991;
/* fallback for old browsers */
background: -webkit-linear-gradient(to left, #78ffd6, #007991);
/* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #78ffd6, #007991);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
color: #fff;
z-index: 100;
}
.mobile-menu li {
padding: 10px;
font-weight: 400 !important;
}
.mobile-menu li a {
color: #fff;
}
.mobile-menu li:hover {
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
#media(max-width: 768px) {
header {
height: 40px;
}
.logo {
height: 25px;
width: 25px;
margin: 8px 10px;
}
header nav,
header .access {
display: none;
}
#hamburger-icon {
display: block;
padding: 2px 7px;
margin-right: 5px;
}
#hamburger-icon div {
width: 20px;
height: 3px;
}
.mobile-menu li {
margin-right: 15px;
}
}
media(min-width: 769px) and (max-width: 1020px) {
.logo {
margin: 10px;
}
nav ul li {
padding-left: 10px;
font-size: 16px;
}
nav ul li a {
padding: 5px;
}
}
#media(min-width: 250px) and (max-width: 281px) {
.logo {
margin-left: -10px;
}
#hamburger-icon {
margin-right: -10px;
}
}
#media(min-width: 282px) and (max-width: 320px) {
.logo {
margin-left: -10px;
}
#hamburger-icon {
margin-right: -10px;
}
}
/*Card*/
.card {
min-width: 15rem;
flex: 1;
-webkit-box-flex: 1;
-ms-flex: 1;
height: 100%;
width: 100%;
border: 1px solid #ccc;
background: #fff;
font-weight: 300 !important;
position: relative;
}
.card .category {
position: absolute;
top: -10px;
left: 0;
background: #FF7F50;
color: #fff;
font-weight: 300 !important;
padding: 5px 9px;
font-size: 10px;
text-transform: uppercase;
}
.card .flag {
top: 0;
right: -15px;
position: absolute;
}
.card .flag button {
position: absolute;
top: -10px;
right: 0;
background: 0;
color: #fff;
font-size: 20px;
}
.flag #report {
display: none;
float: left;
padding: 0;
margin-top: 22px;
margin-right: 22px;
background: #fff;
color: #007bff;
}
#report p {
padding: 2px 5px;
top: -10px;
font-size: 10px;
line-height: 0.1rem;
cursor: pointer;
}
.card img {
flex-wrap: wrap;
pointer-events: none;
-moz-user-select: none;
-webkit-user-select: none;
user-select: none;
width: 100%;
float: none;
display: block;
z object-fit: fill;
height: 180px;
}
.card-panel {
display: flex;
align-items: center;
justify-content: center;
margin-top: -10px;
}
.card-panel .icon {
cursor: pointer;
display: flex;
/*flex-direction: row;*/
align-items: center;
justify-content: center;
position: relative;
z-index: 1;
}
.card-panel .icon img {
height: 60px;
width: 60px;
border: 5px solid #FFF;
border-radius: 50%;
background-color: #007bff;
text-align: center;
color: #fff;
margin: -25px 10px 0 10px;
pointer-events: none;
cursor: pointer;
}
.card-panel .icon i {
font-size: 15px;
line-height: 30px;
height: 40px;
width: 40px;
border: 5px solid #fff;
border-radius: 50%;
background-color: #007bff;
text-align: center;
color: #fff;
margin: -20px 5px 0 5px;
}
.card-panel .icon .tooltip,
.card-panel .icon .tooltip1 {
text-align: center;
position: absolute;
top: 0;
background: #fff;
color: #007bff;
font-size: 10px;
padding: 10px 10px;
border-radius: 25px;
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.1);
opacity: 0;
pointer-events: none;
z-index: 1;
transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.card-panel .icon .tooltip:before,
.card-panel .icon .tooltip1:before {
position: absolute;
content: "";
height: 7px;
width: 7px;
background: #fff;
bottom: -3px;
left: 50%;
transform: translate(-50%) rotate(45deg);
transition: all 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}
.card-panel .icon:hover .tooltip,
.card-panel .icon:focus .tooltip {
position: absolute;
top: -60px;
opacity: 1;
pointer-events: auto;
}
.card-panel .icon:hover .tooltip1,
.card-panel .icon:focus .tooltip1 {
top: -92px;
opacity: 1;
pointer-events: auto;
text-align: center;
}
.card-panel .icon:hover i,
.card-panel .icon:active i,
.card-panel .icon:hover .tooltip,
.card-panel .icon:focus .tooltip,
.card-panel .icon .tooltip1:before {
text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.4);
}
.card-panel .tooltip1 i {
font-size: 8px;
line-height: 13px;
height: 20px;
width: 20px;
border: 3px solid #fff;
border-radius: 50%;
background-color: #007bff;
text-align: center;
color: #fff;
margin: -20px 5px 0 5px;
}
.card .text {
padding: 10px 10px;
}
.card .text h3 {
margin-top: 0;
text-align: justify;
text-justify: inter-word;
font-weight: 500 !important;
}
.card button {
background-color: #007bff;
border-radius: 10px;
color: #fff;
padding: 10px 20px;
border: none;
cursor: pointer;
position: relative;
margin: 0 auto;
display: block;
}
.card button:hover {
opacity: 0.8;
}
.card .see-more {
top: 40%;
text-align: center;
position: relative;
}
.card .see-more i {
font-size: 60px;
color: #007bff;
}
.container-a,
.container-b {
margin: 10px auto;
padding: 0;
width: calc(100% - 100px);
position: relative;
}
.wrapper {
height: 100%;
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-template-areas: "blog-container blog-container blog-container blog-container blog-sidebar";
grid-gap: 10px;
}
.wrapper .blog-container {
grid-area: blog-container;
}
.wrapper .blog-sidebar {
grid-area: blog-sidebar;
}
.wrapper .blog-container span,
.wrapper .blog-sidebar span {
background-color: #007bff;
padding: 5px 10px;
position: relative;
color: #fff;
z-index: -1;
background-blend-mode: multiply;
font-family: 'Roboto', sans-serif !important;
}
.blog-container hr,
.blog-sidebar hr {
width: 100%;
color: #007bff;
margin-top: 3.5px;
position: relative;
z-index: -2;
}
.blog-container .blog-cards {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
grid-gap: 10px;
}
.widgets {
background: #fff;
border: 1px solid #ccc;
margin-bottom: 10px;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
grid-gap: 10px;
padding: 5px;
}
.widgets img {
width: 100%;
float: none;
display: block;
object-fit: fill;
}
.container-a .widgets,
.container-b .widgets {
margin-bottom: 10px;
}
.load-more {
text-align: center;
grid-column: 1/-1;
margin-bottom: 10px;
}
.load-more button {
padding: 9px 150px;
background-color: rgba(0, 136, 169, 1);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease 0s;
color: #fff;
font-size: 13px;
}
.load-more button:hover {
background: rgba(0, 136, 169, 0.8);
transform: scale(1.1);
transition: all 0.3s ease 0s;
}
/*--MEDIA QUERIES--*/
#media(max-width: 768px) {
.carousel {
width: calc(100% - 60px);
margin: 10px auto;
}
.carousel span,
.wrapper .blog-container span,
.wrapper .blog-sidebar span {
font-size: 12px;
}
.carousel hr {
margin-top: 3px;
}
.horizontal-scroll .btn-scroll {
padding: 0 5px;
font-size: 30px;
}
.horizontal-scroll #btn-scroll-left {
top: calc(430px/2);
}
.horizontal-scroll #btn-scroll-right {
top: calc(430px/2);
}
.container-a,
.container-b {
width: 99%;
padding: 5px;
}
.wrapper {
grid-template-rows: auto;
grid-template-columns: 1fr;
grid-template-areas: "blog-container" "blog-sidebar";
}
.card {
min-width: 100%;
}
.card .category {
font-size: 8px;
padding: 4px 7px;
top: -8px;
}
.card img {
height: 150px;
}
.card .flag {
right: -7px;
0
}
.card .flag button {
font-size: 15px;
top: -5px;
}
.flag #report {
margin-top: 17px;
margin-right: 12px;
}
#report p {
padding: 1px 4px;
font-size: 9px;
}
.card-panel .icon i {
font-size: 10px;
line-height: 22px;
height: 30px;
width: 30px;
margin: -12px 4px 0 4px;
border: 4px solid #FFF;
}
.card-panel .icon img {
width: 50px;
height: 50px;
border: 4px solid #FFF;
margin: -20px 10px 0 10px;
}
.card-panel .icon .tooltip,
.card-panel .icon .tooltip1 {
padding: 8px 8px;
font-size: 8px;
}
.card-panel .icon .tooltip:before,
.card-panel .icon .tooltip1:before {
width: 5px;
height: 5px;
bottom: -2px;
}
.card-panel .icon:hover .tooltip {
top: -45px;
}
.card-panel .icon:hover .tooltip1 {
top: -75px;
}
.card-panel .tooltip1 i {
font-size: 8px;
line-height: 14px;
height: 18px;
width: 18px;
border: 2px solid #fff;
}
.card .text h3 {
font-size: 15px;
}
.card button {
padding: 5px 10px;
font-size: 12px;
}
.widgets {
grid-template-columns: repeat(auto-fill, minmax(244px, 1fr));
}
.card .see-more {
top: 40%;
}
.card .see-more i {
font-size: 50px;
}
.load-more button {
padding: 5px 30px;
font-size: 12px;
}
}
#media(max-width: 281px) {
.wrapper .blog-container {
padding-right: 0;
}
.blog-container .blog-cards {
grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
}
.widgets {
grid-template-columns: repeat(auto-fill, minmax(100%, 1fr));
}
}
<section class="body-content">
<header>
<img src="img/Logo.jpg" class="logo" alt="Logo">
<nav>
<ul>
<li class="active"><i class="fas fa-home"></i> Home</li>
<li><i class="fas fa-pen-nib"></i> Blogs</li>
<li><i class="far fa-images"></i> product</li>
</ul>
</nav>
<ul class="access">
<li><button class="accessBtn"><i class="fas fa-sign-in-alt"></i> Access <i class="fas fa-caret-down"></i></button>
<ul class="access-menu">
<li id="signup">Signup</li>
<li id="signin">Signin</li>
</ul>
</li>
</ul>
<div id="hamburger-icon" onclick="toggleMobileMenu(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
<ul class="mobile-menu">
<li class="active"><i class="fas fa-home"></i> Home</li>
<li><i class="fas fa-pen-nib"></i> contact</li>
<li><i class="far fa-images"></i> Product</li>
<li>Signup</li>
<li>Signin</li>
</ul>
</div>
</header>
<section class="container-a" aria-label="blog-content">
<div class="wrapper">
<div class="blog-container">
<span>Blogs</span>
<hr>
<div class="blog-cards">
<div class="card">
<img src="images/1.jpg">
<p class="category">Fashion</p>
<div class="flag">
<button onclick=myFunction()>&#8942</button>
<div id="report">
<p>Report</p>
<p>Not-interested</p>
</div>
</div>
<!--flag-->
<div class="card-panel">
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-star"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-comment"></i>
</div>
<div class="icon">
<div class="tooltip1"><i class="fas fa-crown"></i>Umananda goswami
</div>
<img src="images/4.jpeg">
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-user-plus"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-share"></i>
</div>
</div>
<!--card-panel-->
<div class="text">
<h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</h3>
<button>Read it</button>
</div>
</div>
<!--card-->
<div class="card">
<img src="images/1.jpg">
<p class="category">Fashion</p>
<div class="flag">
<button onclick=myFunction()>&#8942</button>
<div id="report">
<p>Report</p>
<p>Not-interested</p>
</div>
</div>
<!--flag-->
<div class="card-panel">
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-star"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-comment"></i>
</div>
<div class="icon">
<div class="tooltip1"><i class="fas fa-crown"></i>Umananda goswami
</div>
<img src="images/4.jpeg">
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-user-plus"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-share"></i>
</div>
</div>
<!--card-panel-->
<div class="text">
<h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</h3>
<button>Read it</button>
</div>
</div>
<!--card-->
<div class="card">
<img src="images/1.jpg">
<p class="category">Fashion</p>
<div class="flag">
<button onclick=myFunction()>&#8942</button>
<div id="report">
<p>Report</p>
<p>Not-interested</p>
</div>
</div>
<!--flag-->
<div class="card-panel">
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-star"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-comment"></i>
</div>
<div class="icon">
<div class="tooltip1"><i class="fas fa-crown"></i>Umananda goswami
</div>
<img src="images/4.jpeg">
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-user-plus"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-share"></i>
</div>
</div>
<!--card-panel-->
<div class="text">
<h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</h3>
<button>Read it</button>
</div>
</div>
<!--card-->
<div class="card">
<img src="images/1.jpg">
<p class="category">Fashion</p>
<div class="flag">
<button onclick=myFunction()>&#8942</button>
<div id="report">
<p>Report</p>
<p>Not-interested</p>
</div>
</div>
<!--flag-->
<div class="card-panel">
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-star"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-comment"></i>
</div>
<div class="icon">
<div class="tooltip1"><i class="fas fa-crown"></i>Umananda goswami
</div>
<img src="images/4.jpeg">
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-user-plus"></i>
</div>
<div class="icon">
<div class="tooltip">14.1k</div>
<i class="fas fa-share"></i>
</div>
</div>
<!--card-panel-->
<div class="text">
<h3>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod</h3>
<button>Read it</button>
</div>
</div>
<!--card-->
<div class="card">Card5</div>
<div class="load-more">
<button>Load More</button>
</div>
</div>
<!--cards-->
</div>
<div class="blog-sidebar">
<span>Sidebar</span>
<hr>
<div class="widgets">
<img src="images/5.jpg">
<img src="images/4.jpeg">
</div>
</div>
</div>
</section>
So the problem was fixed by changing min-width to 100% insted of a absolute value in line 601 at your css file.

Changing text after :focus and :hover

I'm creating a website. On default, I want to have an fontawesome icon on the div, but when user hover to this div or key focus I want to hide the icon and show text "Home", "Offert" etc.
.page-nav-menu {
height: 45px;
width: 100%;
margin: auto;
text-align: center;
}
.nav-menu-option {
height: 100%;
width: 120px;
text-align: center;
background: black;
color: white;
font-size: 22px;
padding: 5px;
padding-top: 20px !important;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
transition: 0.5 background;
margin: auto;
margin-right: 10px !important;
}
.nav-menu-option:focus,
.nav-menu-option:hover {
outline: none;
background: #1b63f4c8;
transition: 0.5 background;
cursor: pointer;
outline: none;
}
.page-nav-menu a {
color: #1b63f4c8;
border-bottom: none;
}
.page-nav-menu a:focus,
.page-nav-menu a:hover {
outline: none;
border-bottom: none;
}
#nav-option-1 {
width: 100px;
margin-left: 350px;
}
#nav-option-1::before {
content: '';
}
#nav-option-1::after,
#nav-option-1:hover {
content: Home;
}
#nav-option-2 {
width: 130px;
}
a {
color: #1a1a1a;
text-decoration: none;
border-bottom: 3px solid black;
border-radius: 1px;
}
a:focus,
a:hover {
border-bottom: 3px solid #1b63f4;
border-radius: 1px;
}
<div class="page-nav-menu flex">
<a href="/">
<div class="nav-menu-option" id="nav-option-1"><i class="fa-solid fa-house-chimney"></i></div>
</a>
<a href="offer">
<div class="nav-menu-option"><i class="fa-solid fa-laptop-code"></i></div>
</a>
<a href="realisations">
<div class="nav-menu-option" id="nav-option-2"><i class="fa-solid fa-globe"></i></div>
</a>
<a href="about-me">
<div class="nav-menu-option">fa-solid fa-user</div>
</a>
<a href="contact">
<div class="nav-menu-option"><i class="fa-solid fa-envelope"></i></div>
</a>
</div>
What can I do?
Kind Regards
I'm a new programer so I'm not sure if I can help you but this is my result
result:
const iconElement = document.querySelector('.fa-globe'); /*icon element*/
const nav_menu_option = document.getElementById('nav-option-2')/*nav option element */
nav_menu_option.addEventListener('mouseenter', () => {
iconElement.style.display = 'none';
nav_menu_option.innerHTML = 'realisations' ;
})
nav_menu_option.addEventListener('mouseleave', () => {
iconElement.style.display = 'block'/*or whatever you want*/;
nav_menu_option.innerHTML = '<i class="fa-solid fa-globe"></i>';
})
<html>
<body>
<a href="realisations">
<div class="nav-menu-option" id="nav-option-2"><i class="fa-solid fa-globe"></i></div>
</a>
</body>
<script src="https://kit.fontawesome.com/8367bf7b85.js" crossorigin="anonymous"></script>
</html>
I really really hope I helped you.
You can put icon in a div and put display:none; property inside nav-menu-option:hover
.page-nav-menu {
height: 45px;
width: 100%;
margin: auto;
text-align: center;
}
.nav-menu-option .text {
display: none;
}
.nav-menu-option {
height: 100%;
width: 120px;
text-align: center;
background: black;
color: white;
font-size: 22px;
padding: 5px;
padding-top: 20px !important;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
transition: 0.5 background;
margin: auto;
margin-right: 10px !important;
}
.nav-menu-option:focus,
.nav-menu-option:hover {
outline: none;
background: #1b63f4c8;
transition: 0.5 background;
cursor: pointer;
outline: none;
}
.page-nav-menu a {
color: #1b63f4c8;
border-bottom: none;
}
.page-nav-menu a:focus,
.page-nav-menu a:hover {
outline: none;
border-bottom: none;
}
#nav-option-1 {
width: 100px;
margin-left: 350px;
}
#nav-option-1::before {
content: '';
}
#nav-option-1::after,
#nav-option-1:hover {
content: Home;
}
#nav-option-2 {
width: 130px;
}
a {
color: #1a1a1a;
text-decoration: none;
border-bottom: 3px solid black;
border-radius: 1px;
}
a:focus,
a:hover {
border-bottom: 3px solid #1b63f4;
border-radius: 1px;
}
.nav-menu-option:hover .icon {
display: none;
}
.nav-menu-option:hover .text {
display: block;
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/js/all.min.js"></script>
<div class="page-nav-menu flex">
<a href="/">
<div class="nav-menu-option"><div class="icon"><i class="fa-solid fa-house-chimney"></i></div><div class="text">Home</div></div>
</a>
<a href="offer">
<div class="nav-menu-option"><div class="icon"><i class="fa-solid fa-laptop-code"></i></div><div class="text">Offer</div></div>
</a>
<a href="realisations">
<div class="nav-menu-option"><div class="icon"><i class="fa-solid fa-globe"></i></div><div class="text">Realisation</div></div>
</a>
<a href="about-me">
<div class="nav-menu-option"><div class="icon">
<i class="fa-solid fa-user"></i>
</div><div class="text">About me</div></div>
</a>
<a href="contact">
<div class="nav-menu-option"><div class="icon"><i class="fa-solid fa-envelope"></i></div><div class="text">Contact</div></div>
</a>
</div>
if you want it with fade effect you can use this :)
PS: optimized your code and removed unnecessary ones
body {
margin: 0;
padding: 0;
}
.page-nav-menu {
text-align: center;
}
.page-nav-menu a {
text-decoration: none;
-webkit-tap-highlight-color: transparent;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
.nav-menu-option {
position: relative;
display: inline-block;
margin: 0 5px 5px;
padding: 20px 5px;
width: 120px;
font-size: 1.5em;
border-radius: 0 0 40px 40px;
background: black;
color: white;
transition: all 0.5s ease;
}
.nav-menu-option:focus,
.nav-menu-option:hover {
background: #1b63f4c8;
cursor: pointer;
}
.nav-menu-option>* {
transition: visibility 0.5s, opacity 0.3s linear;
}
.nav-menu-option>.title {
font-family: 'Courier New', Courier, monospace;
position: absolute;
left: 0;
right: 0;
opacity: 0;
bottom: 30%;
text-transform: uppercase;
visibility: hidden;
}
.nav-menu-option:hover .title,
.nav-menu-option:focus .title {
visibility: visible;
opacity: 1;
}
.nav-menu-option:hover .icon,
.nav-menu-option:focus .icon {
opacity: 0;
visibility: hidden;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet" />
<div class="page-nav-menu flex">
<a href="#">
<div class="nav-menu-option">
<i class="fa-solid fa-house-chimney icon"></i>
<span class="title">Home</span>
</div>
</a>
<a href="#">
<div class="nav-menu-option">
<i class="fa-solid fa-laptop-code icon"></i>
<span class="title">Laptop</span>
</div>
</a>
<a href="#">
<div class="nav-menu-option">
<i class="fa-solid fa-globe icon"></i>
<span class="title">Global</span>
</div>
</a>
<a href="#">
<div class="nav-menu-option">
<i class="fa-solid fa-user icon"></i>
<span class="title">User</span>
</div>
</a>
<a href="#">
<div class="nav-menu-option">
<i class="fa-solid fa-envelope icon"></i>
<span class="title">Mail</span>
</div>
</a>
</div>
Try the following it should work using display none and display block on each child element
CSS
<style>
.page-nav-menu {
height: 45px;
width: 100%;
margin: auto;
text-align: center;
}
.nav-menu-option {
height: 100%;
width: 120px;
text-align: center;
background: black;
color: white;
font-size: 22px;
padding: 5px;
padding-top: 20px !important;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
transition: 0.5 background;
margin: auto;
margin-right: 10px !important;
}
.nav-menu-option:focus,
.nav-menu-option:hover {
outline: none;
background: #1b63f4c8;
transition: 0.5 background;
cursor: pointer;
outline: none;
}
.page-nav-menu a {
color: #1b63f4c8;
border-bottom: none;
}
.page-nav-menu a:focus,
.page-nav-menu a:hover {
outline: none;
border-bottom: none;
}
#nav-option-1 {
width: 100px;
margin-left: 350px;
}
#nav-option-1::before {
content: "";
}
#nav-option-1::after,
#nav-option-1:hover {
content: Home;
}
#nav-option-2 {
width: 130px;
}
a {
color: #1a1a1a;
text-decoration: none;
border-bottom: 3px solid black;
border-radius: 1px;
}
a:focus,
a:hover {
border-bottom: 3px solid #1b63f4;
border-radius: 1px;
}
.nav-menu-option:hover i {
display: none;
}
.nav-menu-option:hover span {
display: block;
}
.nav-menu-option span {
display: none;
}
</style>
Html
<div class="page-nav-menu flex">
<a href="/">
<div class="nav-menu-option" id="nav-option-1">
<i class="fa-solid fa-house-chimney"></i><span>home</span>
</div>
</a>
<a href="offer">
<div class="nav-menu-option">
<i class="fa-solid fa-laptop-code"></i><span>gallery</span>
</div>
</a>
<a href="realisations">
<div class="nav-menu-option" id="nav-option-2">
<i class="fa-solid fa-globe"></i><span>etc</span>
</div>
</a>
<a href="about-me">
<div class="nav-menu-option">
<i class="fa-solid fa-user"></i><span>test</span>
</div>
</a>
<a href="contact">
<div class="nav-menu-option">
<i class="fa-solid fa-envelope"></i><span>test</span>
</div>
</a>
</div>

The :checked selector doesn't work beside working on the tutorial

I'm using this tutorial, and beside some id/class name, I did exactly the same as the tutorial, but i still can't make the checked work.
I didn't get through the entire tutorial.
I tested both codes (code I tested with : here), but it looks like the problem isn't coming from the checkbox.
Here's the HTML :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css">
<title>Test Sidebar</title>
</head>
<body>
<input type="checkbox" id="check">
<header>
<label for="check">
<i class="fas fa-bars" id="sidebarBtn"></i>
</label>
<div class="leftArea">
<h3>Side <span>Bar</span></h3>
</div>
<div class="rightArea">
Logout
</div>
<div class="sidebar">
<center>
<img src="pic.jpg" class="profileImage" alt="">
<h4>Amanda</h4>
</center>
<i class="fas fa-desktop"></i><span>Dashboard</span>
<i class="fas fa-cogs"></i><span>Components</span>
<i class="fas fa-table"></i><span>Tables</span>
<i class="fas fa-th"></i><span>Forms</span>
<i class="fas fa-info-circle"></i><span>About</span>
<i class="fas fa-sliders-h"></i><span>Settings</span>
</div>
</header>
</body>
</html>
Here's the CSS :
body {
margin: 0;
padding: 0;
font-family: "Roboto", sans-serif;
}
header {
position: fixed;
background: #22242A;
padding: 20px;
width: 100%;
height: 30px;
}
.leftArea h3 {
color: #fff;
margin: 0;
text-transform: uppercase;
font-size: 22px;
font-weight: 900;
}
.leftArea span {
color: #1DC4E7;
}
.logoutBtn {
padding: 5px;
background: #19B3D3;
text-decoration: none;
float: right;
margin-top: -30px;
margin-right: 40px;
border-radius: 2px;
font-size: 15px;
font-weight: 600;
color: #fff;
transition: 0.5s;
transition-property: background;
}
.logoutBtn:hover {
background: #0D9DBB;
}
.sidebar {
background: #2F323A;
margin-top: 22px;
/* margin-top: 70px - n'as pas l'air de fonctionner */
padding-top: 30px;
position: fixed;
left: 0;
width: 250px;
height: 100%
}
.sidebar .profileImage {
width: 100px;
height: 100px;
border-radius: 100px;
margin-bottom: 10px;
}
.sidebar h4 {
color: #ccc;
margin-top: 0;
margin-bottom: 20px;
}
.sidebar a {
color: #fff;
display: block;
width: 100%;
line-height: 60px;
text-decoration: none;
padding-left: 40px;
box-sizing: border-box;
transition: 0.5s;
transition-property: background;
}
.sidebar a:hover {
background: #19B3D3;
}
.sidebar i {
padding-right: 10px;
}
label #sidebarBtn {
z-index: 1;
color: #fff;
position: fixed;
cursor: pointer;
left: 300px;
font-size: 20px;
margin: 5px 0;
transition: 0.5s;
transition-property: color;
}
label #sidebarBtn:hover {
color: #19B3D3;
}
#check:checked ~ .sidebar {
left: -190px;
}
Place an <input type="checkbox" id="check"> inside your head tag, but above the line <label for="check">.
body {
margin: 0;
padding: 0;
font-family: "Roboto", sans-serif;
}
header {
position: fixed;
background: #22242A;
padding: 20px;
width: 100%;
height: 30px;
}
.leftArea h3 {
color: #fff;
margin: 0;
text-transform: uppercase;
font-size: 22px;
font-weight: 900;
}
.leftArea span {
color: #1DC4E7;
}
.logoutBtn {
padding: 5px;
background: #19B3D3;
text-decoration: none;
float: right;
margin-top: -30px;
margin-right: 40px;
border-radius: 2px;
font-size: 15px;
font-weight: 600;
color: #fff;
transition: 0.5s;
transition-property: background;
}
.logoutBtn:hover {
background: #0D9DBB;
}
.sidebar {
background: #2F323A;
margin-top: 22px;
/* margin-top: 70px - n'as pas l'air de fonctionner */
padding-top: 30px;
position: fixed;
left: 0;
width: 250px;
height: 100%
}
.sidebar .profileImage {
width: 100px;
height: 100px;
border-radius: 100px;
margin-bottom: 10px;
}
.sidebar h4 {
color: #ccc;
margin-top: 0;
margin-bottom: 20px;
}
.sidebar a {
color: #fff;
display: block;
width: 100%;
line-height: 60px;
text-decoration: none;
padding-left: 40px;
box-sizing: border-box;
transition: 0.5s;
transition-property: background;
}
.sidebar a:hover {
background: #19B3D3;
}
.sidebar i {
padding-right: 10px;
}
label #sidebarBtn {
z-index: 1;
color: #fff;
position: fixed;
cursor: pointer;
left: 300px;
font-size: 20px;
margin: 5px 0;
transition: 0.5s;
transition-property: color;
}
label #sidebarBtn:hover {
color: #19B3D3;
}
#check:checked ~ .sidebar {
left: -190px;
}
<body>
<header>
<input type="checkbox" id="check">
<label for="check">
<i class="fas fa-bars" id="sidebarBtn"></i>
</label>
<div class="leftArea">
<h3>Side <span>Bar</span></h3>
</div>
<div class="rightArea">
Logout
</div>
<div class="sidebar">
<center>
<img src="pic.jpg" class="profileImage" alt="">
<h4>Amanda</h4>
</center>
<i class="fas fa-desktop"></i><span>Dashboard</span>
<i class="fas fa-cogs"></i><span>Components</span>
<i class="fas fa-table"></i><span>Tables</span>
<i class="fas fa-th"></i><span>Forms</span>
<i class="fas fa-info-circle"></i><span>About</span>
<i class="fas fa-sliders-h"></i><span>Settings</span>
</div>
</header>
</body>
Ok, i just understood where i messed up. The tag should close after the rightArea class.
<header>
<label for="check">
<i class="fas fa-bars" id="sidebarBtn"></i>
</label>
<div class="leftArea">
<h3>Side <span>Bar</span></h3>
</div>
<div class="rightArea">
Logout
</div>
</header>
This way, i can have my input BEFORE my header, and it would works. I think it's because now, the sidebar isn't in the header anymore. That was pretty dumb on my part, sorry, and thank you for helping me out there.

Text not aligning vertically in a flex block

.account-select-block {
display: flex;
width: 100%;
height: 50px;
line-height: 50px;
}
.account-select-icon {
flex: 0;
font-size: 20px;
}
.account-select-item {
flex: 1;
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
}
.account-select-remove {
flex: 0;
font-size: 20px;
background-color: #ff5200;
color: #fff;
}
<div class="account-select-block">
<div class="account-select-icon">
<i class="fa fa-user-circle" aria-hidden="true"></i>
</div>
<div class="account-select-item">
<h3>Account Name</h3>
</div>
<div class="account-select-remove">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</div>
In the end icons are aligning vertically but text in the middle block doesn't
What am I doing wrong?
Fiddle: https://jsfiddle.net/7su954x3/
You need to remove the margin from the heading:
.account-select-block {
display: flex;
width: 100%;
height: 50px;
line-height: 50px;
}
.account-select-icon {
flex: 0;
font-size: 20px;
}
.account-select-item {
flex: 1;
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
}
.account-select-remove {
flex: 0;
font-size: 20px;
background-color: #ff5200;
color: #fff;
}
/* add this */
.account-select-item h3 {
margin: 0;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="account-select-block">
<div class="account-select-icon">
<i class="fa fa-user-circle" aria-hidden="true"></i>
</div>
<div class="account-select-item">
<h3>Account Name</h3>
</div>
<div class="account-select-remove">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</div>
Didn't realise you were setting the line height manually to vertically centre, if you don't want to do that then you would have to make each child flex too and apply align items to them:
.account-select-block {
display: flex;
width: 100%;
height: 50px;
}
.account-select-icon {
display:flex;
align-items:center;
font-size: 20px;
}
.account-select-item {
display:flex;
align-items:center;
flex-grow:1;
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
}
.account-select-remove {
display:flex;
align-items:center;
font-size: 20px;
background-color: #ff5200;
color: #fff;
}
/* add this */
.account-select-item h3 {
margin: 0;
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
<div class="account-select-block">
<div class="account-select-icon">
<i class="fa fa-user-circle" aria-hidden="true"></i>
</div>
<div class="account-select-item">
<h3>Account Name</h3>
</div>
<div class="account-select-remove">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</div>
In your question you ask how to align in flexbox. However in your code .account-select-item is not a flexbox.
Instead you seem to be using an old styling 'hack' using line-height. This will fall apart if you ever decide to change .account-select-block's height or line-height.
.account-select-block {
display: flex;
width: 100%;
height: 50px;
/* line-height: 50px; */
}
.account-select-icon {
flex: 0;
font-size: 20px;
}
.account-select-item {
display: flex; /* NEW */
flex: 1;
align-items: center; /* NEW */
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
}
.account-select-remove {
flex: 0;
font-size: 20px;
background-color: #ff5200;
color: #fff;
}
<div class="account-select-block">
<div class="account-select-icon">
<i class="fa fa-user-circle" aria-hidden="true"></i>
</div>
<div class="account-select-item">
<h3>Account Name</h3>
</div>
<div class="account-select-remove">
<i class="fa fa-times" aria-hidden="true"></i>
</div>
</div>
try with this
.account-select-item {
flex: 1;
font-size: 14px;
border: 1px solid #D8D8D8;
background: #eee;
cursor: pointer;
transition: border 0.1s ease;
text-align: left;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
}

overlay icons over border

I am trying to create some icons that overlay the border like this:
However when i try to do this i end up with:
Is there a way i can fix this? Dont worry about the icon color i changed it to black so that it is visible.Is there a way i can achieve this using HTML and CSS.
Here is my work:
https://codepen.io/anon/pen/YLdPjM
body {
margin: 0;
padding: 0;
font-family: 'Oswald', sans-serif;
}
.red {
color: red;
}
.underline {
text-decoration: underline;
}
.nav ul {
list-style: none;
background-color: #0F211E;
text-align: center;
padding: 0;
margin: 0;
}
.nav li {
font-size: 1.2em;
line-height: 40px;
height: 40px;
border-bottom: 1px solid #888;
}
.nav a {
text-decoration: none;
color: #fff;
display: block;
transition: .3s background-color;
text-transform: uppercase;
}
.hero-image {
background-image: url("1.jpg");
height: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
#media screen and (min-width: 600px) {
.nav li {
width: 120px;
border-bottom: none;
height: 50px;
line-height: 50px;
font-size: 1.4em;
}
/* Option 1 - Display Inline */
.nav li {
display: inline-block;
margin-right: -4px;
}
/* Options 2 - Float
.nav li {
float: left;
}
.nav ul {
overflow: auto;
width: 600px;
margin: 0 auto;
}
.nav {
background-color: #444;
}
*/
}
section.hero {
height: 75%;
position: relative;
}
.hero-content {
position: absolute;
top: 50%;
transform: translateY(5%);
width: 100%;
}
.bgimg {
/* The image used */
background-image: url("bg.jpg");
/* Set a specific height */
height: 100%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.back .caption:before{
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
transform: scale(0,1);
}
.back .caption:after{
border-right: 1px solid #fff;
border-left: 1px solid #fff;
transform: scale(1,0);
}
.card.flipped .back .caption:before,
.card.flipped .back .caption:after {
opacity: .9;
transform: scale(1);
}
.back dl{
font-family:'Lato', Arial, sans-serif;
font-weight:300;
bottom:40px;
left:40px;
position: absolute;
opacity: 0;
transition: opacity .35s, transform .35s;
transition-delay: .85s;
transform: translate3d(-40px,0,0);
}
.card.flipped .back dl {
opacity: 1;
transform: translate3d(0,0,0);
}
dl dt{
float: left;
width: 60px;
overflow: hidden;
clear: left;
text-align: right;
font-weight:700;
}
dl dd{
margin-left: 80px;
text-align:left;
}
dl dd:before,
dl dd:after{
display: table;
content: " ";
}
dl dd:after{
clear: both;
}
.front:hover p {
opacity: 1;
transform: translate3d(0,0,0);
}
figure a{
z-index: 1000;
text-indent: 200%;
white-space: nowrap;
font-size: 0;
opacity: 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#media (min-width: 450px) {
.container{
left: 50%;
margin-left:-225px;
}
}
body {
background-color: #0F211E;
}
.recipe-card {
border-top: 15px solid lightblue;
border-bottom: 50px solid red;
background: #fff;
margin: 0 auto;
width: 90%;
max-width: 496px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
.card-top {
padding: 30px 15px;
display: flex;
}
.card-top .right {
padding-left: 20px;
}
<html>
<head>
<title>Portfolio</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</style>
</head>
<body class="news" >
<header>
<div class="nav">
<ul>
<li class="two"> <span>About</span></li>
<li class="three"><a class="active" href="#">Projects</a></li>
<li class="four">Skills</li>
</ul>
</div>
</header>
<section class="hero">
<div class="bgimg">
</div>
<div class="hero-content">
<div class="recipe-card">
<aside>
<div class="card-top">
<div class="left">
<img src="myAvatar.png" class="myavatar">
</div>
<div class="right">
<h1>Hamza Wahbi</h1>
<hr class="hrunder">
<h5 style="color:#8B8B8B " >Web Developer</h5>
<h1>Age: <font color="#8B8B8B">13</font></h1>
<h1>Email: <font color="#8B8B8B">fxgfnxngfx#gmail.com</font></h1>
<h1>Phone: <font color="#8B8B8B">0093836372</font></h1>
</div>
</div>
</aside>
<i class="fab fa-twitter fa-3x" style="color: black;"></i>
<i class="fab fa-instagram fa-3x" style="color: black;"></i>
<i class="fab fa-dribbble fa-3x" style="color: black;"></i>
<i class="fab fa-facebook-f fa-3x" style="color: black;"></i>
<i class="fab fa-snapchat-ghost fa-3x" style="color: black;"></i>
<i class="fab fa-google-plus-g fa-3x" style="color: black;"></i>
<i class="fab fa-youtube fa-3x" style="color: black;"></i>
<i class="fab fa-pinterest-p fa-3x" style="color: black;"></i>
</div>
</div><!-- .hero-content -->
</section>
</div>
</html>
Why are you using a border for this? Just have the icons inside a div and set the background colour of the div to red. See snippet below.
body {
margin: 0;
padding: 0;
font-family: 'Oswald', sans-serif;
}
.red {
color: red;
}
.icon-bar {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: space-evenly;
-ms-flex-pack: space-evenly;
justify-content: space-evenly;
background-color: #FC5558;
padding: 5px;
}
.icon-bar i {
color: #fff;
}
.underline {
text-decoration: underline;
}
.nav ul {
list-style: none;
background-color: #0F211E;
text-align: center;
padding: 0;
margin: 0;
}
.nav li {
font-size: 1.2em;
line-height: 40px;
height: 40px;
border-bottom: 1px solid #888;
}
.nav a {
text-decoration: none;
color: #fff;
display: block;
transition: .3s background-color;
text-transform: uppercase;
}
.hero-image {
background-image: url("1.jpg");
height: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
#media screen and (min-width: 600px) {
.nav li {
width: 120px;
border-bottom: none;
height: 50px;
line-height: 50px;
font-size: 1.4em;
}
/* Option 1 - Display Inline */
.nav li {
display: inline-block;
margin-right: -4px;
}
/* Options 2 - Float
.nav li {
float: left;
}
.nav ul {
overflow: auto;
width: 600px;
margin: 0 auto;
}
.nav {
background-color: #444;
}
*/
}
section.hero {
height: 75%;
position: relative;
}
.hero-content {
position: absolute;
top: 50%;
transform: translateY(5%);
width: 100%;
}
.bgimg {
/* The image used */
background-image: url("bg.jpg");
/* Set a specific height */
height: 100%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.back .caption:before {
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
transform: scale(0, 1);
}
.back .caption:after {
border-right: 1px solid #fff;
border-left: 1px solid #fff;
transform: scale(1, 0);
}
.card.flipped .back .caption:before,
.card.flipped .back .caption:after {
opacity: .9;
transform: scale(1);
}
.back dl {
font-family: 'Lato', Arial, sans-serif;
font-weight: 300;
bottom: 40px;
left: 40px;
position: absolute;
opacity: 0;
transition: opacity .35s, transform .35s;
transition-delay: .85s;
transform: translate3d(-40px, 0, 0);
}
.card.flipped .back dl {
opacity: 1;
transform: translate3d(0, 0, 0);
}
dl dt {
float: left;
width: 60px;
overflow: hidden;
clear: left;
text-align: right;
font-weight: 700;
}
dl dd {
margin-left: 80px;
text-align: left;
}
dl dd:before,
dl dd:after {
display: table;
content: " ";
}
dl dd:after {
clear: both;
}
.front:hover p {
opacity: 1;
transform: translate3d(0, 0, 0);
}
figure a {
z-index: 1000;
text-indent: 200%;
white-space: nowrap;
font-size: 0;
opacity: 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#media (min-width: 450px) {
.container {
left: 50%;
margin-left: -225px;
}
}
body {
background-color: #0F211E;
}
.recipe-card {
border-top: 15px solid lightblue;
background: #fff;
margin: 0 auto;
width: 90%;
max-width: 496px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
.card-top {
padding: 30px 15px;
display: flex;
}
.card-top .right {
padding-left: 20px;
}
<html>
<head>
<title>Portfolio</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</style>
</head>
<body class="news">
<header>
<div class="nav">
<ul>
<li class="two">
<span>About</span>
</li>
<li class="three"><a class="active" href="#">Projects</a></li>
<li class="four">Skills</li>
</ul>
</div>
</header>
<section class="hero">
<div class="bgimg">
</div>
<div class="hero-content">
<div class="recipe-card">
<aside>
<div class="card-top">
<div class="left">
<img src="myAvatar.png" class="myavatar">
</div>
<div class="right">
<h1>Hamza Wahbi</h1>
<hr class="hrunder">
<h5 style="color:#8B8B8B ">Web Developer</h5>
<h1>Age:
<font color="#8B8B8B">13</font>
</h1>
<h1>Email:
<font color="#8B8B8B">fxgfnxngfx#gmail.com</font>
</h1>
<h1>Phone:
<font color="#8B8B8B">0093836372</font>
</h1>
</div>
</div>
</aside>
<div class="icon-bar">
<i class="fab fa-twitter fa-3x"></i>
<i class="fab fa-instagram fa-3x"></i>
<i class="fab fa-dribbble fa-3x"></i>
<i class="fab fa-facebook-f fa-3x"></i>
<i class="fab fa-snapchat-ghost fa-3x"></i>
<i class="fab fa-google-plus-g fa-3x"></i>
<i class="fab fa-youtube fa-3x"></i>
<i class="fab fa-pinterest-p fa-3x"></i>
</div>
</div>
</div>
<!-- .hero-content -->
</section>
</div>
</html>
You can wrap all icons in a DIV (class icon_row in my snippet below), apply position: absolute to that DIV and appy position: relative to the recipe-card DIV to define it as the position anchor for the icon DIV (and optionally use position settings like bottom, left etc. to fine-tune the position):
body {
margin: 0;
padding: 0;
font-family: 'Oswald', sans-serif;
}
.red {
color: red;
}
.underline {
text-decoration: underline;
}
.nav ul {
list-style: none;
background-color: #0F211E;
text-align: center;
padding: 0;
margin: 0;
}
.nav li {
font-size: 1.2em;
line-height: 40px;
height: 40px;
border-bottom: 1px solid #888;
}
.nav a {
text-decoration: none;
color: #fff;
display: block;
transition: .3s background-color;
text-transform: uppercase;
}
.hero-image {
background-image: url("1.jpg");
height: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
#media screen and (min-width: 600px) {
.nav li {
width: 120px;
border-bottom: none;
height: 50px;
line-height: 50px;
font-size: 1.4em;
}
/* Option 1 - Display Inline */
.nav li {
display: inline-block;
margin-right: -4px;
}
/* Options 2 - Float
.nav li {
float: left;
}
.nav ul {
overflow: auto;
width: 600px;
margin: 0 auto;
}
.nav {
background-color: #444;
}
*/
}
section.hero {
height: 75%;
position: relative;
}
.hero-content {
position: absolute;
top: 50%;
transform: translateY(5%);
width: 100%;
}
.bgimg {
/* The image used */
background-image: url("bg.jpg");
/* Set a specific height */
height: 100%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.back .caption:before {
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
transform: scale(0, 1);
}
.back .caption:after {
border-right: 1px solid #fff;
border-left: 1px solid #fff;
transform: scale(1, 0);
}
.card.flipped .back .caption:before,
.card.flipped .back .caption:after {
opacity: .9;
transform: scale(1);
}
.back dl {
font-family: 'Lato', Arial, sans-serif;
font-weight: 300;
bottom: 40px;
left: 40px;
position: absolute;
opacity: 0;
transition: opacity .35s, transform .35s;
transition-delay: .85s;
transform: translate3d(-40px, 0, 0);
}
.card.flipped .back dl {
opacity: 1;
transform: translate3d(0, 0, 0);
}
dl dt {
float: left;
width: 60px;
overflow: hidden;
clear: left;
text-align: right;
font-weight: 700;
}
dl dd {
margin-left: 80px;
text-align: left;
}
dl dd:before,
dl dd:after {
display: table;
content: " ";
}
dl dd:after {
clear: both;
}
.front:hover p {
opacity: 1;
transform: translate3d(0, 0, 0);
}
figure a {
z-index: 1000;
text-indent: 200%;
white-space: nowrap;
font-size: 0;
opacity: 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#media (min-width: 450px) {
.container {
left: 50%;
margin-left: -225px;
}
}
body {
background-color: #0F211E;
}
.recipe-card {
border-top: 15px solid lightblue;
border-bottom: 50px solid red;
background: #fff;
margin: 0 auto;
width: 90%;
max-width: 496px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
position: relative;
}
.card-top {
padding: 30px 15px;
display: flex;
}
.card-top .right {
padding-left: 20px;
}
.icon_row {
position: absolute;
left: 30px;
}
<html>
<head>
<title>Portfolio</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</style>
</head>
<body class="news">
<header>
<div class="nav">
<ul>
<li class="two">
<span>About</span>
</li>
<li class="three"><a class="active" href="#">Projects</a></li>
<li class="four">Skills</li>
</ul>
</div>
</header>
<section class="hero">
<div class="bgimg">
</div>
<div class="hero-content">
<div class="recipe-card">
<aside>
<div class="card-top">
<div class="left">
<img src="myAvatar.png" class="myavatar">
</div>
<div class="right">
<h1>Hamza Wahbi</h1>
<hr class="hrunder">
<h5 style="color:#8B8B8B ">Web Developer</h5>
<h1>Age:
<font color="#8B8B8B">13</font>
</h1>
<h1>Email:
<font color="#8B8B8B">fxgfnxngfx#gmail.com</font>
</h1>
<h1>Phone:
<font color="#8B8B8B">0093836372</font>
</h1>
</div>
</div>
</aside>
<div class="icon_row">
<i class="fab fa-twitter fa-3x" style="color: black;"></i>
<i class="fab fa-instagram fa-3x" style="color: black;"></i>
<i class="fab fa-dribbble fa-3x" style="color: black;"></i>
<i class="fab fa-facebook-f fa-3x" style="color: black;"></i>
<i class="fab fa-snapchat-ghost fa-3x" style="color: black;"></i>
<i class="fab fa-google-plus-g fa-3x" style="color: black;"></i>
<i class="fab fa-youtube fa-3x" style="color: black;"></i>
<i class="fab fa-pinterest-p fa-3x" style="color: black;"></i>
</div>
</div>
</div>
<!-- .hero-content -->
</section>
</div>
</html>
Try wrapping icons in a div with position:fixed and bottom: 0
body {
margin: 0;
padding: 0;
font-family: 'Oswald', sans-serif;
}
.red {
color: red;
}
.underline {
text-decoration: underline;
}
.nav ul {
list-style: none;
background-color: #0F211E;
text-align: center;
padding: 0;
margin: 0;
}
.nav li {
font-size: 1.2em;
line-height: 40px;
height: 40px;
border-bottom: 1px solid #888;
}
.nav a {
text-decoration: none;
color: #fff;
display: block;
transition: .3s background-color;
text-transform: uppercase;
}
.hero-image {
background-image: url("1.jpg");
height: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
#media screen and (min-width: 600px) {
.nav li {
width: 120px;
border-bottom: none;
height: 50px;
line-height: 50px;
font-size: 1.4em;
}
/* Option 1 - Display Inline */
.nav li {
display: inline-block;
margin-right: -4px;
}
/* Options 2 - Float
.nav li {
float: left;
}
.nav ul {
overflow: auto;
width: 600px;
margin: 0 auto;
}
.nav {
background-color: #444;
}
*/
}
section.hero {
height: 75%;
position: relative;
}
.hero-content {
position: absolute;
top: 50%;
transform: translateY(5%);
width: 100%;
}
.bgimg {
/* The image used */
background-image: url("bg.jpg");
/* Set a specific height */
height: 100%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.back .caption:before{
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
transform: scale(0,1);
}
.back .caption:after{
border-right: 1px solid #fff;
border-left: 1px solid #fff;
transform: scale(1,0);
}
.card.flipped .back .caption:before,
.card.flipped .back .caption:after {
opacity: .9;
transform: scale(1);
}
.back dl{
font-family:'Lato', Arial, sans-serif;
font-weight:300;
bottom:40px;
left:40px;
position: absolute;
opacity: 0;
transition: opacity .35s, transform .35s;
transition-delay: .85s;
transform: translate3d(-40px,0,0);
}
.card.flipped .back dl {
opacity: 1;
transform: translate3d(0,0,0);
}
dl dt{
float: left;
width: 60px;
overflow: hidden;
clear: left;
text-align: right;
font-weight:700;
}
dl dd{
margin-left: 80px;
text-align:left;
}
dl dd:before,
dl dd:after{
display: table;
content: " ";
}
dl dd:after{
clear: both;
}
.front:hover p {
opacity: 1;
transform: translate3d(0,0,0);
}
figure a{
z-index: 1000;
text-indent: 200%;
white-space: nowrap;
font-size: 0;
opacity: 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#media (min-width: 450px) {
.container{
left: 50%;
margin-left:-225px;
}
}
body {
background-color: #0F211E;
}
.recipe-card {
border-top: 15px solid lightblue;
border-bottom: 50px solid red;
background: #fff;
margin: 0 auto;
width: 90%;
max-width: 496px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
.card-top {
padding: 30px 15px;
display: flex;
}
.card-top .right {
padding-left: 20px;
}
<html>
<head>
<title>Portfolio</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</style>
</head>
<body class="news" >
<header>
<div class="nav">
<ul>
<li class="two"> <span>About</span></li>
<li class="three"><a class="active" href="#">Projects</a></li>
<li class="four">Skills</li>
</ul>
</div>
</header>
<section class="hero">
<div class="bgimg">
</div>
<div class="hero-content">
<div class="recipe-card">
<aside>
<div class="card-top">
<div class="left">
<img src="myAvatar.png" class="myavatar">
</div>
<div class="right">
<h1>Hamza Wahbi</h1>
<hr class="hrunder">
<h5 style="color:#8B8B8B " >Web Developer</h5>
<h1>Age: <font color="#8B8B8B">13</font></h1>
<h1>Email: <font color="#8B8B8B">fxgfnxngfx#gmail.com</font></h1>
<h1>Phone: <font color="#8B8B8B">0093836372</font></h1>
</div>
</div>
</aside>
<div style="position: fixed; bottom:0;">
<i class="fab fa-twitter fa-3x" style="color: black;"></i>
<i class="fab fa-instagram fa-3x" style="color: black;"></i>
<i class="fab fa-dribbble fa-3x" style="color: black;"></i>
<i class="fab fa-facebook-f fa-3x" style="color: black;"></i>
<i class="fab fa-snapchat-ghost fa-3x" style="color: black;"></i>
<i class="fab fa-google-plus-g fa-3x" style="color: black;"></i>
<i class="fab fa-youtube fa-3x" style="color: black;"></i>
<i class="fab fa-pinterest-p fa-3x" style="color: black;"></i>
</div>
</div>
</div><!-- .hero-content -->
</section>
</div>
</html>
body {
margin: 0;
padding: 0;
font-family: 'Oswald', sans-serif;
background-color: #0F211E;
}
.red {
color: red;
}
.icon-div{
background-color: red;
justify-content: space-evenly;
display: flex;
padding: 4px;
}
.icon-div i{
color: #fff;;
}
.underline {
text-decoration: underline;
}
.nav ul {
list-style: none;
background-color: #0F211E;
text-align: center;
padding: 0;
margin: 0;
}
.nav li {
font-size: 1.2em;
line-height: 40px;
height: 40px;
border-bottom: 1px solid #888;
}
.nav a {
text-decoration: none;
color: #fff;
display: block;
transition: .3s background-color;
text-transform: uppercase;
}
.hero-image {
height: 50%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
#media screen and (min-width: 600px) {
.nav li {
width: 120px;
border-bottom: none;
height: 50px;
line-height: 50px;
font-size: 1.4em;
}
/* Option 1 - Display Inline */
.nav li {
display: inline-block;
margin-right: -4px;
}
/* Options 2 - Float
.nav li {
float: left;
}
.nav ul {
overflow: auto;
width: 600px;
margin: 0 auto;
}
.nav {
background-color: #444;
}
*/
}
section.hero {
height: 75%;
position: relative;
}
.hero-content {
position: absolute;
top: 50%;
transform: translateY(5%);
width: 100%;
}
.bgimg {
/* The image used */
background-image: url("bg.jpg");
/* Set a specific height */
height: 100%;
/* Position and center the image to scale nicely on all screens */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
}
.back .caption:before {
border-top: 1px solid #fff;
border-bottom: 1px solid #fff;
transform: scale(0, 1);
}
.back .caption:after {
border-right: 1px solid #fff;
border-left: 1px solid #fff;
transform: scale(1, 0);
}
.card.flipped .back .caption:before,
.card.flipped .back .caption:after {
opacity: .9;
transform: scale(1);
}
.back dl {
font-family: 'Lato', Arial, sans-serif;
font-weight: 300;
bottom: 40px;
left: 40px;
position: absolute;
opacity: 0;
transition: opacity .35s, transform .35s;
transition-delay: .85s;
transform: translate3d(-40px, 0, 0);
}
.card.flipped .back dl {
opacity: 1;
transform: translate3d(0, 0, 0);
}
dl dt {
float: left;
width: 60px;
overflow: hidden;
clear: left;
text-align: right;
font-weight: 700;
}
dl dd {
margin-left: 80px;
text-align: left;
}
dl dd:before,
dl dd:after {
display: table;
content: " ";
}
dl dd:after {
clear: both;
}
.front:hover p {
opacity: 1;
transform: translate3d(0, 0, 0);
}
figure a {
z-index: 1000;
text-indent: 200%;
white-space: nowrap;
font-size: 0;
opacity: 0;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
#media (min-width: 450px) {
.container {
left: 50%;
margin-left: -225px;
}
}
.recipe-card {
border-top: 15px solid lightblue;
background: #fff;
margin: 0 auto;
width: 90%;
max-width: 496px;
border-top-left-radius: 5px;
border-top-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
.card-top {
padding: 30px 15px;
display: flex;
}
.card-top .right {
padding-left: 20px;
}
<html>
<head>
<title>Portfolio</title>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.0.13/css/all.css" integrity="sha384-DNOHZ68U8hZfKXOrtjWvjxusGo9WQnrNx2sqG0tfsghAvtVlRW3tvkXWZh58N9jp" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Oswald" rel="stylesheet">
<link rel="stylesheet" href="style.css">
</style>
</head>
<body class="news">
<header>
<div class="nav">
<ul>
<li class="two">
<span>About</span>
</li>
<li class="three"><a class="active" href="#">Projects</a></li>
<li class="four">Skills</li>
</ul>
</div>
</header>
<section class="hero">
<div class="bgimg">
</div>
<div class="hero-content">
<div class="recipe-card">
<aside>
<div class="card-top">
<div class="left">
<img src="myAvatar.png" class="myavatar">
</div>
<div class="right">
<h1>Hamza Wahbi</h1>
<hr class="hrunder">
<h5 style="color:#8B8B8B ">Web Developer</h5>
<h1>Age:
<font color="#8B8B8B">13</font>
</h1>
<h1>Email:
<font color="#8B8B8B">fxgfnxngfx#gmail.com</font>
</h1>
<h1>Phone:
<font color="#8B8B8B">0093836372</font>
</h1>
</div>
</div>
</aside>
<div class="icon-div">
<i class="fab fa-twitter fa-3x" ></i>
<i class="fab fa-instagram fa-3x" ></i>
<i class="fab fa-dribbble fa-3x" ></i>
<i class="fab fa-facebook-f fa-3x"></i>
<i class="fab fa-snapchat-ghost fa-3x" ></i>
<i class="fab fa-google-plus-g fa-3x" ></i>
<i class="fab fa-youtube fa-3x" ></i>
<i class="fab fa-pinterest-p fa-3x" ></i>
</div>
</div>
</div>
<!-- .hero-content -->
</section>
</div>
</html>