Text Alignment changed when window size is changed - html

I'm trying to make it where the percentage text and loading text stays in the middle of the loader when I resize. The width change works when I resize the window, but when I change the height it moves the text. I'm not sure why this is happening but if someone is able to help me under why this is happening that would be nice.
CSS:
<style type="text/css">
html {
height: 100%;
width: 100%;
}
body {
background: url("https://cdn.cporigins.com/site/images/bg.jpg");
margin: 0;
}
.container {
display: none;
position: relative;
font-family: 'Do Hyeon', sans-serif;
font-size: 27px;
}
.middle {
position: absolute;
top: 50%;
left: 50%;
bottom: 50px;
transform: translate(-50%, -50%);
text-align: center;
}
hr {
margin: auto;
width: 40%;
border: 0;
height: 1px;
background: #333;
background-image: linear-gradient(to right, #ccc, #333, #ccc);
}
a {
text-decoration: none;
}
a:hover {
color: #add8e6;
}
i#heart-icon {
height: 18px;
width: 18px;
background-image: url(https://cdn.cporigins.com/site/images/heart_icon.png);
background-repeat: no-repeat;
}
i#heart-icon:before {
content: "";
padding-right: 18px;
}
.loader {
font-size: 10px;
margin: 50px auto;
border: 16px solid #f3f3f3;
border-top: 16px solid #6294f9;
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
background-repeat: no-repeat;
position: relative;
bottom: -32%;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#loadingDiv {
position: relative;
top: -50px;
left: 0;
width: 100%;
height: 100%;
background: #8360c3;
background: -webkit-linear-gradient(to top, #2ebf91, #8360c3);
background: linear-gradient(to top, #2ebf91, #8360c3);
}
#loaderTxt {
position: relative;
color: white;
font-size: 32px;
font-family: 'Do Hyeon', sans-serif;
top: 297px;
font-weight: bold;
text-align: center;
}
#loaderPercent {
position: relative;
color: white;
font-size: 32px;
font-family: 'Do Hyeon', sans-serif;
top: 128px;
font-weight: bold;
text-align: center;
}
</style>
I basically have it where it appends the divs to the html tag in js.
$('html').append('<div id="loadingDiv"><div class="loader"></div><div id="loaderTxt">Initializing Origins</div><div id="loaderPercent">0%</div></div>');

In these type of design you got to put the container to flex and center all items ( make it relative too )... Now make all items inside it absolutely positioned ... Here all items will come to the center ( of that container )... Viola, You will never get a problem of putting out the elements based on px size ever again..
html {
height: 100%;
width: 100%;
}
body {
background: url("https://cdn.cporigins.com/site/images/bg.jpg");
margin: 0;
}
#loadingDiv {
display: flex;
justify-content: center;
align-items: center;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #8360c3;
background: -webkit-linear-gradient(to top, #2ebf91, #8360c3);
background: linear-gradient(to top, #2ebf91, #8360c3);
}
.loader {
font-size: 10px;
margin: 50px auto;
border: 16px solid #f3f3f3;
border-top: 16px solid #6294f9;
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
background-repeat: no-repeat;
position: relative;
}
#keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
#loaderTxt {
position: absolute;
color: white;
font-size: 32px;
font-family: 'Do Hyeon', sans-serif;
bottom: 10vh;
font-weight: bold;
text-align: center;
}
#loaderPercent {
position: absolute;
color: white;
font-size: 32px;
font-family: 'Do Hyeon', sans-serif;
font-weight: bold;
text-align: center;
}
<div id="loadingDiv">
<div class="loader"></div>
<div id="loaderTxt">Initializing Origins</div>
<div id="loaderPercent">0%</div>
</div>

Try to end your css alignment line with !important
so if you want to align this html text
<p>THIS IS MY TEXT</p>
You can use css like this
p{text-align:center !important;}
I hope this answer helps.

Related

Trying to make animation on hr tag but it's not working

I'm trying to make the hr tag to animate from left to right and repeat,
and stay kinda center under the h2 tag,
but the animation not working... is anyone know why?
.div-projects {
margin-top: 200px;
display: flex;
justify-content: center;
align-items: center;
}
.div-projects h2 {
font-size: 55px;
padding: 90px;
color: white;
transform: skewY(-9deg);
}
.hr-projects {
width: 20%;
border-radius: 30px;
z-index: 2;
left: 900px;
bottom: 60px;
transform: skewY(-6deg);
border: 3px solid rgba(0, 136, 169, 1);
position: relative;
animation: alternate hr 19s infinite;
}
#keyframes hr {
from {
left: 900px;
}
to {
right: 600px;
}
}
<div class="div-projects">
<h2>Projects</h2>
</div>
<hr class="hr-projects">
You need to make animation/transition on same property.
So far example change from left 0 to left 100%, or left:50px to left:200px etc.
.div-projects {
margin-top: 200px;
display: flex;
justify-content: center;
align-items: center;
}
.div-projects h2 {
font-size: 55px;
padding: 90px;
color: white;
transform: skewY(-9deg);
}
.hr-projects {
width: 20%;
border-radius: 30px;
z-index: 2;
left: 900px;
bottom: 60px;
transform: skewY(-6deg);
border: 3px solid rgba(0, 136, 169, 1);
position:relative;
animation:alternate hr 19s infinite;
}
#keyframes hr {
from {
left: 0;
}
to {
left: 100%;
}
}
<div class="div-projects">
<h2>Projects</h2>
</div>
<hr class="hr-projects">

I want to set the text on my animation html/css

I want to set the h2 text on the animation. But i cant able to do that -_-.
here is the live link http://leander.web.dnodes.net/
source code: https://github.com/LeleEdits/website-new
change css to
.h2-parent {
position: absolute;
top: 0;
left: 0;
height: 100%;
max-width: 600px;
width: 600px;
padding-left: 10px;
padding-right: 10px;
z-index: 10;
}
h2
{
position: relative;
width: 100%;
top: 40%;
transform: translateY(-50%);
font-size: 5vw;
color: rgba(255,255,255,0.5);
text-transform: uppercase;
}
.abs-h2
{
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
color: #5865f2;
-webkit-text-stroke: 0vw rgb(51, 51, 51);
border-right: 2px solid #5865f2;
overflow: hidden;
animation: animate-t 6s linear infinite;
}
.abs-h2 h2
{
position: relative;
width: 600px;
top: 40%;
left:10px;
transform: translateY(-50%);
font-size: 5vw;
color: #5865f2;
text-transform: uppercase;
}
and change html to
<div class="h2-parent">
<h2 data-text="Improve your Server...">Improve your Server...</h2>
<div class="abs-h2">
<h2 data-text="Improve your Server...">Improve your Server...</h2>
</div>
</div>
demo in js<>fiddle

how to stop text animation in css

My animation is not ending at the end of text what do I do to make it stop after displaying some text.
h2 {
justify-content: center;
position: relative;
font-size: 14vw;
color: #ffffff;
-webkit-text-stroke: 0.3vw #ffffff;
text-transform: uppercase;
}
h2::before {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
color: #01fe87;
-webkit-text-stroke: 0vw #ffffff;
border-right: 2px solid #ffffff;
overflow: hidden;
animation: animate 6s linear;
}
#keyframes animate {
0%,
100% {
width: 0;
}
70%,
90% {
width: 100%;
}
}
<h2 data-text="Hi..">Hi..</h2>
I'm a beginner so don't know a lot of things
h2 {
justify-content: center;
position: relative;
font-size: 14vw;
color: #ffffff;
-webkit-text-stroke: 0.3vw #ffffff;
text-transform: uppercase;
}
h2::before {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
color: #01fe87;
-webkit-text-stroke: 0vw #ffffff;
border-right: 2px solid #ffffff;
overflow: hidden;
animation: animate 6s linear;
}
#keyframes animate {
0%,
100% {
width: 0;
}
70%,
90% {
width: 100%;
}
}
<h2 data-text="Hi Atih <3">Hi Atih <3</h2>
I just played with width and it works
width: 0; was causing the issue
h2 {
justify-content: center;
position: relative;
font-size: 14vw;
color: #ffffff;
-webkit-text-stroke: 0.3vw #ffffff;
text-transform: uppercase;
}
h2 {
content: attr(data-text);
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
color: #01fe87;
-webkit-text-stroke: 0vw #ffffff;
border-right: 2px solid #ffffff;
overflow: hidden;
animation: animate 6s linear;
animation-fill-mode: forwards;
}
#keyframes animate {
0% {
width: 100px;
height: 100px;
}
100% {
width: 100%;
height: 100%;
}
}
<h2 data-text="Hi..">Hi..</h2>

Keep everything centered for different browser resolution

I am trying to keep everything centered as the browser changes size. I have tried messing around with the position, but I haven't gotten that to work for everything.
I'm also having trouble centering my font-awesome icons. They are too far to the right, which I have tried to counter by setting it to left: 49%; but that just makes it even more wonky as the sizes shift around.
body {
font-family: "Lato", sans-serif;
color: #fff;
background-color: #21d4fd;
background-image: linear-gradient(19deg, #21d4fd, #b721ff);
background-size: 10%, 10%;
background-repeat: repeat;
animation: change 10s ease-in-out infinite;
}
#name {
font-size: 75px;
font-kerning: auto;
text-transform: uppercase;
letter-spacing: 3px;
text-align: center;
}
#schoolText {
text-align: center;
letter-spacing: 5px;
font-size: 20px;
line-height: 25px;
}
.mainText {
border: 5px solid;
border-radius: 5px;
position: absolute;
padding: 10px 100px;
line-height: 10px;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
overflow: hidden;
}
#footer {
text-align: left;
position: absolute;
width: 99%;
left: 1%;
top: 95%;
letter-spacing: 5px;
text-transform: uppercase;
}
#keyframes change {
0% {
background-position: 0, 50%;
}
50% {
background-position: 100%, 50%;
}
10% {
background-position: 0, 50%;
}
}
.media {
padding: 0;
margin: 0;
position: absolute;
top: 65%;
transform: translateY(-53%);
width: 100%;
text-align: center;
}
.btn {
display: inline-block;
width: 90px;
height: 90px;
background: rgb(255, 255, 255, 0.0);
margin: 10px;
border-radius: 30%;
color: rgb(255, 255, 255, 0.4);
overflow: hidden;
position: relative;
}
.btn i {
line-height: 90px;
font-size: 35px;
transition: 0.2s;
}
.btn :hover {
color: white;
}
<div class="mainText">
<h1 id="name">Nick</h1>
<p id="schoolText">Professional Harvard Dropout</p>
</div>
<h6>Centered</h6>
<!-- Social Media Icons -->
<div class="media" style="text-align: center;">
<a class="btn" href="#">
<i class="fab fa-instagram"></i>
</a>
<a class="btn" href="#">
<i class="fab fa-snapchat-ghost"></i>
</a>
</div>

Links not working on Parallax design

I have a link in the final div (slide4) and it is not working. I've messed around with z-index and positioning but that didn't work.
This is my first time messing around with a parallax design and I'm using a template to familiarize myself with it, but I hit a snag in this and can't figure it out.
Here's the codepen: http://codepen.io/anon/pen/bdGcI
CSS:
<style type="text/css">
html {
height: 100%;
overflow: hidden;
}
`body {
margin:0;
padding:0;
perspective: 1px;
transform-style: preserve-3d;
height: 100%;
overflow-y: scroll;
overflow-x: hidden;
font-family: Oswald;
}`body {
margin:0;
padding:0;
perspective: 1px;
transform-style: preserve-3d;
height: 100%;
overflow-y: scroll;
overflow-x: hidden;
font-family: Oswald;
}
a:link {
text-decoration: none;
color: #fff;
}
a:visited {
text-decoration: none;
color: #ccc;
}
a:hover {
text-decoration: underline;
color: #B22222;
}
a:active {
text-decoration: underline;
}
h1 {
font-size: 550%
}
h2 {
font-size: 250%
}
p {
font-size: 140%;
line-height: 150%;
color: #333;
}
p2 {
font-size: 300%;
line-height: 150%;
color: #fff;
}
.slide {
position: relative;
padding: 25vh 10%;
min-height: 100vh;
width: 100vw;
box-sizing: border-box;
box-shadow: 0 -1px 10px rgba(0, 0, 0, .7);
transform-style: inherit;
}
img {
position: absolute;
top: 50%;
left: 35%;
width: 320px;
height: 240px;
transform: translateZ(.25px) scale(.75) translateX(-94%) translateY(-100%) rotate(2deg);
padding: 1px;
border-radius: 10px;
background: rgba(240,230,220, .7);
box-shadow: 0 0 1px rgba(0, 0, 0, .7);
}
img:last-of-type {
transform: translateZ(.4px) scale(.6) translateX(-104%) translateY(-40%) rotate(-5deg);
}
.slide:before {
content: "";
position: absolute;
top: 0;
bottom: 0;
left:0;
right:0;
}
.title {
width: 50%;
padding: 2%;
border-radius: 5px;
background: rgba(240,230,220, .7);
box-shadow: 0 0 8px rgba(0, 0, 0, .7);
}
.slide:nth-child(2n) .title {
margin-left: 0;
margin-right: auto;
}
.slide:nth-child(2n+1) .title {
margin-left: auto;
margin-right: 0;
}
.slide, .slide:before {
background: 50% 50% / cover;
}
.header {
text-align: center;
font-size: 175%;
color: #fff;
text-shadow: 0 4px 4px #000;
}
.header2 {
text-align: center;
font-size: 175%;
color: #fff;
}
#title {
background-image: url("bg2");
background-attachment: fixed;
}
#slide1:before {
background-image: url("bg3");
transform: translateZ(-1px) scale(2);
z-index:-1;
}
#slide2 {
background-image: url("bg4");
background-attachment: fixed;
}
#slide3:before {
background-image: url("bgbg");
transform: translateZ(-1px) scale(2);
z-index:-1;
}
#slide4 {
background: #222;
}
</style>
</head>
HTML in question:
<div id="slide3" class="slide">
<div class="title">
<h2>Music</h2>
<p>words words words.</p>
</div>
</div>
<div id="slide4" class="slide header2">
Final Page Link.
</div>
Because :before pseudo class is causing an overlay over the content as you have written
.slide:before {
content: "";
position: absolute;
/*top:0;*/ /*remove this */
bottom: 0;
left:0;
right:0;
}
Code pen Demo
You have .slide:before with position:absolute; if you remove that it will work, so your problem is that Absolute position is Over the Link and content. If you add position:relative; to ahref or add relative to new Container inside #slide4, it will work..
1http://codepen.io/anon/pen/HGIiF/