HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URL's added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Projeto Individual</title>
<link rel="icon" type="image/png" href="./images/logo-uc.png" />
<link rel="stylesheet" href="index.css" />
<script src="https://kit.fontawesome.com/6c109bd4c4.js" crossorigin="anonymous"></script>
<script src="index.js"></script>
</head>
<body>
<scroll-container>
<!-- Menu superior -->
<nav class="nav-bar">
<ul class="nav-bar-list" id="nav-bar-list-id">
<!-- Primeiro item (Home) -->
<li class="nav-bar-item">
<a href="#scroll-page0"> <i class="fa-solid fa-house"></i> HOME</a>
</li>
<!-- Segundo item (Projetos) -->
<li class="nav-bar-item">
<a href="#scroll-page1">
<i class="fa-solid fa-bars-progress"></i> PROJETOS</a>
</li>
<!-- Terceiro item (Quem somos) -->
<li class="nav-bar-item">
<a href="#scroll-page2">
<i class="fa-solid fa-people-group"> </i> QUEM SOMOS
</a>
</li>
<!-- Quarto item (registo) -->
<li class="nav-bar-item">
<a href="#scroll-page3">
<i class="fa-solid fa-user-plus"> </i> REGISTO
</a>
<ul>
<li class="nav-bar-subitem">
<input type="text" name="username" id="username" placeholder="Username" />
</li>
<li class="nav-bar-subitem">
<input type="password" name="password" id="password" placeholder="Password" />
</li>
<li class="nav-bar-subitem">
<input type="submit" value="login" />
</li>
</ul>
</li>
<!-- Quinto item (login) -->
<li class="nav-bar-item">
<a href="#scroll-page4">
<i class="fa-solid fa-right-to-bracket"> </i> LOGIN
</a>
</li>
<!-- Sexto item (barra de pesquisa) -->
<li class="nav-bar-item">
<div id="search">
<input id="input-search" type="text" placeholder="Search for news" />
<input type="submit" id="search-button" value="submit" />
</div>
</li>
<!-- Sétimo item (idiomas) -->
<li class="nav-bar-item" id="nav-bar-item-languages">
<select name="languages" id="languages">
<option id="portuguese" class="option-language" value="portuguese">
PT
</option>
<option id="english" class="option-language" value="english">
EN
</option>
</select>
</li>
</ul>
</nav>
<!-- Primeira imagem grande -->
<scroll-page id="scroll-page0">
<div class="imagem1">
<div class="description">
<span class="border"> Casas do futuro </span>
</div>
</div>
</scroll-page>
<!-- Primeira seção de texto -->
<scroll-page id="scroll-page1">
<div class="outher-section">
<h2 class="section-title">Últimas notícias</h2>
<section class="section section-light">
<div class="news-item">
<img src="./images/container3.jpg" alt="Terceira notícia" class="news-image" width="200px" height="133px" />
<br />
<a href="#" title="Mansão ecológica">É possível ter uma casa luxuosa e ecolocicamente correta</a>
</div>
<div class="news-item">
<img src="./images/container2.jpg" alt="Segunda notícia" class="news-image" width="200px" height="133px" />
<br />
<a href="#" title="Mansão ecológica">É possível ter uma casa luxuosa e ecolocicamente correta</a>
</div>
<div class="news-item">
<img src="./images/container1.jpg" alt="Primeira notícia" class="news-image" width="200px" height="133px" />
<br />
<a href="#" title="Casa container luxuosa">Como são feitas as casas containers</a>
</div>
</section>
</div>
</scroll-page>
<!-- Segunda imagem grande -->
<div class="imagem2">
<div class="description">
<span class="border transparent"><strong>Sustentabilidade</strong></span>
</div>
</div>
<!-- Segunda seção de texto -->
<scroll-page id="scroll-page2">
<div class="outher-section">
<h2 class="section-title">Quem somos</h2>
<section class="section section-light">
<div class="news-item">
<img src="./images/youko.png" alt="Terceira notícia" class="news-image" width="274px" height="244px" />
<br />
<a href="#" title="Alguém 0">Sujeito 0</a>
</div>
<div class="news-item">
<img src="./images/inuyasha.png" alt="Segunda notícia" class="news-image" width="250px" height="273px" />
<br />
<a href="#" title="Alguém 1">Sujeito 1</a>
</div>
<div class="news-item">
<img src="./images/hal.png" alt="Primeira notícia" class="news-image" width="278px" height="260px" />
<br />
<a href="#" title="Alguém 2">Sujeito 2</a>
</div>
</section>
</div>
</scroll-page>
<!-- Terceira imagem grande -->
<div class="imagem3">
<div class="description">
<div class="border transparent"><strong>Inovação</strong></div>
</div>
</div>
<!-- Terceira seção de texto -->
<scroll-page id="scroll-page3">
<section class="section section-dark">
<h2>Registo</h2>
<form action="#" class="register">
<input class="form-item" type="text" placeholder="Primeiro nome" />
<br />
<input class="form-item" type="text" placeholder="Último nome" />
<br />
<input class="form-item" type="text" placeholder="Username" />
<br />
<input class="form-item" type="password" name="password" id="password" placeholder="Palavra passe" />
<br />
<input class="form-item" type="email" name="email" id="email" placeholder="e-mail" />
<br />
<input class="form-item" type="url" name="photo" id="photo" placeholder="Foto URI" />
<br />
<input type="submit" value="Submeter" />
</form>
</section>
</scroll-page>
<!-- Última imagem grande -->
<div class="imagem1">
<div class="description">
<div class="border">Ecológica</div>
</div>
</div>
<!-- Última seção de texto -->
<scroll-page id="scroll-page4">
<section class="section section-dark">
<h2>Login</h2>
<form action="#" class="register">
<input class="form-item" type="text" placeholder="Username" />
<br />
<input class="form-item" type="password" name="password" id="password" placeholder="Palavra passe" /> <br>
<input type="submit" value="Submeter" />
</form>
</section>
</scroll-page>
</scroll-container>
</body>
</html>
body,
html {
height: 100%;
margin: 0;
font-size: 16px;
font-family: "Lato", sans-serif;
font-weight: 400;
line-height: 1.8em;
color: #666666;
display: block;
scroll-behavior: smooth; /* efeito de rolagem ao clicar em um link */
background-color: whitesmoke;
}
/* CONFIGURAÇÕES DO MENU */
.nav-bar {
position: fixed;
width: 100%;
z-index: 1;
top: 0;
}
/* Nova classe a ser atribuída ao elemento com os estilos desejados */
.changeStyle {
background-color: whitesmoke;
box-shadow: 0 0 1em gray;
}
.nav-bar-list {
list-style-type: none;
margin: 0;
padding: 0;
top: 0;
width: 100%;
position: fixed;
transition: background-color 0.3s ease-in-out; /* ainda não funciona */
}
.nav-bar-item {
float: left;
}
.nav-bar-item a {
display: inline-block;
color: gray;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
.nav-bar-item a:hover {
background-color: #6666661f;
}
/* menu dropdown do login */
li {
list-style: none;
display: block;
}
.dropdown:hover .dropdown-content {
display: block;
}
/* Mecanismo de busca */
#search {
margin-top: 12px;
padding-left: 200px;
}
#input-search:focus {
box-shadow: 0 0 0 0;
border: none;
outline: 0;
width: 300px;
}
/* Seletor de idiomas */
#nav-bar-item-languages {
margin-top: 10px;
right: 1px;
}
#languages {
border: transparent;
background-color: transparent;
}
#input-search {
/* border: 4px ridge rgba(211, 220, 50, .6); */
border: transparent;
background-color: transparent;
}
#search-button {
background-color: transparent;
background-image: url("./images/magnifying-glass-solid.svg");
background-position: center;
background-repeat: no-repeat;
background-size: 12px;
border: 0 none;
width: 16px;
height: 16px;
position: relative;
left: -24px; /* Botão dentro do input */
top: -4px;
font-size: 0px;
cursor: pointer;
}
.fa-solid:hover {
/* Começa a animação shake e fá-la durar por 0.5 segundos */
animation: shake 0.5s;
/* Quando a animação terminar, fá-la iniciar novamente */
animation-iteration-count: infinite;
}
.nav-bar-subitem {
display: none; /* Esconde os campos da navbar */
}
.nav-bar-subitem:hover {
display: block; /*Não está funcionando !!!!!!!!!!!!!*/
}
@keyframes shake {
0% {
transform: translate(1px, 1px) rotate(0deg);
}
10% {
transform: translate(-1px, -2px) rotate(-1deg);
}
20% {
transform: translate(-3px, 0px) rotate(1deg);
}
30% {
transform: translate(3px, 2px) rotate(0deg);
}
40% {
transform: translate(1px, -1px) rotate(1deg);
}
50% {
transform: translate(-1px, 2px) rotate(-1deg);
}
60% {
transform: translate(-3px, 1px) rotate(0deg);
}
70% {
transform: translate(3px, 1px) rotate(-1deg);
}
80% {
transform: translate(-1px, -1px) rotate(1deg);
}
90% {
transform: translate(1px, 2px) rotate(0deg);
}
100% {
transform: translate(1px, -2px) rotate(-1deg);
}
}
/* FIM DAS CONFIGURAÇÕES DO MENU */
.imagem1,
.imagem2,
.imagem3 {
position: relative;
opacity: 0.7;
background-position: center;
background-size: cover;
background-repeat: no-repeat;
/*
fixed = parallax
scroll = normal
*/
background-attachment: fixed;
}
.imagem1 {
background-image: url("https://i.imgur.com/ui8XONA.jpg");
min-height: 100%;
}
.imagem2 {
background-image: url("https://i.imgur.com/qqvapmB.jpg");
min-height: 400px;
}
.imagem3 {
background-image: url("https://i.imgur.com/TWzCWDV.jpg");
min-height: 100%;
}
.section {
text-align: center;
padding: 50px 80px;
/* background-color: whitesmoke; */
}
.section-light {
/* background-color: whitesmoke; */
color: gray;
display: flex;
justify-content: space-around;
}
.section-dark {
background-color: #282e34;
color: azure;
}
/* Títulos de seções */
.section-title {
display: flex;
justify-content: center;
/* background-color: whitesmoke; */
}
.description {
position: absolute;
top: 50%;
width: 100%;
text-align: center;
color: black;
font-size: 27px;
letter-spacing: 8px;
text-transform: uppercase;
}
.description .border {
background-color: #111111;
color: white;
padding: 20px;
}
.description .border.transparent {
background-color: transparent;
}
.form-item {
width: 500px;
height: 20px;
margin: 5px;
}
@media (max-width: 568px) {
.imagem1,
.imagem2,
.imagem3 {
background-attachment: scroll;
}
}
const desiredElement = document.getElementById("nav-bar-list-id"); // elemento alvo
const pixelsAmount = "50"; // Quantidade de pixels a contar do TOP até definir a cor
window.addEventListener("scroll", function () {
if (window.scrollY > pixelsAmount) {
desiredElement.classList.add("changeStyle"); // adiciona classe "changeColor"
} else {
desiredElement.classList.remove("changeStyle"); // remove classe "changeColor"
}
});
Also see: Tab Triggers