Trying to remove padding from my h2 titles - html

Hi I'm trying to bring my h2 Titles towards the top of the div they're in, but I can't figure out how to remove the padding / margin / whatever it is that is causing them to be spaced down so far.
This is the first time I've tried using "sections" and I'm using them to create a parallax scrolling website. I've uploaded the site so you can see it in action. Where it states "Title One", "Title Two", etc, this is what I want to bring up towards the top of the div they're inside of.
example website url... http://www.littleroomproductions.com/jQtest/
Below are the parts of code that I think need to be changed in order to bring the titles up to the top of the div...
//HTML
<section class="box content">
<div id="me"></div>
<div class="container">
<h2>Title One</h2>
<p>This is where text goes </p>
<div class="someContent">
<p>click me</p>
</div>
</div>
</section>
//CSS used
section.box:last-child {
margin-bottom: 0;
}
section.box h2 {
padding-top: 0;
margin-bottom: 20px;
color: #606060;
font-family: serif;
font-size: 30px;
}
section.box p {
padding-top: 0;
margin-bottom: 20px;
color: black;
font-size: 20px;
font-family: cursive;
font-weight: 300;
}
section.box p:last-child {
margin-bottom: 300px;
}
section.box.content {
padding-top: 0;
padding-left: 40px;
padding-bottom: 40px;
}
section.box.slide {
padding: 240px 0;
background-position: 0 0;
}
section.box.slide h1 {
color: yellow;
font-size: 48px;
/*line-height: 1;*/
font-weight: 700;
text-align: center;
text-transform: uppercase;
text-shadow: 0 0 10px black;
}

Your
#me #projects #hire have a 100px padding-top;

try this
section.box h2 {
padding-top: 0;
margin: -7px 0;
color: #606060;
font-family: serif;
font-size: 30px;
}

Related

Why can't I change the margin of my paragraphs?

For some context, I am brand new to programming and only about two hours in to an HTML/CSS tutorial, so I don't know many elements, properties etc. beyond what you see in my code here. Forgive me if my terminology is inaccurate, but hopefully this makes sense.
I am doing an exercise at the end of a particular lesson trying to match a design, and trying to eliminate the margin (or blank space) between my first paragraph line and my second paragraph line. As you can see, I've tried changing the margin, line-height, and padding to zero (anything I could think of) but the gap remains.
In the solution code for this exercise, I see the teacher chose to change the bottom margin targeting all paragraphs instead of the specific paragraph classes to make this happen. I would like to understand why that would work, but targeting the specific paragraph classes is not affecting the margin. I assume I will understand this later, but I hesitate to move on until I do.
My code
<style>
p {
font-family: arial;
}
.price {
font-size: 36px;
}
.currency {
margin-left: 12px;
font-size: 16px;
color: gray;
margin-bottom: 0px;
line-height: 0px;
padding-bottom: 0;
}
.change {
padding-top: 0;
margin-top: 0;
color: green;
font-size: 16px;
line-height: 0;
}
.after-hours {
color: gray;
}
.after-hours-change {
color: red;
}
</style>
<p class="price">1,049.61<span class="currency">USD</span></p>
<p class="change">+18.05 (1.75%) today</p>
<p class="after-hours">After hours 1,048.00
<span class="after-hours-change">-1.61 (0.15%)</span></p>
Picture of my result
The teacher's solution code
<style>
p {
font-family: Arial;
margin-top: 0;
margin-bottom: 0;
}
.price {
font-size: 32px;
margin-bottom: 5px;
}
.currency {
font-size: 16px;
color: rgb(100, 100, 100);
}
.change {
color: rgb(24, 128, 56);
margin-bottom: 8px;
}
.after-hours {
color: rgb(100, 100, 100);
}
.after-hours-change {
color: rgb(235, 39, 39);
}
</style>
<p class="price">
1,049.61 <span class="currency">USD</span>
</p>
<p class="change">
+18.05 (1.75%) today
</p>
<p class="after-hours">
After hours 1,048.00
<span class="after-hours-change">-1.61 (0.15%)</span>
</p>
Picture of his result
Because the margin-bottom: 5px; is not set by you to the .price.
Paragraph is a block element, so it adds up a margin below, but the font-size also counts in -- as I can see.
p {
font-family: arial;
}
.price {
font-size: 32px;
margin-bottom: 0.5em;
}
.currency {
margin-left: 12px;
font-size: 16px;
color: gray;
margin-bottom: 0px;
line-height: 0px;
padding-bottom: 0;
}
.change {
padding-top: 0;
margin-top: 0;
color: green;
font-size: 16px;
line-height: 0;
}
.after-hours {
color: gray;
}
.after-hours-change {
color: red;
}
<p class="price">1,049.61<span class="currency">USD</span></p>
<p class="change">+18.05 (1.75%) today</p>
<p class="after-hours">After hours 1,048.00<span class="after-hours-change">-1.61 (0.15%)</span></p>

How I can remove the space between the elements in html

How i can remove the space between strings "Text 1" and "its simple"? I need to create whitespace in only 10 pixel, i.e. via margin-top: 10px;. But when i use margin-top: 10px;, total space is 10 pixel + shift.
In my opinion, the white space are formed directly by the margin of the font. With what element can i change the size of this whitespace?
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.title {
font-family: Roboto;
font-size: 41px;
font-weight: 900;
text-transform: uppercase;
color: #f9bf3b;
text-align: center;
}
.simple .title_big {
font-family: Roboto;
font-size: 80px;
font-weight: 900;
text-transform: uppercase;
color: #000000;
text-align: center;
}
<h1 class="title">Text 1</h1>
<div class="simple">
<h2 class="title_big">its simple!</h2>
<div class="line"></div>
</div>
<h2 class="title">Text 2</h2>
Set your line-height equal to 1 on the respective classes. This is equivalent to line-height: 100%;, meaning 100% of the font size for that element, not 100% of its height.
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.title {
font-family: Roboto;
font-size: 41px;
font-weight: 900;
text-transform: uppercase;
color: #f9bf3b;
text-align: center;
}
.simple .title_big {
font-family: Roboto;
font-size: 80px;
font-weight: 900;
text-transform: uppercase;
color: #000000;
text-align: center;
}
h1.title,
h2.title_big {
line-height: 1;
}
<h1 class="title">Text 1</h1>
<div class="simple">
<h2 class="title_big">its simple!</h2>
<div class="line"></div>
</div>
<h2 class="title">Text 2</h2>
Is this what you happened to be looking for? I used a negative margin in the .simple .title_big class (-15px to be exact) to remove the margin that was in the text to add less whitespace then there was before. But still leaving you with some.
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
.title {
font-family: Roboto;
font-size: 41px;
font-weight: 900;
text-transform: uppercase;
color: #f9bf3b;
text-align: center;
}
.simple .title_big {
font-family: Roboto;
font-size: 80px;
font-weight: 900;
text-transform: uppercase;
color: #000000;
text-align: center;
margin: -15px 0;
}
<h1 class="title">Text 1</h1>
<div class="simple">
<h2 class="title_big">its simple!</h2>
<div class="line"></div>
</div>
<h2 class="title">Text 2</h2>

How to adjust the verticle distance between two lines of text in a div without using position?

I have two lines of text that compose a title and date section for small little blog I'm making. I want to adjust the vertical distance between the two so that the second line of text is almost directly underneath the first. As it stands right now, there is a giant gap between the two. What is the standard fix for this? I have tried adjusting the position variable in the past, but it always makes the resizing of my website wonky. I would prefer not to mess with this. Thanks!
.StoriesTitle {
font-size: 25px;
margin-left: 23%;
height: 10px;
}
.chinese {
font-family: "Yu Gothic";
font-weight: normal;
}
.StoriesDate {
padding-bottom: 10pt;
font-size: 12pt;
margin-left: 1pt;
}
<section class="stories">
<div class="StoriesTitle">
<h2>Title Length</h2>
<div class="StoriesDate">
<h3>2018<span class="chinese">年</span>09<span class="chinese">月</span> 28<span class="chinese">日</span</h3>
</div>
</div>
</section>
Just remove the margin from h2 and h3 tags and add height: auto to your StoriesTitle class.
h2, h3 {
margin: 0;
}
.stories {
margin-top: 15px;
}
.StoriesTitle {
font-size: 25px;
margin-left: 23%;
height: auto;
}
.chinese {
font-family: "Yu Gothic";
font-weight: normal;
}
.StoriesDate {
padding-bottom: 10pt;
font-size: 12pt;
margin-left: 1pt;
}
<section class="stories">
<div class="StoriesTitle">
<h2>Title Length</h2>
<div class="StoriesDate">
<h3>2018<span class="chinese">年</span>09<span class="chinese">月</span> 28<span class="chinese">日</span></h3>
</div>
</div>
</section>
.StoriesTitle h2 {
margin-bottom: 0;
}
.StoriesDate h3 {
margin-top: 0;
}
Try to remove the margin of your h2 and h3 elements
.StoriesTitle {
font-size: 25px;
margin-left: 23%;
height: 10px;
}
.chinese {
font-family: "Yu Gothic";
font-weight: normal;
}
.StoriesDate {
padding-bottom: 10pt;
font-size: 12pt;
margin-left: 1pt;
}
.StoriesTitle > h2, .StoriesDate > h3 {
margin: 0px;
}
<section class="stories">
<div class="StoriesTitle">
<h2>Title Length</h2>
<div class="StoriesDate">
<h3>
2018<span class="chinese">年</span>09<span class="chinese">月</span> 28<span class="chinese">日</span>
</h3>
</div>
</div>
</section>

Changing line height of horizontal rule

I have followed a tutorial on the internet and I have the following html template:
body {
font-weight: 200;
font-size: 14px;
}
.header {
font-size: 20px;
font-weight: 100;
text-align: center;
color: #007cae;
}
.title {
font-size: 22px;
font-weight: 100;
/* text-align: right;*/
padding: 10px 20px 0px 20px;
}
.title span {
color: #007cae;
}
.details {
padding: 10px 20px 0px 20px;
text-align: left !important;
/*margin-left: 40%;*/
}
.hrItem {
border: none;
height: 1px;
/* Set the hr color */
color: #333; /* old IE */
background-color: #fff; /* Modern Browsers */
}
<div class='wrapper'>
<div class='header'>
<p class='title'>Invoice #<hr class='hrItem' /> </p>
</div>
<div>
<div class='details'>
Bill to: <br/>
Amount: <br/>
Date:
</div>
</div>
The problem that I am having is that between Invoice # and the horizontal rule there is a significant amount of white space that I want to remove. I tried changing the padding and the margin in the .hrItem,.tittle and .header, however, this made no difference. Is it possible to remove that white space or should I reconsider the method of adding the horizontal line?
You need to place the <hr> outside of your <p>, as having it inside is invalid HTML and actually ends up creating an empty <p></p>, which creates more space:
What you should have is:
<div class='header'>
<p class='title'>Invoice #</p>
<hr class='hrItem' />
</div>
Once you make that change, you can control the spacing between the .hrItem and the .title by changing their margin properties (I set both to 0):
body {
font-weight: 200;
font-size: 14px;
}
.header {
font-size: 20px;
font-weight: 100;
text-align: center;
color: #007cae;
}
.title {
font-size: 22px;
font-weight: 100;
/* text-align: right;*/
padding: 10px 20px 0px 20px;
margin: 0;
}
.title span {
color: #007cae;
}
.details {
padding: 10px 20px 0px 20px;
text-align: left !important;
/*margin-left: 40%;*/
}
.hrItem {
border: none;
height: 1px;
/* Set the hr color */
color: #333; /* old IE */
background-color: #fff; /* Modern Browsers */
margin: 0;
}
<div class='wrapper'>
<div class='header'>
<p class='title'>Invoice #</p>
<hr class='hrItem' />
</div>
<div class='details'>
Bill to: <br/>
Amount: <br/>
Date:
</div>
</div>

Big height out of nowhere

Somehow one of the group of the same block elements on the picture gets inexplicably big height. Styles shown on the pic don't suggest that kind of behavior for this element. In fact, height isn't even set for those h3's.
Browser screenshot
The html is
<section class="about-us">
<div class="wrapper clearfix">
<h2 class="about-us-heading section-heading red-black-stressing-line-at-left">About Us</h2>
<p class="about-us-statement section-saying about-us-saying">This is who we are - or at least who we strive to be...</p>
<div class="about-more">
<p class="about-saying">If you can't explain it simply, you don't understand it enough.</p>
The more you know
</div>
<div class="about-work-details">
<h3 class="about-details-heading typography-icon">Typography</h3>
<p class="about-details-text">...</p>
</div>
<div class="about-work-details">
<h3 class="about-details-heading curve-with-dots-icon">Full icon set</h3>
<p class="about-details-text">...</p>
</div>
<div class="about-work-details">
<h3 class="about-details-heading triangular-ruler-icon">Accurate</h3>
<p class="about-details-text">...</p>
</div>
</div>
</section>
Three same div.about-work-details elements.
The default css is
.about-us{
background-color: #fff;
position: relative;
}
.about-us-heading{
color: #272d32;
}
.about-us-statement{
color: #4e5860;
margin-bottom: 3.9em;
}
.about-more{
width: 16.875em;
float:left;
margin-right: 1.875em;
}
.about-saying{
font-family: "Open Sans", sans-serif;
font-size: 1.75em;
line-height: 1.4285;
color: #4e5860;
}
.about-more-link{
display: inline-block;
font-family: "Raleway", sans-serif;
line-height: .77;
padding: 1em 2.625em 1em 1.25em;
text-decoration: none;
font-weight: 600;
color: #fff;
text-transform: uppercase;
background: #ff3c1f url(../images/left-arrow.gif) 12.7em .95em no-repeat;
margin-top: 4.25em;
transition: background-color 0.5s;
}
.about-work-details{
width: 16.875em;
float:left;
margin-right: 1.685em;
margin-bottom: 8.1875em;
position: relative;
min-height: 16.875em;
border: 1px solid #edeff2;
}
.about-work-details:last-of-type{
margin-right: 0;
}
.about-details-heading{
font-family: "Open Sans", sans-serif;
font-weight: 700;
font-size: 1.25em;
color: #303030;
text-transform: uppercase;
padding: 0.85em 0 1em 3em;
margin: 1.70em 0 0 1em;
}
Media query modifications
#media screen and (max-width: 860px){
.about-work-details{
width: 70%;
margin: 3em auto;
min-height: 0;
float: none;
}
.about-us{
padding-bottom: 1px;
}
.about-work-details:last-of-type {
margin-right: auto;
}
}
Seems like a floating item behavior issue.
Try removing/commenting float:left; from .about-more.