Problems formatting in HTML - html

The headertext font size changes but it won't be centered. Only just started learning HTML so this is likely a rookie mistake. Any advice is appreciated, thanks!
.main {
margin-left: 220px; /* Same as the width of the sidenav */
margin-top: 20px; /* Same as the width of the sidenav */
font-size: 20px; /* Increased text to enable scrolling */
}
.main headertext {
font-size: 45px;
text-align: center;
}
<div class="main">
<headertext>ExampleTitle</headertext>
<p>Welcome to my website.</p>
</div>

headertext is not a valid HTML element. Change it to a div with a class of headertext and I think that fixes your issue, snippet below:
.main {
margin-left: 220px;
margin-top: 20px;
font-size: 20px;
}
.main .headertext {
font-size: 45px;
text-align: center;
}
<div class="main">
<div class="headertext"> ExampleTitle </div>
<p> Welcome to my website.</p>
</div>

Your problem is there is no <headertext> element. You need to use <h1> (biggest) to <h6> (smallest). If you want it centered, use the following CSS:
h1 {
margin-left: auto;
margin-right: auto;
}

Actually, if you want to it to act as a title (semantically) you should probably give it a h1 tag instead. Like so
.main {
margin-left: 220px;
margin-top: 20px;
font-size: 20px;
}
h1 {
font-size: 45px;
text-align: center;
}
<div class="main">
<h1> ExampleTitle </h1>
<p> Welcome to my website.</p>
</div>
This will tell the browser and people who use screenreaders that it's actually a title. You may benefit from reading up on html tags. This is a useful link and whilst it may seem overwhelming, you'll get used to it pretty quickly. https://www.w3schools.com/tags/ref_byfunc.asp

There is no element called headertext. Instead you can user header which is whole wrapper in standard or h1/h2/h3/h4/h5/h6 which are commonly used to represent headings.
In your code if you want to follow the first heading you can follow the following code:
.main {
margin-left: 220px;
margin-top: 20px;
font-size: 20px;
}
.header-text {
font-size: 45px;
text-align: center;
}
<div class="main">
<h1 class="header-text"> ExampleTitle </h1>
<p> Welcome to my website.</p>
</div>
But it seems in-align with other contents. I guess you are looking for the following.
.main {
/*margin-left: 220px;*/ //remove this line
margin-top: 20px;
font-size: 20px;
text-align: center; //added this line
}
.header-text {
font-size: 45px;
/* text-align: center; */
}
<div class="main">
<h1 class="header-text"> ExampleTitle </h1>
<p> Welcome to my website.</p>
</div>
I added both way that you can try for now. But still there is many ways to give you a solution. Happy journey on HTML,CSS

Related

How can I position the html column of mine in css?

I am currently building my hs project, I'm just a beginner and I am struggling with this column like I want my bio looks like this one (below)
But I can't really do achieve this, this is my HTML and CSS code
html :
<div class="row">
<div class="column">
<img src="photos.png" style="width: 320px;">
</div>
<div class="column" id="david">
<h1>David Watson</h1>
<h2></h2>
</div>
</div>
and here is my CSS code for that
css:
.column {
float: left;
}
.row {
margin-left: 350px;
margin-top: 100px;
}
/* Clear floats after the columns */
h1 {
font-weight: 10;
font-style: italic;
}
and btw this is how it works
use
.row{ display:flex }
then the child element will take side by side position you can have a quick look on this too https://www.w3schools.com/css/css3_flexbox.asp
.row {
display:flex
margin-left: 350px;
margin-top: 100px;
}
.column {
margin:0 2rem;
}
h1 {
font-weight: 10;
font-style: italic;
}

How to make a div fit to the size of the window?

Essentially, i'm trying to emulate the first page of this theme:
http://blackrockdigital.github.io/startbootstrap-grayscale/
I want to make it so that the first section occupies the entire screen, and clicking the button will scroll down to the other pages on the site (I'll be adding the button later. However, I end up with white space no matter what I do. I tried playing around with the percentage of the div in the css, but it didn't seem to do anything. I just want the black background to extend down to the bottom of the window without a scroll bar, no matter the screen size.
Code can be found here: http://codepen.io/pwatrous/pen/qZeaog
body {
width: 100%;
height: 100%;
}
html {
height: 100%;
}
h1 {
margin-top: 0;
padding-top: 10%;
}
.container-fluid {
padding: 0px;
}
.section1 {
background-color: #000000;
height: 100%
}
.title {
font-family: Quicksand;
color: #FFFFFF;
}
#name {
font-size: 5em;
}
#info {
font-size: 3em;
padding-bottom: 4%;
}
#bio {
font-size: 2em;
padding-bottom: 10%;
margin-left: 5%;
margin-right: 5%;
}
.fa-chevron-circle-down {
color: #FFFFFF;
padding-bottom: 4%;
}
Thanks!
To make a div fit the entire screen, try this:
body {
margin: 0;
}
.my_fullscreen_div {
width: 100vw;
height: 100vh;
}
Method 1:
Try adding a background-color in the body.
body {
background-color:black;
}
Method 2:
HTML:
place the section2 div inside the section1 div
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">
<div class="section1 text-center">
<h1 class="title" id="name">Patrick Watrous</h1>
<h2 class="title" id="info">Learn. Implement. Innovate.</h2>
<i class="fa fa-chevron-circle-down fa-5x"></i>
<p class="title" id="bio">The ability to dream up an idea and then recreate it on a computer has always been something that has caused me immense satisfaction. Due to this, I'm pursuing a bachelor's degree at Northeastern University in computer science and business. I'm interested in all facets of design, from Bootstrap to Java. Take a look at my website and see what i've been up to!</p>
<div class="section2 text-center">
<p>Lorem ipsum dolor sit amet,.....
</div>
</div>
</div>
</div>
</div>

Bootstrap H1 Aligning Problems

I need help getting my H1s to align. My code is below. An image of it is also below. I would like for the Spencer Hiltbrand bit at the top to be all the way to the right. The Beautiful Websites, Inspiring Photography part the same it is now. I am using Bootstrap.
Homepage:
.intro {
color: white;
font-weight: 600;
text-align: left;
font-size: 80px;
margin-left: 45px !important;
padding-top: 380px;
}
.name {
text-align: right !important;
}
<!-- Intro Section -->
<section id="intro" class="intro-section">
<div class="container">
<div class="row">
<div class="col-lg-12">
<h1 class="name"><span class="red">Spencer</span> Hiltbrand</h4>
<h1 class="intro"><span class="red">Beautiful</span> Websites, <br>and <span class="red">Inspiring</span> Photography</h1>
</div>
</div>
</div>
</section>
The following line of HTMl you have is invalid:
<h1 class="name"><span class="red">Spencer</span> Hiltbrand</h4>
You're starting with an h1 tag but never closing it because you try to close it with an h4 tag. This may be causing part of your issue if styles aren't working.
To answer your actual question, an easy way to get your top brand/text to the right is simply to use float: right instead of text-align: right.
If you need to align the heading all to the right, then you need to get rid of container, row and col-lg-12 because they introduce padding and margins. The heading's margin-top has been changed little from the top. Please have a look at the HTML, CSS and its working demo.
HTML
<!-- Intro Section -->
<section id="intro" class="intro-section">
<div>
<h1 class="name"><span class="red">Spencer</span> Hiltbrand</h1>
<h1 class="intro"><span class="red">Beautiful</span> Websites, <br>and <span class="red">Inspiring</span> Photography</h1>
</div>
</section>
CSS
.intro {
color: white;
font-weight: 600;
text-align: left;
font-size: 80px;
margin-left: 45px !important;
padding-top: 380px;
}
.name {
text-align: right;
margin: 5px 0 0 0;
}
Still if you have to make use of bootstrap's container, row and col-*, then you need to modify the existing html.

Percent height of <a> element not accurate to parent <div> height

In my assignment, I've been having a lot of issues lately with height:x%; it's not accurate when used in some parts of my code, such as this:
My <a> element, a child of <div>, has a child <img>. <a> has padding of %1, and 100 - 2(to make up for the added height from padding) = 98% height of <div>. Since I want the entire picture to be clickable as a link, I nest the <img> in the <a> element with 100% height and width to fit right in. So I'm thinking at this point, I should see a picture of a dog that at least fits in vertically. However I get this:
https://gyazo.com/0b36f8c7efa70d7dc2b6155c821e1b1e
As you can see, the padding is correct, the width is, but the height is not. It extends by twice the padding of <a>. I tried also subtracting twice the padding from the height yet it makes a very small difference. It's still outside.
div#top {
width: 100%;
height: 20vh;
background-color: black;
color: limegreen;
}
a#homeiconlink {
width: 13%;
height: 98%;
padding: 1%;
float: left;
}
img#homeicon {
width: 100%;
height: 100%;
}
h2#title {
width: 85%;
height: 100%;
float: left;
}
h2 {
margin: 0;
font-family: Arial;
font-variant: small-caps;
}
body {
background-color: yellow;
}
div#sidebar {
width: 15%;
height: 60vh;
background-color: green;
float: left;
}
a {
text-decoration: none;
color: inherit;
}
a.sidebar:hover {
background-color: limegreen;
color: white;
}
a.sidebar {
display: block;
background-color: green;
color: limegreen;
padding: 2.5%;
}
div#contentspace {
width: 85%;
height: 60vh;
margin: 0px;
background-color: limegreen;
color: white;
float: left;
}
div#content {
padding: 2.5%;
}
div#footerspace {
width: 100%;
height: 20vh;
}
footer {
padding: 2.5%;
clear: both;
background-color: darkgreen;
color: limegreen;
margin: 0;
text-align: center;
}
div#testedwith {
font-style: italic;
color: lightgray;
text-align: right;
}
<div id="top">
<a href="home.html" id="homeiconlink">
<img src="dog.png" alt="logo" id="homeicon">
</a>
<h2 id="title">
Adopt a dog or cat Foundation
</h2>
</div>
<div id="sidebar">
<a class="sidebar" href="home.html">Home page</a>
<a class="sidebar" href="browse.html">Browse available pets</a>
<a class="sidebar" href="find.html">Find a dog/cat</a>
<a class="sidebar" href="dogcare.html">Dog Care</a>
<a class="sidebar" href="catcare.html">Cat Care</a>
<a class="sidebar" href="giveaway.html">Have a pet to give away</a>
<a class="sidebar" href="contact.html">Contact us</a>
</div>
<div id="contentspace">
<div id="content">
<h2>
Welcome!
</h2>
<br>
<p>
At Adopt a dog or cat foundation (TM), we strive to save as many endangered dogs and cats lives as possible from the animal pound. We invite all who are loving towards animals to adopt and care for a dog or cat of your choice from somebody who can no
longer give them the care they deserve. We strive to maintain a good community, and have a good reputation for that. Any dog or cat you adopt will most certainly be a good companion and are well trained and disease free. Thank you for helping us
shape the world into a more hospitable one!
<br>
<br>-AADOCF
</p>
</div>
</div>
<div id="footerspace">
<footer>
View disclaimer
<div id="testedwith">tested with Google Chrome</div>
</footer>
</div>
In your CSS, add box-sizing: border-box; a#homeiconlink {...}.
By default, when you specify a height, it does not take margins, padding, or borders into account. Specifying border-box changes this so that the height you specify is total height. More info at https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model and https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

Making Hero Unit in Bootstrap match my needs

I am using Twitter Bootstrap, I am trying to make the Hero Unit the full height of the page and then they can click a button and it scrolls down further. I also want some text to display in the Hero Unit at the bottom of the Unit.
I have added: height: 100%; and vertical-align:bottom; along with: text-align:center;
to the Hero Unit in the css file with no avail. It is almost seeming like you can't edit it :(
Here is the full CSS for the Hero Unit Class:
.hero-unit {
height: 100%;
min-height: 649px;
padding: 60px;
margin-bottom: 30px;
font-size: 18px;
font-weight: 200;
line-height: 30px;
text-align: center;
vertical-align: middle;
color: inherit;
background-color: #eeeeee;
background-image: url('../img/blured.jpg');
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
}
.hero-unit h1 {
margin-bottom: 0;
font-size: 60px;
line-height: 1;
letter-spacing: -1px;
color: inherit;
}
.hero-unit li {
line-height: 30px;
}
And the html for the Hero Unit:
<!--HERO UNIT -->
<div class="hero-unit">
<div class="container-fluid">
<div class="row-fluid">
<div class="span4">
<h4>The Green Panda</h4>
</div>
<div class="span4">
<p>Professional Web Design</p>
</div>
<div class="span4">
Learn More
</div>
</div>
</div>
</div>
Am I missing something? If so what? I can't figure this out and do not understand why the height: 100% and vertical-align:bottom is not working. Any suggestions are open. Here is a fiddle
To make the Hero Unit full height in Bootstrap add this to the hero-unit in bootstrap.css
height: 100%;
max-height:900px;
min-height:630px;
To make the items within the hero-unit of Bootstrap add this directly above the first span-4
<div class="span-bottom">
//hero unit items
</div>
And then add the following to your bootstrap.css file
.span-bottom {
padding-top: 560px;
}
You can name this div class anything you like just be sure to change the name in both the html and css file!