I'm making a simple website (HTML & CSS only) consisting of an svg file (blob) with text inside of it, both items centered on the left side of the page. To the right of the page the word "Company" should be displayed centered this is what is suppossed to look like. Another issue I have is the text inside the blob not stretching all the way when the webpage is in full view (admittedly, it does fix itself when I decrease font-size but I feel like it could be fully stretched at the current 4.2em). This is the result of my code.
html body {
padding: 0;
margin: 0;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
width: 100%;
height: 100%;
overflow-x: hidden;
}
body {
background-color: #121212;
}
svg {
max-width: 100%;
object-fit: scale-down;
}
p {
color: white;
font-size: 4rem;
}
.container {
position: absolute;
text-align: center;
color: white;
padding-left: 4%;
padding-right: 4%;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 4.2em;
}
.company {
position: right absolute;
text-align: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="styles.css" rel="stylesheet"/>
<title>Coming Soon</title>
</head>
<body>
<main>
<div class="container">
<svg xmlns="http://www.w3.org/2000/svg"
width="600"
height="600"
viewBox="0 0 638.673 621.008">
<path id="Path_1" data-name="Path 1" d="M500,170.963c67.589,4.626,132.75,31.976,182.124,78.365,45.711,42.948,55.831,107.484,78.093,166.122,23.716,62.466,75.065,123.258,56.095,187.326-19.022,64.243-87.325,101.559-149.224,127.2-52.76,21.856-110.546-4.191-167.088,3.831-71.47,10.139-140.841,81.139-205.49,49.025-63.083-31.336-59.973-122.575-79.066-190.375-18.212-64.672-44.091-128.9-29.3-194.435,15.654-69.353,55.066-133.255,112.67-174.929,57.536-41.625,130.336-56.98,201.184-52.131" transform="translate(-181.759 -170.1)" fill="#bf4040"/>
</svg>
<div class="centered">Coming Soon</div>
</div>
<div class="company">
<p class="outside">Company</p>
</div>
</main>
</body>
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="styles.css" rel="stylesheet"/>
<title>Coming Soon</title>
</head>
<body>
<main>
<div class="container">
<svg xmlns="http://www.w3.org/2000/svg"
width="600"
height="600"
viewBox="0 0 638.673 621.008">
<path id="Path_1" data-name="Path 1" d="M500,170.963c67.589,4.626,132.75,31.976,182.124,78.365,45.711,42.948,55.831,107.484,78.093,166.122,23.716,62.466,75.065,123.258,56.095,187.326-19.022,64.243-87.325,101.559-149.224,127.2-52.76,21.856-110.546-4.191-167.088,3.831-71.47,10.139-140.841,81.139-205.49,49.025-63.083-31.336-59.973-122.575-79.066-190.375-18.212-64.672-44.091-128.9-29.3-194.435,15.654-69.353,55.066-133.255,112.67-174.929,57.536-41.625,130.336-56.98,201.184-52.131" transform="translate(-181.759 -170.1)" fill="#bf4040"/>
</svg>
<div class="centered">Coming Soon</div>
</div>
<div class="company">
<p class="outside">Company</p>
</div>
</main>
</body>
CSS:
html body {
padding: 0;
margin: 0;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
width: 100%;
height: 100%;
overflow-x: hidden;
}
body {
background-color: #121212;
}
svg {
max-width: 100%;
object-fit: scale-down;
}
p {
color: white;
font-size: 4rem;
}
.container {
position: absolute;
text-align: center;
color: white;
padding-left: 4%;
padding-right: 4%;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 4.2em;
}
.company {
position: right absolute;
text-align: center;
}
My first thought was to split the page in half, this way I could center the blob and text on the left and "Company" on the right. While I did manage to center everything and match the design, when resizing the window, the background from the right side would cover the blob and text so I had to scrap that idea. Any help would be great!
There are several ways to do this, but one way is to do the following:
Use flexbox layout
Use a relative container div with absolute centered div
I added background colors to show you layout better. You still need some code cleanup here, but this should be close to what you are looking for.
html body {
padding: 0;
margin: 0;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
width: 100%;
height: 100%;
overflow-x: hidden;
}
body {
background-color: #121212;
}
svg {
max-width: 100%;
object-fit: scale-down;
}
p {
color: white;
font-size: 4rem;
}
.container {
position: relative;
text-align: center;
color: white;
padding-left: 4%;
padding-right: 4%;
flex: 50%;
background-color: green;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 4.2em;
}
.company {
text-align: center;
flex: 50%;
background-color: blue;
align-self: center;
}
main {
display: flex;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="styles.css" rel="stylesheet"/>
<title>Coming Soon</title>
</head>
<body>
<main>
<div class="container">
<svg xmlns="http://www.w3.org/2000/svg"
width="600"
height="600"
viewBox="0 0 638.673 621.008">
<path id="Path_1" data-name="Path 1" d="M500,170.963c67.589,4.626,132.75,31.976,182.124,78.365,45.711,42.948,55.831,107.484,78.093,166.122,23.716,62.466,75.065,123.258,56.095,187.326-19.022,64.243-87.325,101.559-149.224,127.2-52.76,21.856-110.546-4.191-167.088,3.831-71.47,10.139-140.841,81.139-205.49,49.025-63.083-31.336-59.973-122.575-79.066-190.375-18.212-64.672-44.091-128.9-29.3-194.435,15.654-69.353,55.066-133.255,112.67-174.929,57.536-41.625,130.336-56.98,201.184-52.131" transform="translate(-181.759 -170.1)" fill="#bf4040"/>
</svg>
<div class="centered">Coming Soon</div>
</div>
<div class="company">
<p class="outside">Company</p>
</div>
</main>
</body>
I used flex containers to achieve this look you want. I left borders around the div containers so you could see where the div's are that I positioned. You can play with the padding and what not to get the desired look you want. This code is responsive to screen size as well.
* {
padding: 0;
margin: 0;
}
html body {
height: 100vh;
font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
font-size: 16px;
overflow-x: hidden;
}
body {
background-color: #121212;
}
.wrapper {
display: flex;
justify-content: space-around;
align-items: center;
width: 100%;
margin: 50px 0 0 0;
border: 1px solid red;
}
/* LEFT SIDE */
.container {
display: flex;
justify-content: center;
align-items: center;
max-width: 300px;
padding: 10px;
border: 1px solid blue;
}
.svg-container {
border: 1px solid green;
object-fit: contain;
}
svg {
width: 100%;
height: 100%;
}
.coming-soon {
color: white;
font-size: 2rem;
}
.coming-soon-container {
position: absolute;
border: 1px solid white;
z-index: 1000;
}
/*RIGHT SIDE */
.company {
display: flex;
justify-content: center;
align-items: center;
border: 1px solid azure;
padding: 20px;
}
p {
color: white;
font-size: 2rem;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link href="style.css" rel="stylesheet" />
<title>Coming Soon</title>
</head>
<body>
<main>
<div class="wrapper">
<div class="container">
<div class="svg-container">
<svg
xmlns="http://www.w3.org/2000/svg"
width="600"
height="600"
viewBox="0 0 638.673 621.008"
>
<path
id="Path_1"
data-name="Path 1"
d="M500,170.963c67.589,4.626,132.75,31.976,182.124,78.365,45.711,42.948,55.831,107.484,78.093,166.122,23.716,62.466,75.065,123.258,56.095,187.326-19.022,64.243-87.325,101.559-149.224,127.2-52.76,21.856-110.546-4.191-167.088,3.831-71.47,10.139-140.841,81.139-205.49,49.025-63.083-31.336-59.973-122.575-79.066-190.375-18.212-64.672-44.091-128.9-29.3-194.435,15.654-69.353,55.066-133.255,112.67-174.929,57.536-41.625,130.336-56.98,201.184-52.131"
transform="translate(-181.759 -170.1)"
fill="#bf4040"
/>
</svg>
</div>
<div class="coming-soon-container">
<div class="coming-soon">Coming Soon</div>
</div>
</div>
<div class="company">
<p>Company</p>
</div>
</div>
</main>
</body>
</html>
I'm trying to make an image with an caption on the left-middle. The caption should be always at the left-middle or anywhere on the left side of the image and it's size should be vary with browser size simultaneously.
The problem is that when I resize the window than size of the caption won't change and It's position is also not fixed w.r.t the image.
.page-overview{
width: 100%;
border: 1px solid black;
}
.overview-content img{
width: 100%;
}
.caption{
position: absolute;
top: 20%;
left: 18px;
font-size: 80%;
font-family: 'Source Sans Pro', sans-serif;
z-index: 1;
}
.caption span{
display: block;
margin: 8px 0;
padding: 10px 17px;
border-radius: 3px;
background-color: #00000033;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test YOU</title>
</head>
<body>
<!--Here can have other content too-->
<div class="page-overview">
<div class="overview-content"><img src="https://images5.alphacoders.com/481/481903.png" alt="Delilious & Yum" height="auto">
<div class="caption">
<span>Test your best here</span>
<span>It's Yum 😋</span>
</div>
</div>
</div>
Remove position: absolute; and use relative instead. absolute will not account for browser shrinkage, it will just still stay in the specified area.
.page-overview {
width: 100%;
border: 1px solid black;
}
.overview-content img {
width: 100%;
}
.caption {
position: relative;
width: fit-content;
margin: auto 0;
top: 20%;
left: 18px;
font-size: 80%;
font-family: 'Source Sans Pro', sans-serif;
z-index: 1;
}
.caption span {
display: block;
margin: 8px 0;
padding: 10px 17px;
border-radius: 3px;
background-color: #00000033;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test YOU</title>
</head>
<body>
<!--Here can have other content too-->
<div class="page-overview">
<div class="overview-content">
<img src="https://images5.alphacoders.com/481/481903.png" alt="Delilious & Yum" height="auto">
<div class="caption">
<span>Test your best here</span>
<span>It's Yum 😋</span>
</div>
</div>
</div>
The main thing is to wrap a position:absolute divs with a position:relative div, so the absolute div will be relative that that parent.
Besides that, I used flexbox to center the content.
That is assuming you want the caption ON the image...
.page-overview{
width: 100%;
border: 1px solid black;
}
.overview-content img{
width: 100%;
}
.caption{
position: absolute;
top: 20%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
width: 100%;
font-size: 80%;
font-family: 'Source Sans Pro', sans-serif;
z-index: 1;
}
.caption span{
display: block;
margin: 8px 0;
padding: 10px 17px;
border-radius: 3px;
background-color: #00000033;
}
.image-wrapper {
position: relative;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test YOU</title>
</head>
<body>
<!--Here can have other content too-->
<div class="page-overview">
<div class="overview-content">
<div class="image-wrapper">
<a href="#">
<img src="https://images5.alphacoders.com/481/481903.png" alt="Delilious & Yum" height="auto"/>
</a>
<div class="caption">
<span>Test your best here</span>
<span>It's Yum 😋</span>
</div>
</div>
</div>
</div>
#bg {
position: fixed;
top: 0;
left: 0;
/* Preserve aspet ratio */
min-width: 100%;
min-height: 100%;
}
.navbar {
background-color: #000000;
border-color: 1px solid #000000;
}
.card-box {
border-radius: 2.5rem;
padding-bottom: 10px;
margin-top:25px;
background-color: #000000b0;
box-shadow: 1px 1px 5px 1px grey;
}
.portfolio-item {
/* height: 250px; */
text-align: center;
}
.row {
margin: 0px;
}
h3 {
margin: 10px;
}
.app_rstudio, .app_rstudio-super {
margin-left: 15%;
}
.fa, .far, .fas, .fab {
font-size: 96px;
color: #55b0ff;
margin: 15px;
}
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head lang="en">
<title th:text="${title}"></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<link rel="stylesheet" media="screen" th:href="#{${bootstrapCss}}" />
<link rel="stylesheet" media="screen" th:href="#{/css/default.css}"/>
<script th:src="#{${jqueryJs}}"></script>
<script th:src="#{${bootstrapJs}}"></script>
</head>
<body>
<img src="https://i.ibb.co/2Ww4xTB/background.png" id="bg" alt="">
<div th:replace="../fragments/navbar :: navbar"></div>
<div class="container" id="applist">
<div class="row" >
<div th:each="app: ${apps}">
<div th:class="${'col-md-4 portfolio-item app_' + app.id}">
<div class="card-box">
<a th:href="#{/app/}+${app.id}">
<i th:class="${app.logoURL}"></i>
</a>
<h3>
<a th:href="#{/app/}+${app.id}" th:text="${app.displayName == null} ? ${app.id} : ${app.displayName}" style="color: #55b0ff;"></a>
</h3>
<a th:if="${app.description != null}" th:href="#{/app_direct/}+${app.id + '/'}" style="color: #55b0ff; font-style: italic;" target="_blank">
<p th:text="${app.description}"></p>
</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
I added the following CSS code to my HTML document:
body {
background-color: #333;
background-image: url(/assets/img/background.png);
background-size: cover;
background-repeat: no-repeat;
background-attachment: scroll;
background-position: top center;
color: rgb(202, 202, 202);
}
But the image does not fill the browser window as expected. Where did I go wrong?
Here is the entire HTML code (probably more than you need but I'm not sure which bits are relevant):
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head lang="en">
<title th:text="${title}"></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<link rel="stylesheet" media="screen" th:href="#{${bootstrapCss}}" />
<link rel="stylesheet" media="screen" th:href="#{/css/default.css}"/>
<script th:src="#{${jqueryJs}}"></script>
<script th:src="#{${bootstrapJs}}"></script>
<style type="text/css">
body {
background-color: #333;
background-image: url(/assets/img/background.png);
background-size: cover;
background-repeat: no-repeat;
background-attachment: scroll;
background-position: top center;
color: rgb(202, 202, 202);
}
.navbar {
background-color: #000000;
border-color: 1px solid #000000;
}
.card-box {
border-radius: 2.5rem;
padding-bottom: 10px;
margin-top:25px;
background-color: #000000b0;
box-shadow: 1px 1px 5px 1px grey;
}
.portfolio-item {
/* height: 250px; */
text-align: center;
}
.row {
margin: 0px;
}
h3 {
margin: 10px;
}
.app_rstudio, .app_rstudio-super {
margin-left: 15%;
}
.fa, .far, .fas, .fab {
font-size: 96px;
color: #55b0ff;
margin: 15px;
}
</style>
</head>
<body>
<div th:replace="../fragments/navbar :: navbar"></div>
<div class="container" id="applist">
<div class="row" >
<div th:each="app: ${apps}">
<div th:class="${'col-md-4 portfolio-item app_' + app.id}">
<div class="card-box">
<a th:href="#{/app/}+${app.id}">
<i th:class="${app.logoURL}"></i>
</a>
<h3>
<a th:href="#{/app/}+${app.id}" th:text="${app.displayName == null} ? ${app.id} : ${app.displayName}" style="color: #55b0ff;"></a>
</h3>
<a th:if="${app.description != null}" th:href="#{/app_direct/}+${app.id + '/'}" style="color: #55b0ff; font-style: italic;" target="_blank">
<p th:text="${app.description}"></p>
</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
I also tried (and failed) to use an approach described here which suggests using the following CSS:
#bg {
position: fixed;
top: 0;
left: 0;
/* Preserve aspet ratio */
min-width: 100%;
min-height: 100%;
}
And HTML:
<img src="images/bg.jpg" id="bg" alt="">
In this case, the background will not fill the screen if the device you are using is portrait.
Try adding this to your style:
html {
min-height:100%;
}
The problem has to be with your local file path because when adding a url it works fine as seen below:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head lang="en">
<title th:text="${title}"></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.1/css/all.css" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<link rel="stylesheet" media="screen" th:href="#{${bootstrapCss}}" />
<link rel="stylesheet" media="screen" th:href="#{/css/default.css}"/>
<script th:src="#{${jqueryJs}}"></script>
<script th:src="#{${bootstrapJs}}"></script>
<style type="text/css">
body {
background-color: #333;
background-image: url("https://images.unsplash.com/photo-1558481795-7f0a7c906f5e?ixid=MXwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHw%3D&ixlib=rb-1.2.1&auto=format&fit=crop&w=1373&q=80");
background-size: cover;
background-repeat: no-repeat;
background-attachment: scroll;
background-position: top center;
color: rgb(202, 202, 202);
width: 100%;
height: 1600%;
z-index: -1;
}
.navbar {
background-color: #000000;
border-color: 1px solid #000000;
}
.card-box {
border-radius: 2.5rem;
padding-bottom: 10px;
margin-top:25px;
background-color: #000000b0;
box-shadow: 1px 1px 5px 1px grey;
}
.portfolio-item {
/* height: 250px; */
text-align: center;
}
.row {
margin: 0px;
}
h3 {
margin: 10px;
}
.app_rstudio, .app_rstudio-super {
margin-left: 15%;
}
.fa, .far, .fas, .fab {
font-size: 96px;
color: #55b0ff;
margin: 15px;
}
</style>
</head>
<body>
<div th:replace="../fragments/navbar :: navbar"></div>
<div class="container" id="applist">
<div class="row" >
<div th:each="app: ${apps}">
<div th:class="${'col-md-4 portfolio-item app_' + app.id}">
<div class="card-box">
<a th:href="#{/app/}+${app.id}">
<i th:class="${app.logoURL}"></i>
</a>
<h3>
<a th:href="#{/app/}+${app.id}" th:text="${app.displayName == null} ? ${app.id} : ${app.displayName}" style="color: #55b0ff;"></a>
</h3>
<a th:if="${app.description != null}" th:href="#{/app_direct/}+${app.id + '/'}" style="color: #55b0ff; font-style: italic;" target="_blank">
<p th:text="${app.description}"></p>
</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
I am working on a little project. Until now everything went well, but for one reason or another, when I am making my second page, it will only load a part of the CSS (everything until calendar). I tried to put it in another CSS file and link the two files to the HTML file, and that works, but I would like to have all my CSS in just one file.
Can you help me?
Here is my code:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>MyLoveLifeFamily</title>
<link rel="icon" href="./assets/pictures/family.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<div class="header">
<div class="nav">
<div class="navWrapper">
<img src="./assets/pictures/family.ico" alt="Family Icon">
<div class="right">
Thuispagina
Kalender
Foto album
Lijstjes
Gerechten
</div>
</div>
</div>
<div class="headerWrapper">
<h1>Volg ons leven op deze website!</h1>
</div>
</div>
<div class="timeline" id="timeline">
<div class="timelineWrapper">
<h3>Tijdlijn</h3>
<div class="timelinegrid">
<img src="./assets/pictures/family_pic.jpg">
<p>Zeeland - 2018</p>
<p>Welkom Tuur in de familie - 11/01/2018</p>
<img src="./assets/pictures/tuur.jpg">
<img src="./assets/pictures/verjaardag-marie-2017.jpg">
<p>Verjaardag Marie - 2017</p>
<p>Verjaardag Eline - 2016</p>
<img src="./assets/pictures/verjaardag-eline-2016.jpg">
</div>
</div>
</div>
</body>
</html>
calendar.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>MyLoveLifeFamily</title>
<link rel="icon" href="./assets/pictures/family.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<div class="nav">
<div class="navWrapper">
<img src="./assets/pictures/family.ico" alt="Family Icon">
<div class="right">
Thuispagina
Kalender
Foto album
Lijstjes
Gerechten
</div>
</div>
</div>
<div class="calendar">
<div class="calendarWrapper">
<h3>Kalender</h3>
<div class="cal">
<!-- CalendarLink -->
</div>
</div>
</div>
style.css
#import url('https://fonts.googleapis.com/css?family=Oswald:400,700');
* {
margin: 0;
padding: 0;
border: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
}
html {
font-family: 'Oswald', sans-serif;
}
a {
text-decoration: none;
color: inherit;
}
/* Header */
.header {
background-image: url(assets/pictures/hero_bg.jpg);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
height: 90vh;
max-width: 100%;
}
.nav {
width: 100%;
height: 100px;
}
.navWrapper {
width: 85%;
margin: auto;
}
.navWrapper img {
height: 35px;
padding-top: 32.5px;
}
.right {
padding-top: 32.5px;
float: right;
}
#homepage, #calendar, #photoalbum, #lists, #recipes {
color: #000;
font-weight: bold;
font-size: 16px;
margin-right: 35px;
letter-spacing: 0.6px;
}
.headerWrapper {
padding-top: 235px;
}
.headerWrapper h1 {
font-size: 8vw;
font-weight: bold;
color: #4A4A4A;
text-align: center;
letter-spacing: 3.33px;
}
/* Timeline */
.timeline {
width: 100%;
}
.timelineWrapper {
width: 85%;
padding-top: 25px;
margin: auto;
padding-bottom: 75px;
}
.timelineWrapper h3 {
font-size: 40px;
color: #4A4A4A;
letter-spacing: 2px;
font-weight: bold;
}
.timelinegrid {
margin-top: 40px;
display: grid;
grid-template-columns: 500px 500px;
grid-auto-rows: auto auto;
grid-gap: 2%;
align-items: end;
justify-content: center;
}
.timelinegrid img {
width: 100%;
}
.timelinegrid p {
font-size: 30px;
color: #4A4A4A;
}
/* Calendar */
.calendar {
width: 100%;
}
.calendarWrapper {
width: 85%;
padding-top: 25px;
margin: auto;
padding-bottom: 75px;
}
.calendarWrapper h3 {
font-size: 40px;
color: #4A4A4A;
letter-spacing: 2px;
font-weight: bold;
}
Your css has an error. In .timelinegrid(line 98), you have align-items set to end.
If you fix this, the css should fully load.
https://www.w3schools.com/cssref/css3_pr_align-items.asp
I am trying to prevent the header element from scrolling, so I gave it position: fixed but that changes it size as per the second image below.
I am after a css to maintain the look of the first image and prevent the header from scrolling. Thanks
html, body {
height: 100%;
padding: 0;
margin: 0;
}
button {
height: 1.5em;
width: 1.5em;
font-size: 1.5em;
top: 0;
}
label {
display: inline-block;
width: calc(100% - 5em);
text-align: center;
}
header {
border-bottom: 1px solid black;
background-color: yellow;
position: fixed;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="index.css">
<meta name="viewport" content="width=device-width" />
</head>
<body >
<header>
<button class="menuLeft" type="button" >☰</button>
<label>Title of Page</label>
<button class="menuRight" type="button">⋮</button>
</header>
</body>
</html>
Just give width:100% to header.
html, body {
height: 100%;
padding: 0;
margin: 0;
}
button {
height: 1.5em;
width: 1.5em;
font-size: 1.5em;
top: 0;
}
label {
display: inline-block;
width: calc(100% - 5em);
text-align: center;
}
header {
border-bottom: 1px solid black;
background-color: yellow;
position: fixed;
width: 100%;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="index.css">
<meta name="viewport" content="width=device-width" />
</head>
<body >
<header>
<button class="menuLeft" type="button" >☰</button>
<label>Title of Page</label>
<button class="menuRight" type="button">⋮</button>
</header>
</body>
</html>
Simply add width:100%; to the header, like the following solution:
html, body {
height: 100%;
padding: 0;
margin: 0;
}
button {
height: 1.5em;
width: 1.5em;
font-size: 1.5em;
top: 0;
}
label {
display: inline-block;
width: calc(100% - 5em);
text-align: center;
}
header {
border-bottom: 1px solid black;
background-color: yellow;
position: fixed;
width:100%;
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="index.css">
<meta name="viewport" content="width=device-width" />
</head>
<body >
<header>
<button class="menuLeft" type="button" >☰</button>
<label>Title of Page</label>
<button class="menuRight" type="button">⋮</button>
</header>
</body>
</html>
Add width:100%; in the .header .You can see working demo in JSFIDDLE
html,
body {
height: 100%;
padding: 0;
margin: 0;
}
button {
height: 1.5em;
width: 1.5em;
font-size: 1.5em;
top: 0;
}
label {
display: inline-block;
width: calc(100% - 5em);
text-align: center;
}
header {
border-bottom: 1px solid black;
background-color: yellow;
position: fixed;
width: 100%;
}
<header>
<button class="menuLeft" type="button">☰</button>
<label>Title of Page</label>
<button class="menuRight" type="button">⋮</button>
</header>