This question already has answers here:
In CSS Flexbox, why are there no "justify-items" and "justify-self" properties?
(6 answers)
Closed 2 years ago.
I am trying to have a logo on the left of the div and the nav on the right side of the div, but I can't seem to get the nav to move to the right.
.full {
background-color: black;
color: white;
width: 300px;
height: 400px;
border-radius: 20px;
transition: 1s ease;
}
.autofill {
padding: 10px;
}
.topbar {
overflow: hidden;
width: 100%;
height: 50px;
background-color: #131218;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
display: flex;
align-items: center;
}
.body {
display: block;
width: 100%;
height: 330px;
background-color: blue;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
}
img {
height: 50px;
padding: 5px;
border-radius: 200px;
float: left;
will-change: transform;
animation: logofloat 1s ease-in-out infinite alternate;
}
#keyframes logofloat {
from {
transform: translateY(5px);
}
to {
transform: translateY(15px);
}
}
a {
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
align-items: center;
float: left;
display: block;
margin-right: 10px;
background-color: #25242B;
text-align: center;
text-decoration: none;
border-radius: 5px;
}
i {
padding: 5px;
color: #4D4A58;
}
a:hover:not(.active) {
background-color: grey;
}
a:not(.active) {
color: white;
}
.active {
background-image: linear-gradient(to right, #5433FF, #20BDFF, #6FB1FC);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="full">
<div class="autofill" id="background">
<div class="topbar">
<img class="logo" src="/icons/glacier.png">
<div class="nav">
<i class="fa fa-fw fa-align-justify"></i>
<i class="fa fa-fw fa-wifi"></i>
<i class="fa fa-fw fa-user"></i>
<a class="active" href="#"><i class="fa fa-fw fa-gear"></i></a>
</div>
</div>
<div class="body"></div>
</div>
Here is my fiddle for the project: https://jsfiddle.net/70wzxsL5/
How can I fix the aligning of the logo and nav in the division?
Add this justify-content: space-between; on .topbar
.topbar {
overflow: hidden;
width: 100%;
height: 50px;
background-color: #131218;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
display: flex;
align-items: center;
justify-content: space-between;
}
https://jsfiddle.net/lalji1051/fv1ju8cw/2/
Add justify-content: space-between; to .topbar:
.full {
background-color: black;
color: white;
width: 300px;
height: 400px;
border-radius: 20px;
transition: 1s ease;
}
.autofill {
padding: 10px;
}
.topbar {
overflow: hidden;
width: 100%;
height: 50px;
background-color: #131218;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
display: flex;
align-items: center;
justify-content: space-between; /* Here */
}
.body {
display: block;
width: 100%;
height: 330px;
background-color: blue;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 20px;
}
img {
height: 50px;
padding: 5px;
border-radius: 200px;
float: left;
will-change: transform;
animation: logofloat 1s ease-in-out infinite alternate;
}
#keyframes logofloat {
from {
transform: translateY(5px);
}
to {
transform: translateY(15px);
}
}
a {
display: flex;
flex-direction: column;
justify-content: center;
position: relative;
align-items: center;
float: left;
display: block;
margin-right: 10px;
background-color: #25242B;
text-align: center;
text-decoration: none;
border-radius: 5px;
}
i {
padding: 5px;
color: #4D4A58;
}
a:hover:not(.active) {
background-color: grey;
}
a:not(.active) {
color: white;
}
.active {
background-image: linear-gradient(to right, #5433FF, #20BDFF, #6FB1FC);
}
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="full">
<div class="autofill" id="background">
<div class="topbar">
<img class="logo" src="/icons/glacier.png">
<div class="nav">
<i class="fa fa-fw fa-align-justify"></i>
<i class="fa fa-fw fa-wifi"></i>
<i class="fa fa-fw fa-user"></i>
<a class="active" href="#"><i class="fa fa-fw fa-gear"></i></a>
</div>
</div>
<div class="body"></div>
</div>
Related
On hover I would like each icon to have an underline but instead all items are get an underline. I'm not sure how to get it to apply for only the icon that is being hovered.
I want something like this
hovered icon
but instead it looks like this
my hovered image
.top-bar {
display: flex;
align-items: center;
padding: 1.25rem 2rem;
}
.menu-btn {
display: flex;
align-items: center;
justify-content: center;
height: 2.5rem;
width: 2.5rem;
}
.fa-bars {
font-size: 2.5rem;
}
.logo {
margin-left: 1rem;
}
.logo img {
display: block;
width: 10rem;
height: 1.66rem;
color: #000;
}
.controls {
position: relative;
font-size: 2rem;
margin-left: auto;
margin-right: 3rem;
}
.controls-icon::after {
content: "";
position: absolute;
left: 0;
bottom: -0.5rem;
height: 0.2rem;
width: 100%;
background-color: #000;
transition: all 0.5s;
transform: scaleX(0);
}
.controls-icon:hover::after {
transform: scale(1);
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet"/>
<div class="top-bar container">
<div class="menu-btn"><i class="fa-solid fa-bars"></i></div>
<div class="logo"><img src="assets/img/logo.svg" alt="logo" /></div>
<div class="controls">
<i class="fa-solid fa-magnifying-glass controls-icon"></i>
<i class="fa-solid fa-play controls-icon"></i>
<i class="fa-solid fa-user controls-icon"></i>
</div>
</div>
set position of i relative. like this
i{ position:relative; }
.top-bar {
display: flex;
align-items: center;
padding: 1.25rem 2rem;
}
.menu-btn {
display: flex;
align-items: center;
justify-content: center;
height: 2.5rem;
width: 2.5rem;
}
.fa-bars {
font-size: 2.5rem;
}
.logo {
margin-left: 1rem;
}
.logo img {
display: block;
width: 10rem;
height: 1.66rem;
color: #000;
}
.controls {
position: relative;
font-size: 2rem;
margin-left: auto;
margin-right: 3rem;
}
.controls-icon::after {
content: "";
position: absolute;
left: 0;
bottom: -0.5rem;
height: 0.2rem;
width: 100%;
background-color: #000;
transition: all 0.5s;
transform: scaleX(0);
}
.controls-icon:hover::after {
transform: scale(1);
}
i{
position:relative;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" rel="stylesheet"/>
<div class="top-bar container">
<div class="menu-btn"><i class="fa-solid fa-bars"></i></div>
<div class="logo"><img src="assets/img/logo.svg" alt="logo" /></div>
<div class="controls">
<i class="fa-solid fa-magnifying-glass controls-icon"></i>
<i class="fa-solid fa-play controls-icon"></i>
<i class="fa-solid fa-user controls-icon"></i>
</div>
</div>
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)
}
I'm not a front-end developer in fact I've basically copy-pasted an open-source nav bar and pasted it on my project editing the colors and id tags.
For some reason on Chrome, Edge, Opera the nav bar works perfectly while in Mozilla looks very buggy (see screenshot as I don't know how to describe it - left looks ok, right looks buggy) and I do not know why. Below is my code (don't mind the Django code injected) :
HTML
<nav id="main_nav" class="sidebar close"> <!-- cloe class to keep it close -->
<header>
<div class="image-text">
<span class="image">
<img src="logo.png" alt="">
</span>
<div class="text logo-text">
<span class="name">The Groove Cartel</span>
<span class="profession">Playlist Manager</span>
</div>
</div>
<i class='bx bx-chevron-right toggle'></i>
</header>
<div class="menu-bar">
<div class="menu">
<ul class="menu-links">
<li class="nav-link">
<a href="/">
<i class='bx bx-home-alt icon' ></i>
<span class="text nav-text">Home</span>
</a>
</li>
</ul>
</div>
<div class="bottom-content">
{% if user.is_authenticated %}
<li class="">
<a href="{% url 'account' user.username%}">
<i class='bx bxs-user-detail icon' ></i>
<span class="text nav-text">My profile</span>
</a>
</li>
{% endif %}
<li class="mode">
<div class="sun-moon">
<i class='bx bx-moon icon moon'></i>
<i class='bx bx-sun icon sun'></i>
</div>
<span class="mode-text text">Dark mode</span>
<div class="toggle-switch">
<span class="switch"></span>
</div>
</li>
</div>
</div>
</nav>
CSS
/* ===== Sidebar ===== */
.sidebar{
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 280px;
padding: 10px 14px;
background: var(--sidebar-color);
transition: var(--tran-05);
z-index: 100;
}
.sidebar.close{
width: 88px;
}
/* ===== Reusable code - Here ===== */
.menu-links{
padding-left: 0px !important;
}
.sidebar li{
height: 50px;
list-style: none;
display: flex;
align-items: center;
margin-top: 10px;
padding: 0px !important;
}
.sidebar header .image,
.sidebar .icon{
min-width: 60px;
border-radius: 6px;
}
.sidebar .icon{
min-width: 60px;
border-radius: 6px;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
}
.sidebar .text,
.sidebar .icon{
color: var(--text-color);
transition: var(--tran-03);
}
.sidebar .text{
font-size: 17px;
font-family: Poppins-Medium;
white-space: nowrap;
opacity: 1;
}
.sidebar.close .text{
opacity: 0;
}
/* =========================== */
.sidebar header{
position: relative;
}
.sidebar header .image-text{
display: flex;
align-items: center;
}
.sidebar header .logo-text{
display: flex;
flex-direction: column;
}
header .image-text .name {
margin-top: 2px;
font-size: 18px;
font-family: Poppins-SemiBold;
}
header .image-text .profession{
font-size: 16px;
margin-top: -2px;
display: block;
}
.sidebar header .image{
display: flex;
align-items: center;
justify-content: center;
}
.sidebar header .image img{
width: 40px;
border-radius: 6px;
}
.sidebar header .toggle{
position: absolute;
top: 50%;
right: -25px;
transform: translateY(-50%) rotate(180deg);
height: 25px;
width: 25px;
background-color: var(--primary-color);
color: var(--sidebar-color);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 22px;
cursor: pointer;
transition: var(--tran-05);
}
body.dark .sidebar header .toggle{
color: var(--text-color);
}
.sidebar.close .toggle{
transform: translateY(-50%) rotate(0deg);
}
.sidebar .menu{
margin-top: 40px;
}
.sidebar li.search-box{
border-radius: 6px;
background-color: var(--primary-color-light);
cursor: pointer;
transition: var(--tran-05);
}
.sidebar li.search-box input{
height: 100%;
width: 100%;
outline: none;
border: none;
background-color: var(--primary-color-light);
color: var(--text-color);
border-radius: 6px;
font-size: 17px;
font-family: Poppins-Medium;
transition: var(--tran-05);
}
.sidebar li a{
list-style: none;
height: 100%;
background-color: transparent;
display: flex;
align-items: center;
height: 100%;
width: 100%;
border-radius: 6px;
text-decoration: none;
transition: var(--tran-03);
}
.sidebar li a:hover{
background-color: var(--primary-color);
}
.sidebar li a:hover .icon,
.sidebar li a:hover .text{
color: var(--sidebar-color);
}
body.dark .sidebar li a:hover .icon,
body.dark .sidebar li a:hover .text{
color: var(--text-color);
}
.sidebar .menu-bar{
height: calc(100% - 55px);
display: flex;
flex-direction: column;
justify-content: space-between;
overflow-y: scroll;
}
.menu-bar::-webkit-scrollbar{
display: none;
}
.sidebar .menu-bar .mode{
border-radius: 6px;
background-color: var(--primary-color-light);
position: relative;
transition: var(--tran-05);
}
.menu-bar .mode .sun-moon{
height: 50px;
width: 60px;
}
.mode .sun-moon i{
position: absolute;
}
.mode .sun-moon i.sun{
opacity: 0;
}
body.dark .mode .sun-moon i.sun{
opacity: 1;
}
body.dark .mode .sun-moon i.moon{
opacity: 0;
}
.menu-bar .bottom-content .toggle-switch{
position: absolute;
right: 0;
height: 100%;
min-width: 60px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 6px;
cursor: pointer;
}
.toggle-switch .switch{
position: relative;
height: 22px;
width: 40px;
border-radius: 25px;
background-color: var(--toggle-color);
transition: var(--tran-05);
}
.switch::before{
content: '';
position: absolute;
height: 15px;
width: 15px;
border-radius: 50%;
top: 50%;
left: 5px;
transform: translateY(-50%);
background-color: var(--sidebar-color);
transition: var(--tran-04);
}
body.dark .switch::before{
left: 20px;
}
.home{
position: absolute;
top: 0;
top: 0;
left: 280px;
height: 100vh;
width: calc(100% - 280px);
background-color: var(--body-color);
transition: var(--tran-05);
}
.home .text{
font-size: 30px;
font-family: Poppins-Medium;
color: var(--text-color);
padding: 12px 60px;
}
.sidebar.close ~ .home{
left: 78px;
height: 100vh;
width: calc(100% - 78px);
}
body.dark .home .text{
color: var(--text-color);
}
I did try a few suggestions that I found online but none of them worked. I tried to fix the footer at the bottom using Flexbox layout but it didn't work, when I add more cards they overflow and go past the footer. I also followed this answer and added the two properties to my main page, but the problem is card-container does not expand to fit the content (it display has to flex) and only the main div (for whole page) does.
Do you have any suggestions or workarounds for this issue?
/* RESET */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #ebecf0;
font-family: "Open Sans", sans-serif;
min-height: 100vh;
}
body a {
text-decoration: none;
color: #172b4d;
}
body h1 {
font-family: "Song Myung", serif;
}
/* DEFAULT STYLE */
:root {
font-size: 16px;
--card-img-height: 200px;
}
.card-container {
width: 100%;
height: 100vh;
display: flex;
flex-flow: row wrap;
justify-content: center;
align-items: center;
transition: all 200ms ease-in-out;
}
.card {
align-self: flex-start;
position: relative;
width: 325px;
min-width: 275px;
margin: 1.25rem 0.75rem;
background: white;
transition: all 300ms ease-in-out;
}
.card .card-img {
visibility: hidden;
width: 100%;
height: var(--card-img-height);
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
}
.card .card-img-hovered {
--card-img-hovered-overlay: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0));
transition: all 350ms ease-in-out;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
width: 100%;
position: absolute;
height: var(--card-img-height);
top: 0;
}
.card .card-info {
position: relative;
padding: 0.75rem 1.25rem;
transition: all 200ms ease-in-out;
}
.card .card-info .card-about {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.75rem 0;
transition: all 200ms ease-in-out;
}
.card .card-info .card-about .card-tag {
width: 60px;
max-width: 100px;
padding: 0.2rem 0.5rem;
font-size: 12px;
text-align: center;
text-transform: uppercase;
letter-spacing: 1px;
background: #505f79;
color: #fff;
}
.card .card-info .card-about .card-tag.tag-news {
background: #36b37e;
}
.card .card-info .card-about .card-tag.tag-deals {
background: #ffab00;
}
.card .card-info .card-about .card-tag.tag-politics {
width: 71px;
background: #ff5630;
}
.card .card-info .card-title {
z-index: 10;
font-size: 1.5rem;
padding-bottom: 0.75rem;
transition: all 350ms ease-in-out;
}
.card .card-info .card-creator {
padding-bottom: 0.75rem;
transition: all 250ms ease-in-out;
}
.card:hover {
cursor: pointer;
box-shadow: 0px 15px 35px rgba(227, 252, 239, 0.1), 0px 5px 15px rgba(0, 0, 0, 0.07);
transform: scale(1.025);
}
.card:hover .card-img-hovered {
--card-img-hovered-overlay: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.65));
height: 100%;
}
.card:hover .card-about, .card:hover .card-creator {
opacity: 0;
}
.card:hover .card-info {
background-color: transparent;
}
.card:hover .card-title {
color: #ebecf0;
transform: translate(0, 40px);
}
.card-1 .card-img, .card-1 .card-img-hovered {
background-image: var(--card-img-hovered-overlay), url(https://source.unsplash.com/Qm_n6aoYzDs);
}
.card-2 .card-img, .card-2 .card-img-hovered {
background-image: var(--card-img-hovered-overlay), url(https://source.unsplash.com/C-v1p2DTakA);
}
.card-3 .card-img, .card-3 .card-img-hovered {
background-image: var(--card-img-hovered-overlay), url(https://source.unsplash.com/V0L1LH7qWOQ);
}
.card-4 .card-img, .card-4 .card-img-hovered {
background-image: var(--card-img-hovered-overlay), url(https://source.unsplash.com/zAi2Is48-MA);
}
.page-footer{
height: 3rem;
background: #cddc39;
color: var(--primary-900);
display: flex;
align-items: center;
justify-content: center;
letter-spacing: var(--letterSpacing);
}
.page-footer p{
font-size: 0.8rem;
margin-bottom: 0;
}
.footer-logo, .page-footer a{
color: #0f5132;
}
.columned-footer {
display: flex;
align-items: center;
justify-content: space-around;
padding-inline-start: 0.1rem;
background-color: rgb(70, 66, 66);
height: 8rem;
color: rgb(243, 240, 235);
width: 100%;
}
.social {
display: flex;
align-items: center;
justify-content: center;
background-color: rgb(70, 66, 66);
height: 5rem;
border-top: 0.1rem solid;
border-top-color: rgb(102, 99, 99);
}
.social_footer_ul {
display:table;
margin:10px auto 0 auto;
list-style-type:none;
padding: 10px 15px;
}
.social_footer_ul li {
font-size: 30px;
padding-left:20px;
float:left;
}
.social_footer_ul li a {
padding:15px;
color: #e2e0ff;
}
.social_footer_ul li a:hover {
opacity: 0.2px;
color: #cddc39;
}
.social_footer_ul li i {
width:20px;
height:20px;
text-align:center;
}
.footer-container {
-webkit-column-count: 2;
-moz-column-count: 2;
column-count: 2;
display: grid;
gap: 10rem;
grid-template-columns: 1fr 1fr;
padding-inline-start: 2rem;
}
.line {
height: 2px;
width: 80px;
background-color: #cddc39;
margin: 3px 0px;
padding: 0px;
}
.streak {
height:2px;
width: 300px;
background-color: #acb930;
display: block;
margin: 5px 50px;
padding: 1px;
}
.address {
float: right;
}
.tel {
float: left;
}
#media screen and (min-width: 748px) {
.footer-container{
width: 100%;
padding-inline-start: 5rem;
}
}
body {
display: flex;
flex-direction: column;
min-height: 100vh;
}
body > *{
flex-grow: 0;
}
body > nav + .card-container {
flex-grow: 1;
}
<div class="card-container">
<div class="card card-1">
<div class="card-img"></div>
<a href="" class="card-link">
<div class="card-img-hovered"></div>
</a>
<div class="card-info">
<div class="card-about">
<a class="card-tag tag-news">NEWS</a>
<div class="card-time">6/11/2018</div>
</div>
<h1 class="card-title">There have been big Tesla accident at New Jersey</h1>
<div class="card-creator">by Sardorbek Usmonov</div>
</div>
</div>
<div class="card card-2">
<div class="card-img"></div>
<a href="" class="card-link">
<div class="card-img-hovered"></div>
</a>
<div class="card-info">
<div class="card-about">
<a class="card-tag">Tech</a>
<div class="card-time">6/07/2018</div>
</div>
<h1 class="card-title">Samsung laptops is exploding again</h1>
<div class="card-creator">by Tyler Platt</div>
</div>
</div>
<div class="card card-3">
<div class="card-img"></div>
<a href="" class="card-link">
<div class="card-img-hovered"></div>
</a>
<div class="card-info">
<div class="card-about">
<a class="card-tag tag-deals">Deals</a>
<div class="card-time">5/27/2018</div>
</div>
<h1 class="card-title">Apple is having big Sale for the first time</h1>
<div class="card-creator">by Timur Mirzoyev</div>
</div>
</div>
<div class="card card-4">
<div class="card-img"></div>
<a href="" class="card-link">
<div class="card-img-hovered"></div>
</a>
<div class="card-info">
<div class="card-about">
<a class="card-tag tag-politics">Politics</a>
<div class="card-time">5/20/2018</div>
</div>
<h1 class="card-title">Net-Nutrality is coming to its end</h1>
<div class="card-creator">by Gregoy Trem</div>
</div>
</div>
</div>
<footer>
<div class="social">
<ul class="social_footer_ul">
<li><i class="fab fa-facebook-f"></i></li>
<li><i class="fab fa-twitter"></i></li>
<li><i class="fab fa-telegram"></i></li>
<li><i class="fab fa-instagram"></i></li>
</ul>
</div>
<div class="page-footer">
<p>
© <span id="date"></span>
<span class="footer-logo"></span>
by me
</p>
</div>
</footer>
.card-container needs min-height: 100vh; instead of height: 100vh;
I am currently building a dashboard for a project I'm workig on - as i didn't touch css for years now i kinda struggle with a side Nav Bar.
<div id="nav">
<div id="nav-wrapper">
<ul>
<li><i class="fas fa-home"></i></li>
<li><i class="fas fa-home"></i></li>
<li><i class="fas fa-home"></i></li>
<li><i class="fas fa-home"></i></li
<li><i class="fas fa-home"></i></li>
</ul>
</div> <!--End of nav-wrapper-->
</div> <!--End of nav-->
#nav{
width: 10%;
height: 100%;
background-color: #273138;
position: fixed;
a{
color: white;
text-decoration: none;
}
#nav-wrapper{
padding: 30px 0px 30px;
font-size: 2em;
}
}
This is what my navbar basicaly looks like. I want the elements centered and rounded - similarly to the style discord uses for it's server list (Link)
Any idea how i can build this in css?
I have created a solution in JSFiddle
JSFiddle
* {
padding: 0;
margin: 0;
}
html, body {
height: 100%;
}
#nav {
width: 10%;
height: 100%;
background-color: #273138;
position: fixed;
}
#nav-wrapper {
font-size: 1.5em;
}
#nav-wrapper ul {
display: block;
}
#nav-wrapper li {
list-style: none;
background-color: #d24d57;
height: 50px;
width: 50px;
margin: 10px auto;
border-radius: 100%;
text-align: center;
line-height: 50px;
}
#nav-wrapper li a {
color: white;
text-decoration: none;
}
I have made something, does it looks like what you want?
body{
margin: 0px;
}
#nav {
height: 100%;
width: 10%;
background-color: #273138;
position: fixed;
}
#nav-wrapper{
display: flex;
justify-content: center;
align-items: center;
}
ul{
list-style-type: none;
margin: 0px;
padding: 0px;
}
li{
margin-top: 2px;
background-color: orange;
border-radius: 100%;
padding: 5px;
font-size: 2em;
}
a{
color: white;
text-decoration: none;
}
plus, this is not recommended to nest classes
I hope this can help you.
body {
background-color: #36393e;
}
#nav {
width: auto;
height: 100%;
background-color: #1f2125;
position: fixed;
}
#nav ul {
list-style: none;
padding-left: 0;
margin: 0;
position: relative;
padding-top: 20px;
padding-bottom: 20px;
}
#nav ul::before {
position: absolute;
content: '';
top: 15px;
left: 25%;
background-color: #2E3136;
width: 50%;
height: 1px;
}
#nav ul::after {
position: absolute;
content: '';
bottom: 15px;
left: 25%;
background-color: #2E3136;
width: 50%;
height: 1px;
}
#nav ul li {
display: flex;
flex-direction: column;
justify-items: center;
align-items: center;
margin: 10px;
}
#nav a {
background-color: #2E3136;
border-radius: 100%;
padding: .5em;
color: white;
text-decoration: none;
width: 30px;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
}
#nav a {
animation: hover-out 0.6s ease;
}
#nav a:hover, #nav a:focus {
animation: hover-in 0.8s ease forwards;
}
#nav a i {
font-size: 1em;
}
#nav #nav-wrapper {
font-size: 2em;
}
#keyframes hover-in {
0% {
border-radius: 100%;
background-color: #2E3136;
}
40% {
border-radius: 12px;
}
70% {
border-radius: 16.7px;
}
80% {
background-color: #7289DA;
}
100% {
border-radius: 15px;
background-color: #7289DA;
}
}
#keyframes hover-out {
0% {
border-radius: 15px;
background-color: #7289DA;
}
45% {
border-radius: 70%;
background-color: #2E3136;
}
65% {
border-radius: 70%;
}
75% {
border-radius: 75%;
}
100% {
border-radius: 100%;
}
}
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<div id="nav">
<div id="nav-wrapper">
<ul>
<li><i class="fa fa-home"></i></li>
<li><i class="fa fa-home"></i></li>
<li><i class="fa fa-home"></i></li>
<li><i class="fa fa-home"></i></li>
<li><i class="fa fa-home"></i></li>
</ul>
</div> <!--End of nav-wrapper-->
</div> <!--End of nav-->