How I can remove the space between the elements in html - 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>

Related

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>

Cannot set p vertically

I want display the text on a new line for every p tag, so I did:
<div class="create-holiday">
<p class="create-holiday-title">Create your holiday activity</p>
<p class="create-holiday-subtitle">Hi! What are your holiday interests?</p>
</div>
.create-holiday *
{
margin-top: 100px;
vertical-align: middle;
text-align: center;
}
.create-holiday-title
{
width: 297px;
height: 22px;
color: #333333;
font-family: Montserrat;
font-size: 22px;
font-weight: 700;
}
.create-holiday-subtitle
{
width: 276px;
height: 18px;
color: #333333;
font-family: Roboto;
font-size: 18px;
font-weight: 300;
}
but the p tag are displayed on the same line.. What I did wrong?
It sounds like your p tag's widths are set to less than 100% and/or your p tags are set to a display of inline or inline-block.
In your CSS file, try this:
p {
display: block;
width: 100%;
}
If that doesn't work, you can always add br tags at the end of each p tag, but you really shouldn't have to do that.
Add A br tag in the middle of the p tags so they don't show up on the same line
<p> tags are block level elements, and therefore you don't need <br> tags. Your code seems to work for me...
.create-holiday * {
margin-top: 100px;
vertical-align: middle;
text-align: center;
}
.create-holiday-title {
width: 297px;
height: 22px;
color: #333333;
font-family: Montserrat;
font-size: 22px;
font-weight: 700;
}
.create-holiday-subtitle {
width: 276px;
height: 18px;
color: #333333;
font-family: Roboto;
font-size: 18px;
font-weight: 300;
}
<div class="create-holiday">
<p class="create-holiday-title">Create your holiday activity</p>
<p class="create-holiday-subtitle">Hi! What are your holiday interests?</p>
</div>
<div class="create-holiday">
<p class="create-holiday-title">Create your holiday activity</p>
<p class="create-holiday-subtitle">Hi! What are your holiday interests?</p>
</div>
.create-holiday * {
margin-top: 100px;
display: flex; //make it flex
align-items: center; //flex middle vertical align
justify-content: center; //flex center align
}
.create-holiday-title {
width: 297px;
height: 22px;
overflow: hidden; //force p to height and width size
color: #333333;
font-family: Montserrat;
font-size: 22px;
font-weight: 700;
}
.create-holiday-subtitle {
width: 276px;
height: 18px;
overflow: hidden; //force p to height and width size
color: #333333;
font-family: Roboto;
font-size: 18px;
font-weight: 300;
}

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.

Removing space between h1 and h2

I have stumbled across a problem that I can not seem to solve in any way, maybe I am using divs in a wrong way?
.greeting h1 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 100px;
text-align: center
}
.greeting h2 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 35px;
line-height: 0px;
text-align: center
}
<div class="greeting">
<h1>Hi.</h1>
<h2>Select a group</h2>
</div>
This is the outcome:
I want to decrease the space between my <h1> and <h2>, and I found out that the way to do that was to set line-height in h1 to 0px.
But as I do that my entire page moves up like so:
I want to keep the text at the same position as it was before I change the line-height. I am suspecting that I am using the div class function wrong. This is more of theoretical question.
headings h1 to h6 have margin by default, so you need to reset it, setting: margin:0.
.greeting h1 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 100px;
text-align: center;
margin: 0
}
.greeting h2 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 35px;
text-align: center;
margin: 0
}
<div class="greeting">
<h1>Hi.</h1>
<h2>Select a group</h2>
</div>
HTML heading tags have some default CSS values applied in most browsers. Following are the values of h1 and h2 that are applied to them by default, so you need to override the margin-bottom of h1 and margin-top of h2 if you want to decrease the spacing between your h1 and h2.
h1 {
display: block;
font-size: 2em;
margin-top: 0.67em;
margin-bottom: 0.67em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
h2 {
display: block;
font-size: 1.5em;
margin-top: 0.83em;
margin-bottom: 0.83em;
margin-left: 0;
margin-right: 0;
font-weight: bold;
}
.greeting h1 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 100px;
text-align: center;
margin-bottom: 0;
}
.greeting h2 {
font-family: 'Raleway', sans-serif;
font-weight: lighter;
font-size: 35px;
line-height: 0px;
text-align: center;
margin-top: 0;
}
<div class="greeting">
<h1>Hi.</h1>
<h2>Select a group</h2>
</div>
Just add the following lines
.greeting h1 {
margin:0px;
line-height:35px;
}
.greeting h2 {
margin:0px;
line-height:35px;
}
If you just want you to assign the margin only for this block you do not need to define it globally you can just do the same this using inline CSS
<h1 style="margin-bottom: 0">Hi</h1>
<h2 style="margin-top: 0">Select a group</h2>

Trying to remove padding from my h2 titles

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;
}