CSS Sliver on Nav animation - html

So as I was updating my design website, I encountered a problem (?). It's hard to quantify because it shows at different times when I resize my browser. But I can see it when it's full screen on my laptop.
In my navigation, I have a right to left animation. The background color is white and it slides to a dark gray. But, when I'm full screen in Chrome, there is a small sliver on the right of "HIRE ME" (this link isn't currently functional btw). Like I said before, when I re-size my screen it flashes and disappears not only of the "HIRE ME," but on all of the nav links.
I don't know if this is some semantic code problem or merely the browser compatibility. Any assistance would be great. I'd attached a bit of the code, although the issue doesn't show there, but my website.
WARNING! I am a graphic designer by trade, so my mostly self-taught code is probably uglier than mud on a white picket fence to most. If you have any suggestions for semantics, I would definitely appreciate that as well. Thank you in advance!
www.kelsiewilson.co/
#import url(https://fonts.googleapis.com/css?family=Playfair+Display:400,900);
#import url(https://fonts.googleapis.com/css?family=Fira+Sans+Extra+Condensed:400,700);
.yellowline {
width: 100%;
height: 8px;
background-color: #FFC45C;
}
.outline {
width: 20%;
padding: 130px 20%;
margin: -10px 0 0 31.5%;
border: .75px solid #FFC45C;
}
h1.name {
margin-left: 26%;
font-size: 72px;
font-family: 'Playfair Display', serif;
letter-spacing: 1.2px;
font-weight: 900;
margin-top: -170px;
color: #2B343E;
}
nav {
margin: 0 auto;
display: block;
text-align: center;
padding-bottom: 100px;
padding-top: 10px;
}
nav ul {
display: inline-block;
list-style-type: none;
}
nav ul li {
float: left;
margin: 0 auto;
clear: float;
}
nav ul li.active a {
color: #2B343E;
}
nav ul li.active:hover a {
color: white;
}
nav ul li a {
font-size: 16px;
font-family: 'Fira Sans Extra Condensed', sans-serif;
font-weight: 400;
color: #d3d3d3;
width: 100px;
padding: 4px 16px;
margin: 0 50px;
background: #fff;
background: linear-gradient(to left, #2B343E 50%, white 50%);
background-size: 200% 100%;
background-position: left bottom;
margin-left: 10px;
transition: all 2s ease;
text-decoration: none;
border-right: solid 0px #6b5d53;
}
nav li:hover a {
font-family: 'Fira Sans Extra Condensed';
font-weight: 400;
background-position: right bottom;
color: white;
}
<div class="yellowline">
</div>
<div class="outline">
</div>
<header>
<h1 class="name">Kelsie Wilson</h1>
</header>
<nav>
<ul>
<li class="active">WORK</li>
<li>ABOUT</li>
<li>HIRE ME</li>
</ul>
<div class="keepopen"></div>
</nav>

The problem here is, that you're using the background position for your animation. (I'm not entirely sure what exactly is the reason why it's shown, but i would assume that it's because chrome renders the background a pixel too far to the left.)
But, nonetheless, it's bad pratice to animate the background property since it causes the browser to repaint the page.
One solution to solve this could be to use a pseudo element and transform: scale() for the animation:
nav ul li a::after {
content: "";
position: absolute;
background: #2B343E;
width: 100%;
height: 100%;
left: 0;
top: 0;
transform: scaleX(0); // scales the width down to 0
transform-origin: 100% 100%; //set transform origin to right-most,
//otherwise it would scale from the center of the button
transition: all 2s ease; // pseudo element needs its own transition
z-index: -1; // set z-index to -1 so that the link text is visible
}
and then for the hover:
nav li:hover a:after {
transform: scaleX(1); // scale the width to normal size
}
if you do it this way, you also need to add
position: relative;
to your a
Here's some further reading about cheap and not so cheap animations to help you understand why i chose to animate with transform: scale.
Here's the complete updated code, hope this helps :) :
#import url(https://fonts.googleapis.com/css?family=Playfair+Display:400,900);
#import url(https://fonts.googleapis.com/css?family=Fira+Sans+Extra+Condensed:400,700);
.yellowline {
width: 100%;
height: 8px;
background-color: #FFC45C;
}
.outline {
width: 20%;
padding: 130px 20%;
margin: -10px 0 0 31.5%;
border: .75px solid #FFC45C;
}
h1.name {
margin-left: 26%;
font-size: 72px;
font-family: 'Playfair Display', serif;
letter-spacing: 1.2px;
font-weight: 900;
margin-top: -170px;
color: #2B343E;
}
nav {
margin: 0 auto;
display: block;
text-align: center;
padding-bottom: 100px;
padding-top: 10px;
}
nav ul {
display: inline-block;
list-style-type: none;
}
nav ul li {
float: left;
margin: 0 auto;
clear: float;
}
nav ul li.active a {
color: #2B343E;
}
nav ul li.active:hover a {
color: white;
}
nav ul li a {
position: relative; //<-- added position: relative
font-size: 16px;
font-family: 'Fira Sans Extra Condensed', sans-serif;
font-weight: 400;
color: #d3d3d3;
width: 100px;
padding: 4px 16px;
margin: 0 50px;
margin-left: 10px;
transition: all 2s ease;
text-decoration: none;
border-right: solid 0px #6b5d53;
}
nav ul li a::after {
content: "";
position: absolute;
background: #2B343E;
width: 100%;
height: 100%;
left: 0;
top: 0;
transform: scaleX(0);
transform-origin: 100% 100%;
transition: all 2s ease;
z-index: -1;
}
nav li:hover a {
font-family: 'Fira Sans Extra Condensed';
font-weight: 400;
color: white;
}
nav li:hover a:after {
transform: scaleX(1);
}
<div class="yellowline">
</div>
<div class="outline">
</div>
<header>
<h1 class="name">Kelsie Wilson</h1>
</header>
<nav>
<ul>
<li class="active">WORK</li>
<li>ABOUT</li>
<li>HIRE ME</li>
</ul>
<div class="keepopen"></div>
</nav>

Related

text stuckt to the header? [duplicate]

This question already has answers here:
CSS margin terror; Margin adds space outside parent element [duplicate]
(7 answers)
Closed 4 years ago.
I’m trying to move my text to the middle of my header on the image but as soon as I move it the whole header follows. Could someone try to help me solve this issue? As you see I’m trying to make it using margin-top but when I implement this the header follows. I have closed all the divs that affects the image.
html, body {
margin: 0;
padding: 0;
text-align: center;
width: 100%;
}
body {
font-family: 'Josefin Sans', sans-serif;
text-align: center;
}
header {
width: 100%;
height: 400px;
background: url(/assets/image/tjanst.jpg) no-repeat 50% 50%;
background-size: cover;
}
.content {
width: 94%;
margin: 4em auto;
font-size: 20px;
line-height: 30px;
text-align: justify;
}
.logo {
line-height: 60px;
position: fixed;
float: left;
margin: 16px 46px;
color: #fff;
font-weight: bold;
font-size: 20px;
letter-spacing: 2px;
}
nav {
position: fixed;
width: 100%;
line-height: 60px;
z-index: 10;
}
nav ul {
line-height: 60px;
list-style: none;
background: rgba(0, 0, 0, 0);
overflow: hidden;
color: #fff;
text-align: right;
margin: 0;
padding-right: 40px;
transition: 1s;
}
nav.black ul {
background: #000;
padding: 16px 40px;
}
nav ul li {
display: inline-block;
padding: 16px 40px;
}
.move-down h3{
margin-top: 200px;
max-width: 400px;
}
nav ul li a {
font-family: 'Josefin Sans', sans-serif;
font-size: 14px;
color: #fff;
font-weight: 600;
text-transform: uppercase;
text-decoration: none;
}
a {
color: #fff;
text-decoration: none;
}
.menu-icon {
line-height: 60px;
width: 100%;
background: #000;
text-align: right;
box-sizing: border-box;
padding: 15px 24px;
cursor: pointer;
color: #fff;
display: none;
}
#media(max-width: 786px) {
.logo {
position: fixed;
top: 0;
margin-top: 16px;
}
nav ul {
max-height: 20px;
background: #000;
}
nav.black ul {
background: #000;
}
.showing {
max-height: 34em;
}
nav ul li {
box-sizing: border-box;
width: 100%;
padding: 24px;
text-align: center;
}
.menu-icon {
display: block;
}
}
<header>
<nav>
<div class="menu-icon">
<i class="fa fa-bars fa-2x"></i>
</div>
<div class="logo wow tada">
</div>
<div class="menu">
<ul>
<li>START</li>
<li>TJÄNSTER</li>
<li>OM OSS</li>
<li>KONTAKT</li>
</ul>
</div>
</nav>
<div class="move-down wow fadeInUp"><h3> VILL GÖRA KUNDEN NÖJD</h3>
<h3> tel: 070719763 </h3></div>
</header>
how it looks now
https://i.stack.imgur.com/vOQGa.png
Well remove 'margin-top: 200px;' in the '.move-down h3' and add 'padding: 200px 0px 0px 0px;' or 'padding-top: 200px;'
Yes, Simple solution is.
Add this CSS
h3{
maring:0;
}
Hope this helps.
Instead of adding margin-top add top value to relatively positioned element.
.move-down h3 {
max-width: 400px;
position: relative;
top: 205px;
}
https://jsfiddle.net/6uedrb89/12/

How to remove an :after effect for a specific id when a class applies the effect

You will see in my snippet below that I am trying to turn "Get a Quote" to more of a button style. Anytime I add padding to this element navInverse, it causes run off for the background color to the next line. I am also trying to get the :after effect to not take place with the navInverse object.The after effect currently puts a red line under the button.
If I add the following code to navInverse, it looks like the image below. This is how I want the button padding to appear, minus the overlapping part that gets pushed to the bottom.
Also, I cannot figure out why the navInverse color will not show as white. I have it coded as
color:#FFF;
vertical-align: middle;
padding: 10px 12px;
Does anyone see what I am doing wrong?
Jsfiddle
nav {
background: #FFF;
height: 70px;
width: 100%;
max-width: 100%;
box-shadow: 1px 1px #E5E5E5;
position: fixed;
top: 0;
z-index: 999;
box-sizing: border-box;
}
#nav-logo {
float: left;
height: 100%;
width: auto;
display: block;
position: relative;
margin-left: 5%;
}
#nav-logo img {
height: 80%;
width: auto;
position: absolute;
top: 50%;
transform: translateY(-50%);-webkit-transform: translateY(-50%);
}
#nav-list li {
display: inline-block;
margin: 0 17px;
}
#nav-list li:first-child {
margin-left: 0px;
}
#nav-list li:last-child {
margin-right: 0px;
}
#nav-list li a {
text-decoration: none;
font-family: 'Muli', sans-serif;
font-size: .9rem;
/*color: #4b4b4b;*/
color: #747678;
letter-spacing: 1px;
vertical-align: middle;
transition: all .3s;-webkit-transition: all .3s;
}
#nav-list li a:after {
content: '';
display: block;
width: 0;
margin-top: 6px;
background: #BE1E2D;
height: 2px;
transition: width .3s;
}
#nav-list li a:hover {
color: #4b4b4b;
transition: all .3s;-webkit-transition: all .3s;
}
#nav-list li a:hover:after {
width: 100%;
transition: width .3s;
}
#navInverse {
border-radius: 2px;
box-sizing: border-box;
font-family: 'Muli', sans-serif;
font-size: 1.4rem;
color: #FFF;
background: linear-gradient(to right bottom, #BE1E2D, #981824);
text-transform: uppercase;
text-decoration: none;
cursor: pointer;
}
#navInverse:after {
content: '';
display: none;
width: 0px;
height: 0px;
transition: none;
}
<nav>
<div id="nav-logo">
<img src="https://s3.us-east-2.amazonaws.com/mbkitsystems/logoBR.png" alt="MB Kit Systems">
</div>
<div id="mobile-button"><img src="" class="hidden" alt=""></div>
<div id="nav-pop">
<div id="nav-pop-close"></div>
<ul id="nav-list">
<li>ABOUT</li>
<li>SERVICES</li>
<li>DESIGN</li>
<li>CONTACT</li>
<li>GET A QUOTE</li>
</ul>
</div>
</nav>
You need to increase the selector specificity, the regular selector (#nav-list li a) as a specificity of 3, but the override selector (#navInverse) has 1, so it get overridden.
One way to increase your selector specificity is make it #nav-list li a#navInverse.
I'm not sure that this is the result you wanted, but this is works.
nav {
background: #FFF;
height: 70px;
width: 100%;
max-width: 100%;
box-shadow: 1px 1px #E5E5E5;
position: fixed;
top: 0;
z-index: 999;
box-sizing: border-box;
}
#nav-logo {
float: left;
height: 100%;
width: auto;
display: block;
position: relative;
margin-left: 5%;
}
#nav-logo img {
height: 80%;
width: auto;
position: absolute;
top: 50%;
transform: translateY(-50%);
-webkit-transform: translateY(-50%);
}
#nav-list li {
display: inline-block;
margin: 0 17px;
}
#nav-list li:first-child {
margin-left: 0px;
}
#nav-list li:last-child {
margin-right: 0px;
}
#nav-list li a {
text-decoration: none;
font-family: 'Muli', sans-serif;
font-size: .9rem;
/*color: #4b4b4b;*/
color: #747678;
letter-spacing: 1px;
vertical-align: middle;
transition: all .3s;
-webkit-transition: all .3s;
}
#nav-list li a:after {
content: '';
display: block;
width: 0;
margin-top: 6px;
background: #BE1E2D;
height: 2px;
transition: width .3s;
}
#nav-list li a:hover {
color: #4b4b4b;
transition: all .3s;
-webkit-transition: all .3s;
}
#nav-list li a:hover:after {
width: 100%;
transition: width .3s;
}
#nav-list li a#navInverse {
border-radius: 2px;
box-sizing: border-box;
font-family: 'Muli', sans-serif;
font-size: 1.4rem;
color: #FFF;
background: linear-gradient(to right bottom, #BE1E2D, #981824);
text-transform: uppercase;
text-decoration: none;
cursor: pointer;
}
#navInverse:after {
content: '';
display: none;
width: 0px;
height: 0px;
transition: none;
}
<nav>
<div id="nav-logo">
<img src="https://s3.us-east-2.amazonaws.com/mbkitsystems/logoBR.png" alt="MB Kit Systems">
</div>
<div id="mobile-button"><img src="" class="hidden" alt=""></div>
<div id="nav-pop">
<div id="nav-pop-close"></div>
<ul id="nav-list">
<li>ABOUT</li>
<li>SERVICES</li>
<li>DESIGN</li>
<li>CONTACT</li>
<li>GET A QUOTE</li>
</ul>
</div>
</nav>

Extra space underneath navigation bar

I'm currently trying to make a website, and I managed to create a navigation bar. However, there is a weird "extra" space between my navigation bar. It was working fine at first but after I referenced a JQuery. However, I doubt the JQuery is the one that caused the problem as the site looks the same even after I took it out. Here's a screenshot of the problem. I'm trying to get rid of the circled part.
My HTML code:
<div id="nav"> <!-- Navigation Bar -->
<nav>
<ul>
<li><a class="selected" href="#">Home</a></li>
<li>About Me</li> <!-- Link to about page -->
<li class="drop">
Games
<div class="drop-content">
Red Faction: Guerrilla <!-- Contains links to the respective pages -->
Way of the Samurai 3
Singularity
</div>
</li>
<li>Reviews</li>
<li>External Store</li> <!-- Link to external site -->
<li>Videos</li> <!-- Contains links to Youtube -->
<li>Feedback</li> <!--Feedback form-->
And here's the stylesheet:
#nav nav{ /* Navigation bar*/
padding-top: 5%;
margin-bottom: 5% }
#nav ul {
list-style-type: none;
margin: 0;
background-color: #1C86EE;
padding: 0;
position: relative;
width: 100%;
bottom: 0;
display: inline-block }
#nav li {
float: left;
width: 14% }
li a, .dropbtn {
display: inline-block;
color: #FFFFFF;
text-align: center;
padding-left: 15%;
padding-right: 15%;
text-decoration: none }
.selected {
background-color: #6CCC0A;
padding-right: 25% }
li a:hover, .drop:hover .dropbtn {
background-color: #BFA810 }
a {
padding-top: 1em;
padding-bottom: 1em }
li.drop {
display: inline-block }
.drop-content {
display: none;
position: absolute;
background-color: #970707;
min-width: 14%;
box-shadow: 0px 8px 16px 0px #000000;
z-index: 100 }
.drop-content a {
color: #FFFFFF;
padding: 15px 20px;
display: block;
text-align: left }
.drop-content a:hover {
background-color: #02BBC4 }
.drop:hover .drop-content {
display: block;
border: 1px solid black;
position: absolute } /*End of navigation*/
* { /* index style */
box-sizing:border-box
}
body {
font-family: Verdana,sans-serif;
margin:0
}
.slideshow-fade {
display:none
}
/* Slideshow container */
.slideshow {
max-width: 100%;
position: relative;
margin: auto;
}
.slideshow img {
opacity: 0.7
}
/* Next & previous buttons */
.prev, .next {
cursor: pointer;
position: absolute;
top: 50%;
width: auto;
padding: 1em;
margin-top: -1em;
color: #FFFFFF;
font-weight: bold;
font-size: 1.5em;
transition: 0.6s ease;
border-radius: 0 3px 3px 0;
}
/* Position the "next button" to the right */
.next {
right: 0;
border-radius: 3px 0 0 3px;
}
/* On hover, add a black background color with a little bit see-through */
.prev:hover, .next:hover {
background-color: rgba(0,0,0,0.8);
}
/* Caption text */
.text {
color: #000000;
font-size: 1.3em;
padding: 1% 2%;
position: absolute;
bottom: 2%;
width: 100%;
text-align: center;
}
/* Number text (1/3 etc) */
.number {
color: #000000;
font-size: 1em;
padding: 8px 12px;
position: absolute;
top: 0;
}
/* The dots/bullets/indicators */
.dot {
cursor: pointer;
height: 1em;
width: 4%;
margin: 0 2px;
background-color: #bbbbbb;
border-radius: 50%;
display: inline-block;
transition: background-color 0.6s ease;
}
.active, .dot:hover {
background-color: #717171;
}
/* Fading animation */
.fade {
-webkit-animation-name: fade;
-webkit-animation-duration: 1.5s;
animation-name: fade;
animation-duration: 1.5s;
}
#-webkit-keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
#keyframes fade {
from {opacity: .4}
to {opacity: 1}
}
/* On smaller screens, decrease text size */
#media only screen and (max-width : 720px ){
.prev, .next,.text {font-size: 11px}
}
.slideshow-fade a {
color: #FFFFFF
}
.slideshow-fade a:visited {
color: #5115D0
} /*End of style for index*/
footer { /*Footer*/
background: #000000;
width: 100%;
height: 5%;
position: relative;
bottom: 0;
left: 0;
padding-top: 2%;
overflow: hidden;
}
footer p {
font-family: arial, calibri, sans-serif;
color: #FFFFFF;
text-align: center;
padding-bottom: 2%;
} /*End of footer*/
Any help will be much appreciated. Thank you.
Here is the jsfiddle file to make it more convenient to see the problem. https://jsfiddle.net/8xutoea5/
Edit: Added more CSS codes.
Edit: I solved the problem. Thanks everyone for taking the time to solve this problem.
It appears to be a margin somewhere else in your CSS, not provided here, that is causing the issue. You could try setting margin-bottom:0; a few places to see if that solves it.
#nav nav ul li {
margin-bottom: 0;
padding-bottom: 0;
}
#nav nav ul li a {
margin-bottom: 0;
}
Or provide the rest of your style sheet.
It's most likely because you have your ul as inline-block, that will cause some space after elements. Also you have float on your li without a clearfix on nav.
You can solve this in various ways, here is one where you can use display: flex; and remove the float: left; on li. This is a pretty solid base you can build on with changing the justify-content property. You can find a awesome guide to flexbox over at css-tricks.com
UPDATE
I made some updates to the fiddle to solve the problem. Please note the code on top, also I made some other changes. Write if there is something unclear
* {
box-sizing: border-box;
}
jsfiddle
#nav ul {
list-style-type: none;
margin: 0;
background-color: #1C86EE;
padding: 0;
position: relative;
width: 100%;
bottom: 0;
display: flex;
justify-content: space-between;
}
#nav li {
width: 14%;
}
It's caused by the section "External Store", it's too long and it wraps. You can make it shorter or force a "no-wrap".
With the css property white-space with the value nowrap.
You have no classes on your internal tags so I would suggest add a class to the a tags and add the rule to it.
a.listLink{
white-space: nowrap;
}
Or you can just add a style attribute to that specific tag but I don't find that solution cool enough.

Centering p element and div in menu bar

Trying to vertically center a p element and an image. I know I could adjust the margins and padding, but I want to make sure the elements are aligned no matter what device the user enters the website on. Hence I'm looking for another option.
html, body {
font-size: 100%;
height: 100%;
font-family: 'Lato', sans-serif;
font-weight: 200;
}
/*Menu*/
.menu {
height: auto;
background-color: #fff;
width: 100%;
position: fixed;
z-index: 1;
-moz-box-shadow: 0 2px 0 0 #6ed3cf;
-webkit-box-shadow: 0 2px 0 0 #6ed3cf;
box-shadow: 0 2px 0 0 #6ed3cf;
}
.menu .logo {
padding-left: 2em;
}
.menu ul li a {
color: #3b3a36;
}
.menu .dropdown {
float: right;
right: 2em;
z-index: 20;
}
.menu .dropdown-menu {
background: #fff;
border: none;
}
.dropdown img {
height: 2.8em;
width: 2.8em;
-webkit-transition: width .8s, height .8s, -webkit-transform .8s; /* Safari */
transition: width .8s, height .8s, transform .8s;
}
.dropdown ul {
top: 3em;
left: -6.5em;
width: auto;
position: absolute;
color: #3DD0AC;
}
.rotate {
-webkit-transform: rotate(180deg); /* Safari */
transform: rotate(180deg);
}
.logo p {
font-size: 100%;
color: black;
font-family: 'Lato', sans-serif;
font-weight: bolder;
letter-spacing: 0.5em;
margin: 0;
}
<div class="menu">
<div class="logo">
<p><⁄BY_John Doe></p>
</div>
<div class="dropdown"> <img src="img/menu.jpg">
<ul class="dropdown-menu">
<li>Find me on Linkedin
<li>
<li>Send me an email</li>
<li>Download my resume</li>
</ul>
</div>
</div>
Flex box can acheive this for you. just add this to your css for .menu:
display:flex;
justify-content:space-between;
align-items: center
More settings for flexbox here: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
html,
body {
font-size: 100%;
height: 100%;
font-family: 'Lato', sans-serif;
font-weight: 200;
}
/*Menu*/
.menu {
height: auto;
background-color: #fff;
width: 100%;
position: fixed;
z-index: 1;
-moz-box-shadow: 0 2px 0 0 #6ed3cf;
-webkit-box-shadow: 0 2px 0 0 #6ed3cf;
box-shadow: 0 2px 0 0 #6ed3cf;
display:flex;
justify-content:space-between;
align-items: center
}
.menu .logo {
padding-left: 2em;
}
.menu ul li a {
color: #3b3a36;
}
.menu .dropdown {
float: right;
right: 2em;
z-index: 20;
}
.menu .dropdown-menu {
background: #fff;
border: none;
}
.dropdown img {
height: 2.8em;
width: 2.8em;
-webkit-transition: width .8s, height .8s, -webkit-transform .8s;
/* Safari */
transition: width .8s, height .8s, transform .8s;
}
.dropdown ul {
top: 3em;
left: -6.5em;
width: auto;
position: absolute;
color: #3DD0AC;
}
.rotate {
-webkit-transform: rotate(180deg);
/* Safari */
transform: rotate(180deg);
}
.logo p {
font-size: 100%;
color: black;
font-family: 'Lato', sans-serif;
font-weight: bolder;
letter-spacing: 0.5em;
margin: 0;
}
<div class="menu">
<div class="logo">
<p><⁄BY_John Doe></p>
</div>
<div class="dropdown">
<img src="img/menu.jpg">
<ul class="dropdown-menu">
<li>Find me on Linkedin
<li>
<li>Send me an email</li>
<li>Download my resume</li>
</ul>
</div>
</div>

CSS problems with animation? Can't align text in li?

This is incredibly frustrating but I am having problems aligning link text within an li after adding an animation. I took the animation from a menu that was aligned horizontally instead of vertically and have been able to integrate the animation in however my link text skewed as a result.
Each link is within an li. Below is a demo with circle animation:
.menubar {
position: absolute;
height: calc(100% - 32px);
width: 137px;
left: -140px;
top: 38px;
background-color: #52DBA5;
}
.menubutton {
width: 100%;
height: 80px;
padding-top: 0px;
padding-bottom: 40px;
text-transform: uppercase;
text-align: center;
cursor: pointer;
font-family: "Source Sans", Helvetica, Arial;
font-weight: bold;
background-color: rgba(0, 0, 0, 0);
display: block;
text-decoration: none;
}
/*HERE for menu animations*/
nav {
width: 100%;
}
nav ul {
list-style: none;
text-align: left;
}
nav ul li {} nav ul li a {
display: block;
padding: 50px;
top: 10px;
text-decoration: none;
color: #52DBA5;
text-transform: uppercase;
}
nav ul li a,
nav ul li a:after,
nav ul li a:before {
transition: all .3s;
}
nav ul li a:hover {
color: #52DBA5;
}
nav.circle ul li a {
position: relative;
overflow: hidden;
z-index: 1;
}
nav.circle ul li a:after {
display: block;
position: absolute;
margin: 0;
top: 0;
bottom: 0;
left: 0;
right: 0;
content: '.';
color: transparent;
width: 1px;
height: 1px;
border-radius: 50%;
background: transparent;
}
nav.circle ul li a:hover:after {
-webkit-animation: circle 1.2s ease-in forwards;
padding-right: 50px;
}
/* Keyframes */
#-webkit-keyframes fill {
0% {
width: 0%;
height: 1px;
}
50% {
width: 100%;
height: 1px;
}
100% {
width: 100%;
height: 100%;
background: #333;
}
}
/* Keyframes */
#-webkit-keyframes circle {
0% {
width: 1px;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
height: 1px;
z-index: -1;
background: white;
border-radius: 100%;
}
100% {
background: white;
height: 5000%;
width: 5000%;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
right: 0px;
margin: auto;
border-radius: 0;
}
}
.menutext {
width: 100%;
height: 20px;
top: -12px;
color: #39946f;
font-family: "source sans pro", , Helvetica, Arial;
font-weight: bold;
text-align: center;
text-decoration: none;
}
<div class="menubar">
<nav class="circle">
<ul>
<li class="menubutton"><a class="menutext" href="#">'.$account['username'].'</a>
</li>
<li class="menubutton"><a class="menutext" href="#">chat</a>
</li>
<li class="menubutton"><a class="menutext" href="#">settings</a>
</li>
<li class="menubutton"><a class="menutext" href="#">users</a>
</li>
</ul>
</nav>
<form class="logoutframe" method="post" id="logout">
<input class="logout" type="submit" name="logout" value="logout" /></input>
</form>
</div>
I have tried placing padding and using left and right on menu button, menu text, nav ul li a, everything. Even tried putting text in individual ps within the li.
But my text is still not centered in the box that forms on hover:
I need the text ("username", "chat," etc) to be left aligned within the menubar and centered (the text is slightly to the bottom and very much to the right) within the "circle" box that is formed on hover.
How can I do this?
Initially I had misunderstood your question and written a different answer. Below is the correct one.
There are a lot of extra/unnecessary settings in your code but the key reason why you are not able to achieve the left align is because the ul elements always have a default padding associated with it. It pushes the contents of the list to the right by a large value and hence it will look as though alignment is not proper.
If you make the changes that I've indicated in the below snippet, you'd be able to get what you need.
.menubar {
position: absolute;
/*height: calc(100% - 32px);
width: 137px; ideally these should be large enough to accomodate the element */
/*left: -140px; commented for demo */
top: 38px;
background-color: #52DBA5;
}
.menubutton {
width: 100%;
height: 80px;
/*padding-top: 0px;
padding-bottom: 40px; not required*/
text-transform: uppercase;
/*text-align: center; remove this */
cursor: pointer;
font-family: "Source Sans", Helvetica, Arial;
font-weight: bold;
background-color: rgba(0, 0, 0, 0);
display: block;
text-decoration: none;
line-height: 80px; /* add this to vertically center align the text */
}
/*HERE for menu animations*/
nav {
width: 100%;
}
nav ul {
list-style: none;
/*text-align: left; not required as this is default */
padding: 0px; /* add this */
}
nav ul li {} nav ul li a {
display: block;
text-indent: 8px; /* add this to indent just the text without affecting white box */
padding: 0px; /* change this */
top: 10px;
text-decoration: none;
color: #52DBA5;
text-transform: uppercase;
}
nav ul li a,
nav ul li a:after,
nav ul li a:before {
transition: all .3s;
}
nav ul li a:hover {
color: #52DBA5;
}
nav.circle ul li a {
position: relative;
overflow: hidden;
z-index: 1;
}
nav.circle ul li a:after {
display: block;
position: absolute;
margin: 0;
top: 0;
bottom: 0;
left: 0;
right: 0;
content: '.';
color: transparent;
width: 1px;
height: 1px;
border-radius: 50%;
background: transparent;
}
nav.circle ul li a:hover:after {
animation: circle 1.2s ease-in forwards; /* changed so others can see animation */
padding-right: 50px;
}
/* Keyframes */
#-webkit-keyframes fill {
0% {
width: 0%;
height: 1px;
}
50% {
width: 100%;
height: 1px;
}
100% {
width: 100%;
height: 100%;
background: #333;
}
}
/* Keyframes */
#-webkit-keyframes circle {
0% {
width: 1px;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
height: 1px;
z-index: -1;
background: white;
border-radius: 100%;
}
100% {
background: white;
height: 5000%;
width: 5000%;
z-index: -1;
top: 0;
bottom: 0;
left: 0;
right: 0px;
margin: auto;
border-radius: 0;
}
}
.menutext {
width: 100%; /* change this */
/*height: 20px;
top: -12px; not required */
color: #39946f;
font-family: "source sans pro", , Helvetica, Arial;
font-weight: bold;
/*text-align: center; remove this */
text-decoration: none;
}
<div class="menubar">
<nav class="circle">
<ul>
<li class="menubutton"><a class="menutext" href="#">'.$account['username'].'</a>
</li>
<li class="menubutton"><a class="menutext" href="#">chat</a>
</li>
<li class="menubutton"><a class="menutext" href="#">settings</a>
</li>
<li class="menubutton"><a class="menutext" href="#">users</a>
</li>
</ul>
</nav>
<form class="logoutframe" method="post" id="logout">
<input class="logout" type="submit" name="logout" value="logout" /></input>
</form>
</div>