Reputation: 1
My navigation bar doesn't reach the left end of the screen, only the right end. This issue only came up when I tried to put a video as a background for the web page.
I tried setting the padding to 0, keeping in mind that that would put the text at the start and the end of the navbar, but it didn't work out.
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
}
#myVideo {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
}
.content {
position: fixed;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.5);
color: #f1f1f1;
width: 100vw;
height: 100vh;
padding: 20px;
box-sizing: border-box;
}
nav {
height: 80px;
background: #29282e;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0rem calc((100vw - 1300px) / 2);
user-select: none;
position: fixed;
top: 0;
width: 100%;
}
body {
margin: 0;
padding: 0;
}
.logo {
color: #b4b4b4;
font-size: 1.5rem;
font-weight: bold;
padding: 0 2rem;
animation: ripple 2s linear infinite alternate;
}
@keyframes ripple {
from {
color: #b4b4b4;
}
to {
color: #5f5f5f;
}
}
nav a {
text-decoration: none;
color: #5f5f5f;
padding: 0 1.5rem;
transition: all 0.5s;
}
nav a span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
nav a span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
nav a:hover span {
padding-right: 10px;
}
nav a:hover span:after {
opacity: 1;
right: 0;
}
.title {
user-select: none;
}
.title-container {
display: grid;
grid-template-columns: 1fr 1fr;
height: 95vh;
padding: 3rem calc((100vw - 1300px) / 2);
}
.column-left {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
color: #b4b4b4;
padding: 0rem 2rem;
}
.column-left h1 {
margin-bottom: 1rem;
font-size: 5rem;
}
.column-left p {
margin-bottom: 2rem;
font-size: 1.5rem;
line-height: 1.5;
}
button {
padding: 1rem 3rem;
font-size: 1rem;
border: none;
color: #5f5f5f;
background: none;
cursor: pointer;
border-radius: 50px;
transition: all 0.5s;
}
.button {
border-radius: 4px;
border: none;
color: #5f5f5f;
text-align: center;
font-size: 1.5rem;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.column-right {
display: flex;
justify-content: center;
align-items: center;
padding: 0rem 2rem;
}
.title-image {
width: 50%;
transition: transform 0.7s ease-out;
}
@media screen and (max-width: 768px) {
.title-container {
grid-template-columns: 1fr;
}
}
body::-webkit-scrollbar {
display: none;
}
<video autoplay muted loop id="myVideo">
<source src="media/background.mp4" type="video/mp4">
</video>
<div class="content" width="100%">
<nav>
<div class="logo">wonder〇</div>
<div class="nav-items">
<a href="/"><span>about</span></a>
<a href="/"><span>contact</span></a>
<a href="../login/login.html"><span>login</span></a>
</div>
</nav>
<section class="title">
<div class="title-container">
<div class="column-left">
<h1>wondersphere</h1>
<p>explore interactive and playful virtual museums.</p>
<button class="button"><span>get started</span></button>
</div>
<div class="column-right">
<img src="media/title_img.png" alt="" class="title-image" id="titleImage" />
</div>
</div>
</section>
</div>
Upvotes: 0
Views: 46
Reputation: 1747
You need to remove the padding in .content:20px
* {
box-sizing: border-box;
margin: 0;
padding: 0;
font-family: Cambria, Cochin, Georgia, Times, 'Times New Roman', serif;
}
#myVideo {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
}
.content {
position: fixed;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.5);
color: #f1f1f1;
width: 100vw;
height: 100vh;
/* padding: 20px; */
box-sizing: border-box;
}
nav {
height: 80px;
background: #29282e;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0rem calc((100vw - 1300px) / 2);
user-select: none;
position: fixed;
top: 0;
min-width: 100%;
}
body {
margin: 0;
padding: 0;
}
.logo {
color: #b4b4b4;
font-size: 1.5rem;
font-weight: bold;
padding: 0 2rem;
animation: ripple 2s linear infinite alternate;
}
@keyframes ripple {
from {
color: #b4b4b4;
}
to {
color: #5f5f5f;
}
}
nav a {
text-decoration: none;
color: #5f5f5f;
padding: 0 1.5rem;
transition: all 0.5s;
}
nav a span{
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
nav a span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
nav a:hover span {
padding-right: 10px;
}
nav a:hover span:after {
opacity: 1;
right: 0;
}
.title {
user-select: none;
}
.title-container {
display: grid;
grid-template-columns: 1fr 1fr;
height: 95vh;
padding: 3rem calc((100vw - 1300px) / 2);
}
.column-left {
display: flex;
flex-direction: column;
justify-content: center;
align-items: flex-start;
color: #b4b4b4;
padding: 0rem 2rem;
}
.column-left h1 {
margin-bottom: 1rem;
font-size: 5rem;
}
.column-left p {
margin-bottom: 2rem;
font-size: 1.5rem;
line-height: 1.5;
}
button {
padding: 1rem 3rem;
font-size: 1rem;
border: none;
color: #5f5f5f;
background: none;
cursor: pointer;
border-radius: 50px;
transition: all 0.5s;
}
.button {
border-radius: 4px;
border: none;
color: #5f5f5f;
text-align: center;
font-size: 1.5rem;
padding: 20px;
width: 200px;
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
.button span {
cursor: pointer;
display: inline-block;
position: relative;
transition: 0.5s;
}
.button span:after {
content: '\00bb';
position: absolute;
opacity: 0;
top: 0;
right: -20px;
transition: 0.5s;
}
.button:hover span {
padding-right: 25px;
}
.button:hover span:after {
opacity: 1;
right: 0;
}
.column-right{
display: flex;
justify-content: center;
align-items: center;
padding: 0rem 2rem;
}
.title-image{
width: 50%;
transition: transform 0.7s ease-out;
}
@media screen and (max-width: 768px) {
.title-container {
grid-template-columns: 1fr;
}
}
body::-webkit-scrollbar {
display: none;
}
<video autoplay muted loop id="myVideo">
<source src="media/background.mp4" type="video/mp4">
</video>
<div class="content" width="100%">
<nav>
<div class="logo">wonder〇</div>
<div class="nav-items">
<a href="/"><span>about</span></a>
<a href="/"><span>contact</span></a>
<a href="../login/login.html"><span>login</span></a>
</div>
</nav>
<section class="title">
<div class="title-container">
<div class="column-left">
<h1>wondersphere</h1>
<p>explore interactive and playful virtual museums.</p>
<button class="button"><span>get started</span></button>
</div>
<div class="column-right">
<img src="https://picsum.photos/seed/picsum/200/300" alt="" class="title-image" id="titleImage"/>
</div>
</div>
</section>
</div>
Upvotes: 2