Padding Left weird behavior on vertical position
up vote
2
down vote
favorite
I'm having a hard time figuring it out a weird behavior. So, I have this div with a couple paragraphs, and when I set the padding left within the div so I have all paragraphs left aligned, instead of just the paragraphs being left-aligned, they also get pushed up to the top as if I'm positioning them vertically up as well. I tried testing to see what's going on, it seems like the more padding left I apply to the parent div, the more the paragraphs within the div get pushed up to the top. I tried looking at W3C standards about padding-left to see if there is any relationship with margin top and/or bottom or if it affects the top and bottom position of elements, and I found nothing about. Also, tried see if there is anything here on stackoverflow that can help me figure out what's going on and couldn't find it either.
I'm sure I can fix the problem by applying more margin top to the paragraphs within the div to get the paragraphs where I want, but that's not the solution I'm looking for. I want to know why does applying padding-left to the parent div, not just pushes it's paragraph children to the right, but also position them up to the top the more padding-left I apply to the div?
Has anybody even come across something like that?
UPDATE: Here is the code for better explanation of the problem:
Html:
<div id="home-page">
<div id="intro-page" class="animated FadeInLeft">
<canvas class="animated fadeInUp" id="canvas"></canvas>
<p class="animated fadeInUp" id="p1">Lorem ipsum dolor sit amet, <br> consectetuer adipiscing elit!</p>
<p class="animated fadeInUp" id="quote">“consectetuer adipiscing elit, <br>no, and WOW! consectetuer adipiscing elit.” <br> consectetuer adipiscing elit</p>
<hr class="animated fadeInUpBig">
</div>
</div>
Css: The div in question in "intro-page". There is the comment in its css padding-left rule. Change it to see what I mean
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
}
body {
background-color: #000;
}
#home-page {
height: 100vh;
width: 100%;
}
#intro-page {
width: calc(100% - 120px);
height: 100vh;
background: url(images/light-bulb.jpeg);
background-size: cover;
display: inline-block;
vertical-align: top;
overflow-y: hidden;
padding-left: 5%; /* Change this padding to 50% and see what I
mean*/
}
#intro-page:before {
content: "Hello!";
color: #ffffff;
position: absolute;
left: 6%;
top: 20%;
font-size: 700%;
animation: upAndDown 6s linear infinite;
font-family: 'PT Serif', serif;
}
@keyframes upAndDown {
0% {
transform: translateY(-20%);
}
50% {
transform: translateY(0%);
}
100% {
transform: translateY(-20%);
}
}
#intro-page p {
color: #bababa;
font-family: 'Roboto Condensed', sans-serif;
}
#intro-page #p1 {
font-size: 240%;
margin-top: 26%;
line-height: 50px;
}
#intro-page #quote {
margin-top: 5%;
font-size: 110%;
font-weight: 300;
letter-spacing: 1px;
}
#intro-page hr {
width: 32%;
margin-top: 2%;
}
javascript html5 css3
add a comment |
up vote
2
down vote
favorite
I'm having a hard time figuring it out a weird behavior. So, I have this div with a couple paragraphs, and when I set the padding left within the div so I have all paragraphs left aligned, instead of just the paragraphs being left-aligned, they also get pushed up to the top as if I'm positioning them vertically up as well. I tried testing to see what's going on, it seems like the more padding left I apply to the parent div, the more the paragraphs within the div get pushed up to the top. I tried looking at W3C standards about padding-left to see if there is any relationship with margin top and/or bottom or if it affects the top and bottom position of elements, and I found nothing about. Also, tried see if there is anything here on stackoverflow that can help me figure out what's going on and couldn't find it either.
I'm sure I can fix the problem by applying more margin top to the paragraphs within the div to get the paragraphs where I want, but that's not the solution I'm looking for. I want to know why does applying padding-left to the parent div, not just pushes it's paragraph children to the right, but also position them up to the top the more padding-left I apply to the div?
Has anybody even come across something like that?
UPDATE: Here is the code for better explanation of the problem:
Html:
<div id="home-page">
<div id="intro-page" class="animated FadeInLeft">
<canvas class="animated fadeInUp" id="canvas"></canvas>
<p class="animated fadeInUp" id="p1">Lorem ipsum dolor sit amet, <br> consectetuer adipiscing elit!</p>
<p class="animated fadeInUp" id="quote">“consectetuer adipiscing elit, <br>no, and WOW! consectetuer adipiscing elit.” <br> consectetuer adipiscing elit</p>
<hr class="animated fadeInUpBig">
</div>
</div>
Css: The div in question in "intro-page". There is the comment in its css padding-left rule. Change it to see what I mean
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
}
body {
background-color: #000;
}
#home-page {
height: 100vh;
width: 100%;
}
#intro-page {
width: calc(100% - 120px);
height: 100vh;
background: url(images/light-bulb.jpeg);
background-size: cover;
display: inline-block;
vertical-align: top;
overflow-y: hidden;
padding-left: 5%; /* Change this padding to 50% and see what I
mean*/
}
#intro-page:before {
content: "Hello!";
color: #ffffff;
position: absolute;
left: 6%;
top: 20%;
font-size: 700%;
animation: upAndDown 6s linear infinite;
font-family: 'PT Serif', serif;
}
@keyframes upAndDown {
0% {
transform: translateY(-20%);
}
50% {
transform: translateY(0%);
}
100% {
transform: translateY(-20%);
}
}
#intro-page p {
color: #bababa;
font-family: 'Roboto Condensed', sans-serif;
}
#intro-page #p1 {
font-size: 240%;
margin-top: 26%;
line-height: 50px;
}
#intro-page #quote {
margin-top: 5%;
font-size: 110%;
font-weight: 300;
letter-spacing: 1px;
}
#intro-page hr {
width: 32%;
margin-top: 2%;
}
javascript html5 css3
2
How about you post a demonstration of the problem here, so we can reproduce it, and then give you an answer that would fit your current question? As far as your question goes, I don't see any correlation between padding-left and unexplained top alignment of it's children, so a Minimal, Complete, and Verifiable example would be a lifesavior
– Icepickle
Nov 11 at 0:37
Just updated it with the code
– einacio
Nov 11 at 0:57
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I'm having a hard time figuring it out a weird behavior. So, I have this div with a couple paragraphs, and when I set the padding left within the div so I have all paragraphs left aligned, instead of just the paragraphs being left-aligned, they also get pushed up to the top as if I'm positioning them vertically up as well. I tried testing to see what's going on, it seems like the more padding left I apply to the parent div, the more the paragraphs within the div get pushed up to the top. I tried looking at W3C standards about padding-left to see if there is any relationship with margin top and/or bottom or if it affects the top and bottom position of elements, and I found nothing about. Also, tried see if there is anything here on stackoverflow that can help me figure out what's going on and couldn't find it either.
I'm sure I can fix the problem by applying more margin top to the paragraphs within the div to get the paragraphs where I want, but that's not the solution I'm looking for. I want to know why does applying padding-left to the parent div, not just pushes it's paragraph children to the right, but also position them up to the top the more padding-left I apply to the div?
Has anybody even come across something like that?
UPDATE: Here is the code for better explanation of the problem:
Html:
<div id="home-page">
<div id="intro-page" class="animated FadeInLeft">
<canvas class="animated fadeInUp" id="canvas"></canvas>
<p class="animated fadeInUp" id="p1">Lorem ipsum dolor sit amet, <br> consectetuer adipiscing elit!</p>
<p class="animated fadeInUp" id="quote">“consectetuer adipiscing elit, <br>no, and WOW! consectetuer adipiscing elit.” <br> consectetuer adipiscing elit</p>
<hr class="animated fadeInUpBig">
</div>
</div>
Css: The div in question in "intro-page". There is the comment in its css padding-left rule. Change it to see what I mean
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
}
body {
background-color: #000;
}
#home-page {
height: 100vh;
width: 100%;
}
#intro-page {
width: calc(100% - 120px);
height: 100vh;
background: url(images/light-bulb.jpeg);
background-size: cover;
display: inline-block;
vertical-align: top;
overflow-y: hidden;
padding-left: 5%; /* Change this padding to 50% and see what I
mean*/
}
#intro-page:before {
content: "Hello!";
color: #ffffff;
position: absolute;
left: 6%;
top: 20%;
font-size: 700%;
animation: upAndDown 6s linear infinite;
font-family: 'PT Serif', serif;
}
@keyframes upAndDown {
0% {
transform: translateY(-20%);
}
50% {
transform: translateY(0%);
}
100% {
transform: translateY(-20%);
}
}
#intro-page p {
color: #bababa;
font-family: 'Roboto Condensed', sans-serif;
}
#intro-page #p1 {
font-size: 240%;
margin-top: 26%;
line-height: 50px;
}
#intro-page #quote {
margin-top: 5%;
font-size: 110%;
font-weight: 300;
letter-spacing: 1px;
}
#intro-page hr {
width: 32%;
margin-top: 2%;
}
javascript html5 css3
I'm having a hard time figuring it out a weird behavior. So, I have this div with a couple paragraphs, and when I set the padding left within the div so I have all paragraphs left aligned, instead of just the paragraphs being left-aligned, they also get pushed up to the top as if I'm positioning them vertically up as well. I tried testing to see what's going on, it seems like the more padding left I apply to the parent div, the more the paragraphs within the div get pushed up to the top. I tried looking at W3C standards about padding-left to see if there is any relationship with margin top and/or bottom or if it affects the top and bottom position of elements, and I found nothing about. Also, tried see if there is anything here on stackoverflow that can help me figure out what's going on and couldn't find it either.
I'm sure I can fix the problem by applying more margin top to the paragraphs within the div to get the paragraphs where I want, but that's not the solution I'm looking for. I want to know why does applying padding-left to the parent div, not just pushes it's paragraph children to the right, but also position them up to the top the more padding-left I apply to the div?
Has anybody even come across something like that?
UPDATE: Here is the code for better explanation of the problem:
Html:
<div id="home-page">
<div id="intro-page" class="animated FadeInLeft">
<canvas class="animated fadeInUp" id="canvas"></canvas>
<p class="animated fadeInUp" id="p1">Lorem ipsum dolor sit amet, <br> consectetuer adipiscing elit!</p>
<p class="animated fadeInUp" id="quote">“consectetuer adipiscing elit, <br>no, and WOW! consectetuer adipiscing elit.” <br> consectetuer adipiscing elit</p>
<hr class="animated fadeInUpBig">
</div>
</div>
Css: The div in question in "intro-page". There is the comment in its css padding-left rule. Change it to see what I mean
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: 'Roboto', sans-serif;
}
body {
background-color: #000;
}
#home-page {
height: 100vh;
width: 100%;
}
#intro-page {
width: calc(100% - 120px);
height: 100vh;
background: url(images/light-bulb.jpeg);
background-size: cover;
display: inline-block;
vertical-align: top;
overflow-y: hidden;
padding-left: 5%; /* Change this padding to 50% and see what I
mean*/
}
#intro-page:before {
content: "Hello!";
color: #ffffff;
position: absolute;
left: 6%;
top: 20%;
font-size: 700%;
animation: upAndDown 6s linear infinite;
font-family: 'PT Serif', serif;
}
@keyframes upAndDown {
0% {
transform: translateY(-20%);
}
50% {
transform: translateY(0%);
}
100% {
transform: translateY(-20%);
}
}
#intro-page p {
color: #bababa;
font-family: 'Roboto Condensed', sans-serif;
}
#intro-page #p1 {
font-size: 240%;
margin-top: 26%;
line-height: 50px;
}
#intro-page #quote {
margin-top: 5%;
font-size: 110%;
font-weight: 300;
letter-spacing: 1px;
}
#intro-page hr {
width: 32%;
margin-top: 2%;
}
javascript html5 css3
javascript html5 css3
edited Nov 11 at 1:02
asked Nov 11 at 0:31
einacio
427
427
2
How about you post a demonstration of the problem here, so we can reproduce it, and then give you an answer that would fit your current question? As far as your question goes, I don't see any correlation between padding-left and unexplained top alignment of it's children, so a Minimal, Complete, and Verifiable example would be a lifesavior
– Icepickle
Nov 11 at 0:37
Just updated it with the code
– einacio
Nov 11 at 0:57
add a comment |
2
How about you post a demonstration of the problem here, so we can reproduce it, and then give you an answer that would fit your current question? As far as your question goes, I don't see any correlation between padding-left and unexplained top alignment of it's children, so a Minimal, Complete, and Verifiable example would be a lifesavior
– Icepickle
Nov 11 at 0:37
Just updated it with the code
– einacio
Nov 11 at 0:57
2
2
How about you post a demonstration of the problem here, so we can reproduce it, and then give you an answer that would fit your current question? As far as your question goes, I don't see any correlation between padding-left and unexplained top alignment of it's children, so a Minimal, Complete, and Verifiable example would be a lifesavior
– Icepickle
Nov 11 at 0:37
How about you post a demonstration of the problem here, so we can reproduce it, and then give you an answer that would fit your current question? As far as your question goes, I don't see any correlation between padding-left and unexplained top alignment of it's children, so a Minimal, Complete, and Verifiable example would be a lifesavior
– Icepickle
Nov 11 at 0:37
Just updated it with the code
– einacio
Nov 11 at 0:57
Just updated it with the code
– einacio
Nov 11 at 0:57
add a comment |
1 Answer
1
active
oldest
votes
up vote
2
down vote
accepted
From W3C Spec about margin properties:
The percentage is calculated with respect to the width of the
generated box's containing block. Note that this is true for
'margin-top' and 'margin-bottom' as well. If the containing block's
width depends on this element, then the resulting layout is undefined
in CSS 2.1.
This part of your css is implied :
#intro-page #p1 {
font-size: 240%;
margin-top: 26%;
line-height: 50px;
}
When augmenting the padding of #intro-page, you are reducing the width of the paragraph, therefore reducing the top margin.
Thanks, your answer makes sense. I did read about how the percentage padding/margin is calculated. I just didn't think enough to realize that the more padding I apply to the div, the smaller the paragraph's width gets. Well done explanation.
– einacio
Nov 11 at 1:12
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
From W3C Spec about margin properties:
The percentage is calculated with respect to the width of the
generated box's containing block. Note that this is true for
'margin-top' and 'margin-bottom' as well. If the containing block's
width depends on this element, then the resulting layout is undefined
in CSS 2.1.
This part of your css is implied :
#intro-page #p1 {
font-size: 240%;
margin-top: 26%;
line-height: 50px;
}
When augmenting the padding of #intro-page, you are reducing the width of the paragraph, therefore reducing the top margin.
Thanks, your answer makes sense. I did read about how the percentage padding/margin is calculated. I just didn't think enough to realize that the more padding I apply to the div, the smaller the paragraph's width gets. Well done explanation.
– einacio
Nov 11 at 1:12
add a comment |
up vote
2
down vote
accepted
From W3C Spec about margin properties:
The percentage is calculated with respect to the width of the
generated box's containing block. Note that this is true for
'margin-top' and 'margin-bottom' as well. If the containing block's
width depends on this element, then the resulting layout is undefined
in CSS 2.1.
This part of your css is implied :
#intro-page #p1 {
font-size: 240%;
margin-top: 26%;
line-height: 50px;
}
When augmenting the padding of #intro-page, you are reducing the width of the paragraph, therefore reducing the top margin.
Thanks, your answer makes sense. I did read about how the percentage padding/margin is calculated. I just didn't think enough to realize that the more padding I apply to the div, the smaller the paragraph's width gets. Well done explanation.
– einacio
Nov 11 at 1:12
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
From W3C Spec about margin properties:
The percentage is calculated with respect to the width of the
generated box's containing block. Note that this is true for
'margin-top' and 'margin-bottom' as well. If the containing block's
width depends on this element, then the resulting layout is undefined
in CSS 2.1.
This part of your css is implied :
#intro-page #p1 {
font-size: 240%;
margin-top: 26%;
line-height: 50px;
}
When augmenting the padding of #intro-page, you are reducing the width of the paragraph, therefore reducing the top margin.
From W3C Spec about margin properties:
The percentage is calculated with respect to the width of the
generated box's containing block. Note that this is true for
'margin-top' and 'margin-bottom' as well. If the containing block's
width depends on this element, then the resulting layout is undefined
in CSS 2.1.
This part of your css is implied :
#intro-page #p1 {
font-size: 240%;
margin-top: 26%;
line-height: 50px;
}
When augmenting the padding of #intro-page, you are reducing the width of the paragraph, therefore reducing the top margin.
answered Nov 11 at 1:05
AllirionX
1765
1765
Thanks, your answer makes sense. I did read about how the percentage padding/margin is calculated. I just didn't think enough to realize that the more padding I apply to the div, the smaller the paragraph's width gets. Well done explanation.
– einacio
Nov 11 at 1:12
add a comment |
Thanks, your answer makes sense. I did read about how the percentage padding/margin is calculated. I just didn't think enough to realize that the more padding I apply to the div, the smaller the paragraph's width gets. Well done explanation.
– einacio
Nov 11 at 1:12
Thanks, your answer makes sense. I did read about how the percentage padding/margin is calculated. I just didn't think enough to realize that the more padding I apply to the div, the smaller the paragraph's width gets. Well done explanation.
– einacio
Nov 11 at 1:12
Thanks, your answer makes sense. I did read about how the percentage padding/margin is calculated. I just didn't think enough to realize that the more padding I apply to the div, the smaller the paragraph's width gets. Well done explanation.
– einacio
Nov 11 at 1:12
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244769%2fpadding-left-weird-behavior-on-vertical-position%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
How about you post a demonstration of the problem here, so we can reproduce it, and then give you an answer that would fit your current question? As far as your question goes, I don't see any correlation between padding-left and unexplained top alignment of it's children, so a Minimal, Complete, and Verifiable example would be a lifesavior
– Icepickle
Nov 11 at 0:37
Just updated it with the code
– einacio
Nov 11 at 0:57