I've created a card that is showcasing an article.
For some reason, two of the elements have additonal height that's causing weird behaviour. At first I thought it was the image but giving it a diplay:block hasn't solved the issue.
I've been messing around with it a lot so it's a bit of a mess at this point. SO here's the weird extra height between the white part of the card and the image:
Because it's happening to two elements, I have a feeling that it's something important that I am fundamentally missing.
The two affected elements are:
articleCard_image, a <div>
articleCard_container, a <section>
The issue only occurs for the <secction> when the 'Read Article' anchor is displayed. (I've commmented out the display:none which is changed to block on hover)
I'm using Gulp to compile the scss to css.
Any help would be greatly appreciated. Thank you! Code shown below:
SCSS:
.articleCard_container {
width: 55.7rem;
height: auto;
.articleCard_image {
width: 100%;
height: auto;
box-sizing: border-box;
display: block;
.articleCard_category {
position: relative;
bottom: 4rem;
left: 3rem;
display: flex;
align-items: center;
text-transform: uppercase;
font-size: 1.4rem;
color: var(--white);
width: 100%;
p {
font-weight: 600;
}
.thumbtack {
margin-right: 1rem;
margin-bottom: 1rem;
}
.purpleRose {
width: 100%;
display: block;
}
}
}
.articleCard_textContent {
box-sizing: border-box;
padding: 1rem 3rem 5rem 3rem;
width: 100%;
margin: 0;
background-color: var(--white);
.articleCard_date {
color: var(--articleDate);
text-transform: uppercase;
font-size: 1.2rem;
}
.articleCard_title {
margin-top: 1rem;
font-size: 1.6rem;
width: 100%;
color: var(--articleTitle);
font-weight: 700;
}
}
.articleCard_readMore {
text-transform: uppercase;
color: var(--buttonPrimary);
font-size: 1.2rem;
font-weight: 600;
position: relative;
bottom: 2rem;
left: 3rem;
// display: none;
}
}
.articleCard_container:hover {
.articleCard_readMore {
display: block;
box-sizing: border-box;
text-decoration: none;
}
}
HTML:
<div class="carouselle_container">
<section class="articleCard_container">
<div class="articleCard_image">
<img class="purpleRose" src="./assets/purpleRose.jpg" alt="purple rose">
<div class="articleCard_category">
<img class="thumbtack" src="./assets/thumtack.svg" alt="thumbtack icon">
<p>featured news / category</p>
</div>
</div>
<div class="articleCard_textContent">
<time date="2020-03" class="articleCard_date"> march 20th 20xx</time>
<h3 class="articleCard_title">This is an example of a really long heading that needs to span over multiple lines.</h3>
</div>
<a class="articleCard_readMore" href="/">read article</a>
</section>
</div>
you have to give the .articleCard_image position relative to make sure that the category does not overflow and then give the .articleCard_category absolute position and give a full width and height and display block to the img in order to take the entire space
.articleCard_container {
width: 55.7rem;
height: auto;
.articleCard_image {
width: 100%;
height: auto;
position: relative;
img{
display: block;
height: 100%;
width: 100%;
}
.articleCard_category {
position: absolute;
bottom: 4rem;
left: 3rem;
display: flex;
align-items: center;
text-transform: uppercase;
font-size: 1.4rem;
color: var(--white);
width: 100%;
p {
font-weight: 600;
}
.thumbtack {
margin-right: 1rem;
margin-bottom: 1rem;
}
.purpleRose {
width: 100%;
display: block;
}
}
}
.articleCard_textContent {
box-sizing: border-box;
padding: 1rem 3rem 5rem 3rem;
width: 100%;
margin: 0;
background-color: var(--white);
.articleCard_date {
color: var(--articleDate);
text-transform: uppercase;
font-size: 1.2rem;
}
.articleCard_title {
margin-top: 1rem;
font-size: 1.6rem;
width: 100%;
color: var(--articleTitle);
font-weight: 700;
}
}
.articleCard_readMore {
text-transform: uppercase;
color: var(--buttonPrimary);
font-size: 1.2rem;
font-weight: 600;
position: relative;
bottom: 2rem;
left: 3rem;
// display: none;
}
}
.articleCard_container:hover {
.articleCard_readMore {
display: block;
box-sizing: border-box;
text-decoration: none;
}
}
Related
im working in my final proyect to become a Web Developer, and im struggling with my footer, that is creating a minimum horizontal scroll and I cant find why.
I've been doing tests and I can't get rid of that horizontal scroll. An answer as soon as possible would be of great help to me, since this is my final project.
footer {
position: absolute;
bottom: 100;
left: 0;
right: 0;
background: #111;
height: auto;
width: 100%;
padding-top: 40px;
color: #fff;
}
.footer-content {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
text-align: center;
h3 {
font-size: 2rem;
font-weight: 500;
text-transform: capitalize;
line-height: 4rem;
color: yellow;
}
}
.socials {
list-style: none;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
li {
margin: 0 0px;
}
a {
text-decoration: none;
color: #fff;
padding: 5px;
&:hover {
color: rgb(255, 251, 0);
transition-duration: 1s;
}
}
}
.footer-bottom {
background: #000;
width: 100%;
padding: 20px;
padding-bottom: 40px;
text-align: center;
p {
display: flex;
justify-content: flex-start;
font-size: 14px;
word-spacing: 2px;
text-transform: capitalize;
a {
color: yellow;
font-size: 16px;
text-decoration: none;
}
}
}
#media (max-width: 830px) {
.socials li {
font-size: 14px;
}
}
<footer>
<div class="footer-content">
<h3>KURT BURGERS</h3>
<ul class="socials">
<li>DEFENSA AL CONSUMIDOR</li>
<li>DELIVERY</li>
<li>POLITICAS DE PRIVACIDAD</li>
</ul>
</div>
<div class="footer-bottom">
<p>copyright © KURT BURGERS </p>
</div>
</footer>
I copied your code and removed the width:100% from .footer-bottom the horizontal scroll disappeared.
The reason why you get the scrollbar is because footer-bottom's width is 100% + the 20px padding you have set for each side of the element. If you add padding to an element with a width, the padding will be added on top of the width unless you set box-sizing: border-box;
You could add border-box to footer-bottom as a solution but what you should really do is remove the width 100% from footer-bottom because it is a block element already and it will take up the 100% width by default so there is no need to set it.
The same thing applies to the ul .socials, it has natural padding on the tag so when you set width 100% to it, it will be wider than 100%. In the case of this ul, I simply added padding: 0
In the below snippet, I have removed the width 100% from footer-bottom and I added some minor css to body so it is easier to see your content width.
body,
html {
padding: 0;
margin: 0;
}
footer {
position: absolute;
bottom: 100;
left: 0;
right: 0;
background: #111;
height: auto;
width: 100%;
padding-top: 40px;
color: #fff;
}
.footer-content {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
text-align: center;
}
.footer-content h3 {
font-size: 2rem;
font-weight: 500;
text-transform: capitalize;
line-height: 4rem;
color: yellow;
}
.socials {
list-style: none;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
padding: 0;
}
.socials li {
margin: 0 0px;
}
.socials a {
text-decoration: none;
color: #fff;
padding: 5px;
}
.footer-bottom {
background: #000;
padding: 20px;
padding-bottom: 40px;
text-align: center;
p {
display: flex;
justify-content: flex-start;
font-size: 14px;
word-spacing: 2px;
text-transform: capitalize;
a {
color: yellow;
font-size: 16px;
text-decoration: none;
}
}
}
#media (max-width: 830px) {
.socials li {
font-size: 14px;
}
}
<footer>
<div class="footer-content">
<h3>KURT BURGERS</h3>
<ul class="socials">
<li>DEFENSA AL CONSUMIDOR</li>
<li>DELIVERY</li>
<li>POLITICAS DE PRIVACIDAD</li>
</ul>
</div>
<div class="footer-bottom">
<p>copyright © KURT BURGERS </p>
</div>
</footer>
You are missing this from your styles:
* {
box-sizing: border-box;
}
I made this followers Card design but am having a bit of problem when styling it, when I try to add margin-right to align the image to the right side of the container for some reason it doesn't align to the right, It aligns it more to the left and it stretches the container, it also grabs the text even though they're both in separate containers, same for the button. And for some reason instead of using padding on the follow__content, I instead used gave a width but for some reason the image get left out.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.2%;
font-family: Roboto, Arial, Helvetica, sans-serif;
}
.follow__container {
display: grid;
place-items: center;
height: 100vh;
}
.follow__content {
background-color: rgba(206, 194, 178, 0.836);
line-height: 1.2;
padding: 2rem 10rem;
}
.img__container {
width: 35px;
display: inline-block;
margin-right: 2rem;
margin-top: 0.5rem;
}
.img__container img {
width: 35px;
height: 35px;
object-fit: cover;
object-position: center;
border-radius: 5rem;
}
.follow__desc {
display: inline-block;
margin: 0 0 0 0.5rem;
font-size: 0.99rem;
}
.follow__btn {
display: inline-block;
font-size: 1.2rem;
left: 8rem;
position: relative;
top: -1.6rem;
cursor: pointer;
}
.follow__btn a {
text-decoration: none;
padding: 1rem 1.5rem;
background-color: #222095;
color: #ffffff;
border-radius: 1rem;
}
<div class="follow__container">
<div class="follow__content">
<div class="img__container">
<img src="cybercybrog.jpg" alt="">
</div>
<div class="follow__desc">
<h2>Mr Cyborg</h2>
<p>#CyberCity</p>
<p>Most Popular</p>
</div>
<div class="follow__btn">
Follow
</div>
</div>
</div>
I think this is your desired output.I used the padding property in the follow__content class and changed its' values by giving all the sides padding like this. Since you had given padding only for two sides it was applied incorrectly.
.follow__content {
background-color: rgba(206, 194, 178, 0.836);
line-height: 1.2;
padding: 10px 100px 10px 10px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html {
font-size: 62.2%;
font-family: Roboto, Arial, Helvetica, sans-serif;
}
.follow__container {
display: grid;
place-items: center;
height: 100vh;
}
.follow__content {
background-color: rgba(206, 194, 178, 0.836);
line-height: 1.2;
padding: 20px 100px 20px 10px;
}
.img__container {
width: 35px;
display: inline-block;
margin-right: 0rem;
margin-top: 0.5rem;
}
.img__container img {
width: 35px;
height: 35px;
object-fit: cover;
object-position: center;
border-radius: 5rem;
}
.follow__desc {
display: inline-block;
margin: 0 0 0 0.5rem;
font-size: 0.99rem;
}
.follow__btn {
display: inline-block;
font-size: 1.2rem;
left: 8rem;
position: relative;
top: -1.6rem;
cursor: pointer;
}
.follow__btn a {
text-decoration: none;
padding: 1rem 1.5rem;
background-color: #222095;
color: #ffffff;
border-radius: 1rem;
}
<div class="follow__container">
<div class="follow__content">
<div class="img__container">
<img src="https://www.slashfilm.com/img/gallery/joss-whedon-says-he-cut-cyborgs-justice-league-storyline-because-ray-fisher-is-a-bad-actor/l-intro-1642457019.jpg" alt="Profile Image">
</div>
<div class="follow__desc">
<h2>Mr Cyborg</h2>
<p>#CyberCity</p>
<p>Most Popular</p>
</div>
<div class="follow__btn">
Follow
</div>
</div>
</div>
This question already has an answer here:
Why do I have scroll bars on my website when there shouldn't be?
(1 answer)
Closed 1 year ago.
I'm making a discord server website for people to find discord servers to join and make
friends but, I dont know why my web page has a horizontal scroll bar. It also had a vertical scroll
bar but I got rid of that,
anyway here is my HTML and CSS
html {
font-family: Arial, Helvetica, sans-serif;
background-color: #414141;
text-decoration: none;
}
body {
background-color: #414141;
}
:root {
--navbar-height: 4rem;
--header-height: 14rem;
--main-min-height: 240rem;
}
body {
height: 100vh;
min-width: 480;
margin: 0;
padding: 0;
font-family: Helvetica;
display: grid;
grid-template-rows: minmax(var(--navbar-height), auto) minmax(var(--main-min-height) 1fr) auto;
}
.topnav {
overflow: hidden;
padding: 0px 15px;
height: var(--navbar-height);
color: white;
}
.topnav a {
font-size: 20;
float: left;
color: #f2f2f2;
text-align: center;
padding: 22px 16px;
text-decoration: none;
font-size: 17px;
}
.topnav a:hover {
background-color: #ddd;
color: black;
}
.topnav a.active {
color: #788ce2;
}
.topnav-right {
float: right;
}
.row::after {
clear: both;
display: table;
}
.copyright {
position: absolute;
bottom: 1%;
right: 1%;
font-size: 15px;
}
.copyright-text {
color: white;
}
.footer-links {
position: absolute;
bottom: 5%;
}
.link-text {
position: absolute;
bottom: 10%;
color: white;
text-decoration: none;
}
.container {
padding: 0;
margin: 0;
}
li {
position: relative;
left: 100%;
}
footer {
position: absolute;
bottom: 0%;
height: 300px;
width: 100%;
color: #fff;
background: #2c2c2c;
}
.welcome {
margin-top: -2.5rem;
width: 100%;
height: 35.5rem;
line-height: 1.8em;
margin-bottom: .4em;
padding: 0;
font-family: Helvetica;
font-weight: 600;
font-size: 1.5em;
color: #ffff;
text-transform: uppercase;
}
.centered-text {
position: relative;
margin-left: 25%;
display: flex;
align-items: center;
padding: 0 1.5rem;
}
.discord-logo {
border: 0;
font: 0/0 a;
text-shadow: none;
color: transparent;
display: inline-block;
padding: .6em 0;
background: url(images/Discord-Wordmark-White.png) center no-repeat;
background-size: contain;
font-size: 1em;
}
.head {
margin-bottom: .4em;
padding: 0;
line-height: 1.4;
font-weight: 600;
font-size: 2em;
}
.body {
position: relative;
margin-left: 24.5%;
margin: 0 auto 1em;
text-transform: inherit;
opacity: 85%;
}
.search-box {
position: absolute;
top: 90%;
left: 18%;
background: #2c2c2c;
height: 40px;
border-radius: 40px;
padding: 10px;
}
.search-box:hover>.search-txt {
width: 260px;
padding: 0 6px;
}
.search-btn {
color: white;
float: right;
width: 40px;
height: 40px;
border-radius: 100%;
background: black;
display: flex;
justify-content: center;
align-items: center;
text-decoration: none;
}
.search-box:hover>.search-btn {
background: white;
color: black;
}
.search-txt {
border: none;
background: none;
outline: none;
float: left;
padding: 0;
color: white;
font-size: 16px;
transition: 0.4s;
line-height: 40px;
width: 0px;
}
.navbar-servers {
color: white;
float: right;
}
.title-right {
position: absolute;
right: 25%;
}
body {
color: #e6e6e6;
font-size: 1em;
font-weight: 400;
line-height: 1.5;
}
h1 {
position: absolute;
left: 42%;
top: 10%;
}
.last-modified {
position: absolute;
left: 40.6%;
top: 17%;
}
.terms-of-service-align {
position: absolute;
left: 1%;
top: 25%;
}
.site-footer .site-footer--container,
.site-footer .site-footer--extra {
max-width: 1264px;
width: 100%;
margin: 0 auto;
padding: 32px 12px 12px 12px;
display: flex;
flex-flow: row wrap;
}
.site-footer--container,
.site-footer--extra {
max-width: 1264px;
}
.site-footer,
.site-footer *,
.site-footer *:before,
.site-footer *:after {
box-sizing: border-box;
}
h5,
h6 {
margin: 0;
padding: 0;
border: 0;
font: inherit;
font-size: 100%;
vertical-align: baseline;
}
.site-footer {
background-color: #242729;
background-image: none;
background-position: top left;
background-repeat: no-repeat;
border-top: 0;
background-size: auto;
color: #6a737c;
padding-top: 0;
padding-bottom: 0;
}
.discord {
color: #788ce2;
font-weight: 800;
}
.guidelines {
color: #788ce2;
font-weight: 800;
}
.hidden {
position: absolute;
top: 520%;
height: 0px;
opacity: 0%;
}
.main-header {
position: absolute;
left: 41%;
}
.all {
position: relative;
top: 10%;
left: 28%;
}
<nav class="topnav">
<div>
<h2 class="title-right">
OnTop Servers
</h2>
</div>
</nav>
<div class="main-container">
<h1 class="main-header">
Guidelines</h1>
<p class="last-modified">
Last Modified: 2020-11-22
</p>
<div class="all">
In order to keep a safe community, there are some guidelines which need to be followed by you<br> By using DISBOARD, you agree to the following guidelines:<br><br> The use of swear words, dirty words or NSFW (sexual content) to our discretion in a
server's meta (title,<br> description and picture), review or other content that may be seen by other users in DISBOARD is not<br> allowed. This will lead to the removal of the content, however, you'll be able to repost the content with a<br> proper
language.<br>
<Br> You may not violate any laws or regulations in your country of residence or promote the violation of them.<br><br> Servers violating <a class="discord" href="https://discord.com/guidelines">Discord Community Guidelines</a> are not allowed.<br><br> The use of bots or other scripts to automatically do actions in DISBOARD such as bumping a server ("auto-<br> bump") is not allowed. Bumping, creating reviews and etc. must be done manually.<br><br> You may not list servers which serve for the sole
purpose of redirecting or advertising other servers or have<br> no content (To our discretion).<br><br> You may not reward or force users to do actions in DISBOARD. For instance, you may not reward your users<br> for posting a nice review on a server
or force them to bump a server.<br><br> You may not create multiple Discord accounts to submit multiple reviews. Please just post 1 review per<br> person.
<br><br> All servers which are mainly based on NSFW (sexual content to our discretion) must be marked as "NSFW"<br> in DISBOARD.<br><br>
<div class="TOS">
See also our <a class="discord" href="termsofservice.html">Term of Services</a>
</div>
</div>
How do I fix, please help me with this...
I dont know what to do, I gone through almost everything on the page, I don know.
position: relative; left:28% pushes the element beyond the window width creating an overflow to the right.
.all {
position: relative;
top: 10%;
left: 28%;
}
you can try using padding or margin instead
Instead of putting left: 28% for your div, use padding-left: 28%. It should be a little fix.
* {
font-size: 14px;
box-sizing: border-box;
}
.wrapper {
padding: 2rem;
}
.text--bigtitle {
text-transform: uppercase;
font-size: 2rem;
}
.border--short {
position: relative;
}
.border--short::after {
content: "";
display: block;
position: absolute;
height: 2px;
width: 40%;
bottom: 0;
left: 50%;
color: red;
margin-left: -20%;
}
<div class="wrapper">
<p class="border--short text--bigtitle">Short Border</p>
</div>
I want to achieve a short bottom border instead of a full-width bottom border under a title using CSS and HTML.
I have tried using position:absolute to position the after element under the title text with the width desired. However, the bottom border is not showing at all. My code is as shown below:
Can anyone help me to solve this problem, thank heaps.
change color property to background-color property of .border--short::after. color property is used to change the font color of the text. background-color is used to change the background color. thanks
* {
font-size: 14px;
box-sizing: border-box;
}
.wrapper {
padding: 2rem;
}
.text--bigtitle {
text-transform: uppercase;
font-size: 2rem;
}
.border--short {
position: relative;
}
.border--short::after {
content: "";
display: block;
position: absolute;
height: 2px;
width: 40%;
bottom: 0;
left: 50%;
background-color: red;
margin-left: -20%;
}
<div class="wrapper">
<p class="border--short text--bigtitle">Short Border</p>
</div>
I hope this is how you need..
* {
font-size: 14px;
box-sizing: border-box;
}
.wrapper {
padding: 2rem;
}
.text--bigtitle {
text-transform: uppercase;
font-size: 2rem;
}
.border--short {
position: relative;
padding-bottom: 10px;
}
.border--short::after {
content: "";
display: block;
height: 2px;
width: 40%;
background-color: red;
}
<div class="wrapper">
<p class="border--short text--bigtitle">Short Border</p>
</div>
try this once it will work and if you don't want text center remove text-align: center form class .wrapper.
* {
font-size: 14px;
box-sizing: border-box;
}
.wrapper {
padding: 2rem;
text-align: center;
}
.text--bigtitle {
text-transform: uppercase;
font-size: 2rem;
position: relative;
display: inline-block;
}
.text--bigtitle::after {
content: "";
display: block;
height: 2px;
width: 40%;
background-color: red;
margin: auto;
}
<div class="wrapper">
<p class="text--bigtitle">Short Border</p>
</div>
Thank You...
* {
font-size: 14px;
box-sizing: border-box;
}
.wrapper {
padding: 2rem;
}
.text--bigtitle {
text-transform: uppercase;
font-size: 2rem;
}
.border--short {
position: relative;
display: inline-block;
}
.border--short::after {
content: "";
display: block;
position: absolute;
height: 2px;
width: 40%;
bottom: 0px;
left: 30%; /* 50 % minus half the width */
background-color: red;
}
<div class="wrapper">
<p class="border--short text--bigtitle">Short Border</p>
</div>
I want to left align text in a drop-down menu but I'm having some problems. I have this HTML
<nav>
<a>Vote</a>
<a>Search</a>
<a>About</a>
</nav>
and this CSS for the drop down menu
nav {
display: none;
width: 30rem;
padding: 0rem;
background-color: red;
position: absolute;
right: 0%;
top: 100%;
text-align: left;
}
.nav-open {
display: block;
}
nav a {
display: block;
width: 100%;
text-align: left;
padding: 1.4rem 1.6rem;
text-decoration: none;
cursor: pointer;
font-size: 1.2rem;
color: #000;
}
But as you can see, when you click the menu icon the text isn't even visible. Interestingly, when I change:
text-align: left;
to
text-align: center;
I can see the text again, but it is not aligned where i want it. How do I left align my text and keep it visible?
$('.menu-btn').click(function() {
$('nav').toggleClass('nav-open');
});
style* {
margin: 0 auto;
font-family: sans-serif;
}
body {
margin: 0 auto;
font-family: Benton Sans, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, Helvetica, Tahoma, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
}
header {
width: 100%;
background-color: orange;
text-align: center;
position: relative;
}
#pageTitle {
display: flex;
padding: 10px;
}
#pageTitle h2 {
justify-content: center;
/* align horizontal */
align-items: center;
width: 95%;
}
.menu-btn {
position: absolute;
display: inline-block;
cursor: pointer;
}
.menu-btn div {
position: absolute;
left: 100%;
top: 0%;
padding-right: 8px;
margin-top: -0.50em;
line-height: 1.2;
font-weight: 200;
vertical-align: middle;
z-index: 99;
}
.menu-btn span {
display: block;
width: 20px;
height: 2px;
margin: 4px 0;
background: #989da1;
z-index: 99;
}
nav {
display: none;
width: 30rem;
padding: 0rem;
background-color: red;
position: absolute;
right: 0%;
top: 100%;
text-align: left;
}
.nav-open {
display: block;
}
nav a {
display: block;
width: 100%;
text-align: left;
padding: 1.4rem 1.6rem;
text-decoration: none;
cursor: pointer;
font-size: 1.2rem;
color: #000;
}
nav a:hover {
background-color: #111;
color: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header>
<div id="pageTitle">
<h2>Page Title</h2>
<div class="mobile-nav">
<button class="menu-btn" id="menu-btn">
<div></div>
<span></span>
<span></span>
<span></span>
</button>
<nav>
<a>Vote</a>
<a>Search</a>
<a>About</a>
</nav>
</div>
</div>
</header>
The problem comes from the rem unit you are using when giving width to your nav. You should use vw viewport width. This is relative from the screen width going from 0 to 100 turning the viewport width into a percentage.
Hope this helps
$('.menu-btn').click(function() {
$('nav').toggleClass('nav-open');
});
style* {
margin: 0 auto;
font-family: sans-serif;
}
body {
margin: 0 auto;
font-family: Benton Sans, -apple-system, BlinkMacSystemFont, Roboto, Helvetica Neue, Helvetica, Tahoma, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
}
header {
width: 100%;
background-color: orange;
text-align: center;
position: relative;
}
#pageTitle {
display: flex;
padding: 10px;
}
#pageTitle h2 {
justify-content: center;
/* align horizontal */
align-items: center;
width: 95%;
}
.menu-btn {
position: absolute;
display: inline-block;
cursor: pointer;
}
.menu-btn div {
position: absolute;
left: 100%;
top: 0%;
padding-right: 8px;
margin-top: -0.50em;
line-height: 1.2;
font-weight: 200;
vertical-align: middle;
z-index: 99;
}
.menu-btn span {
display: block;
width: 20px;
height: 2px;
margin: 4px 0;
background: #989da1;
z-index: 99;
}
nav {
display: none;
width: 100vw;
padding: 0rem;
background-color: red;
position: absolute;
right: 0%;
top: 100%;
text-align: left;
}
.nav-open {
display: block;
}
nav a {
display: block;
width: 100%;
text-align: left;
padding: 1.4rem 1.6rem;
text-decoration: none;
cursor: pointer;
font-size: 1.2rem;
color: #000;
}
nav a:hover {
background-color: #111;
color: #fff;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<header>
<div id="pageTitle">
<h2>Page Title</h2>
<div class="mobile-nav">
<button class="menu-btn" id="menu-btn">
<div></div>
<span></span>
<span></span>
<span></span>
</button>
<nav>
<a>Vote</a>
<a>Search</a>
<a>About</a>
</nav>
</div>
</div>
</header>
As others have pointed out already, the text is actually aligned left, but your screen size might prevent it from showing up due to the big width of your menu.
Try changing the width of your nav element to something relative to the page width, like 80%:
nav {
display: none;
width: 80%;
padding: 0rem;
background-color: red;
position: absolute;
right: 0%;
top: 100%;
text-align: left;
}
https://jsfiddle.net/1y8n08aq/1/