Currently I have them both in a Flexbox with space-between
and a 25% margin to the right of the content. It's a bit too hacky and doesn't work well with different sized windows
I also want the navbar to be sticky.
CodePudding user response:
Please try this method and give response. its better to use css grid for page responsiveness.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-size: 62.5%;
}
html,
body {
background-color: lightgray;
height: 100%;
width: 100vw;
}
.container {
min-height: 100%;
width: 100%;
background-color: inherit;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: repeat(5, max-content);
row-gap: 0.5rem;
}
.header {
grid-column: 1/-1;
background-color: #61988e;
}
.main {
grid-column: 1/-1;
grid-row: 2/3;
background-color: #a0b2a6;
}
.main2 {
grid-column: 1/-1;
grid-row: 3/4;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 0.5rem;
}
.feature {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
grid-gap: 0.5rem;
grid-column: 1/-1;
}
.item {
padding: 6rem;
color: white;
font-size: 2.5rem;
font-family: sans-serif;
text-transform: uppercase;
border-radius: 0.2rem;
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.25);
transition: all 0.2s;
}
.item--1 {
background-color: #a0b2a6;
}
.item--2 {
background-color: #360568;
}
.item--3 {
background-color: #586ba4;
}
.item--4 {
background-color: #87a878;
}
.item--5 {
background-color: teal;
}
.item--6 {
background-color: #8789c0;
}
.item:hover {
background-color: lightgray;
color: gray;
box-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.5);
}
.footer {
grid-column: 1/-1;
background-color: #493843;
}
/* Navigation */
@media only screen and (max-width: 41.875em) {
.navMenu a {
min-width: 100%;
text-align: center;
}
}
.navMenu a {
color: #f6f4e6;
text-decoration: none;
font-size: 1.2em;
text-transform: uppercase;
font-weight: 500;
display: inline-block;
width: 80px;
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.navMenu a:hover {
color: #fddb3a;
}
.navMenu .dot {
width: 6px;
height: 6px;
background: #fddb3a;
border-radius: 50%;
opacity: 0;
-webkit-transform: translateX(30px);
transform: translateX(30px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.navMenu a:nth-child(1):hover ~ .dot {
-webkit-transform: translateX(30px);
transform: translateX(30px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
opacity: 1;
}
.navMenu a:nth-child(2):hover ~ .dot {
-webkit-transform: translateX(110px);
transform: translateX(110px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
opacity: 1;
}
.navMenu a:nth-child(3):hover ~ .dot {
-webkit-transform: translateX(200px);
transform: translateX(200px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
opacity: 1;
}
.navMenu a:nth-child(4):hover ~ .dot {
-webkit-transform: translateX(285px);
transform: translateX(285px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
opacity: 1;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div >
<div >
<div >
<nav >
<a href="#">Home</a>
<a href="#">Blog</a>
<a href="#">Work</a>
<a href="#">About</a>
<div ></div>
</nav>
</div>
</div>
<div >
<div >box1</div>
<div >box2</div>
<div >box3</div>
<div >box4</div>
<div >box5</div>
<div >box6</div>
</div>
<div >
<div >footer</div>
</div>
</div>
</body>
</html>
CodePudding user response:
Please try this method and give response. its better to use css grid for page responsiveness. Please also check the page on various screen sizes.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-size: 62.5%;
}
html,
body {
background-color: lightgray;
height: 100%;
width: 100vw;
}
.container {
min-height: 100%;
width: 100%;
background-color: inherit;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: repeat(5, max-content);
row-gap: 0.5rem;
}
.header {
grid-column: 1/-1;
background-color: #61988e;
}
.main {
grid-column: 1/-1;
grid-row: 2/3;
background-color: #a0b2a6;
}
.main2 {
grid-column: 1/-1;
grid-row: 3/4;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-gap: 0.5rem;
}
.feature {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
grid-gap: 0.5rem;
grid-column: 1/-1;
}
.item {
padding: 6rem;
color: white;
font-size: 2.5rem;
font-family: sans-serif;
text-transform: uppercase;
border-radius: 0.2rem;
display: flex;
justify-content: center;
align-items: center;
box-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.25);
transition: all 0.2s;
}
.item--1 {
background-color: #a0b2a6;
}
.item--2 {
background-color: #360568;
}
.item--3 {
background-color: #586ba4;
}
.item--4 {
background-color: #87a878;
}
.item--5 {
background-color: teal;
}
.item--6 {
background-color: #8789c0;
}
.item:hover {
background-color: lightgray;
color: gray;
box-shadow: 0 1rem 4rem rgba(0, 0, 0, 0.5);
}
.footer {
grid-column: 1/-1;
background-color: #493843;
}
/* Navigation */
@media only screen and (max-width: 41.875em) {
.navMenu a {
min-width: 100%;
text-align: center;
}
}
.navMenu a {
color: #f6f4e6;
text-decoration: none;
font-size: 1.2em;
text-transform: uppercase;
font-weight: 500;
display: inline-block;
width: 80px;
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.navMenu a:hover {
color: #fddb3a;
}
.navMenu .dot {
width: 6px;
height: 6px;
background: #fddb3a;
border-radius: 50%;
opacity: 0;
-webkit-transform: translateX(30px);
transform: translateX(30px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
}
.navMenu a:nth-child(1):hover ~ .dot {
-webkit-transform: translateX(30px);
transform: translateX(30px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
opacity: 1;
}
.navMenu a:nth-child(2):hover ~ .dot {
-webkit-transform: translateX(110px);
transform: translateX(110px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
opacity: 1;
}
.navMenu a:nth-child(3):hover ~ .dot {
-webkit-transform: translateX(200px);
transform: translateX(200px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
opacity: 1;
}
.navMenu a:nth-child(4):hover ~ .dot {
-webkit-transform: translateX(285px);
transform: translateX(285px);
-webkit-transition: all 0.2s ease-in-out;
transition: all 0.2s ease-in-out;
opacity: 1;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div >
<div >
<div >
<nav >
<a href="#">Home</a>
<a href="#">Blog</a>
<a href="#">Work</a>
<a href="#">About</a>
<div ></div>
</nav>
</div>
</div>
<div >
<div >box1</div>
<div >box2</div>
<div >box3</div>
<div >box4</div>
<div >box5</div>
<div >box6</div>
</div>
<div >
<div >footer</div>
</div>
</div>
</body>
</html>