8:00p EST / 7:00p CST / 5:00p PST
h2 {
display: none;
}
/* Removes the element and its space from the page */
h3 {
visibility: hidden;
}
/* Hides the element, and retains its original space */
To center horizontally and vertically:
Make sure the element to be centered is in a parent container
Center Me
Apply the CSS:
To center horizontally and vertically
.container {
/* Give the parent container width, height
and the position properties */
width: 200px;
height: 200px;
position: relative;
}
.content {
/* Apply these rules to the content to be centered */
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Apply the CSS:
To center horizontally alone
.container {
/* Parent container can have a specific width
or be full width. */
width: 800px;
height: 200px;
}
.content {
/* The content to be centered must have a
width that's less than its parent container. */
width: 300px;
/* This CSS rule creates the centering effect */
margin: 0 auto;
}
/* Apply to the html element selector
at the top of your CSS stylesheet. */
html {
scroll-behavior: smooth;
scroll-padding: 50px; /* Optional */
/* Adds spacing above the sections we're scrolling to */
}
Source: Why Learning to Code is So Damn Hard (Thinkful.com)
See Resources List