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.
<!--za kreiranje elemenata u našem primjeru smo uglavnom koristili div elemente, div element je block element što znaći da će svaki novi div preći u novi red, ako želimo da se nižu jedan iza drugoga moramo napisati display:inline-block;. nakon kreiranja elementa, dodjeljujemo mu klasu kako bih te elemente mogli dohvatiti u css-u i kasnije u java scripti. Element možemo dohvatiti i pomoću ID-a ali zapamtite da je ID jedinstven i nesmijemo imati 2 elementa s istim ID-em.-->
<div class="content-wrapper-1">
<div class="result-wrapper-1">
<!--Klase treba dodjeljivati promišljeno, najbolja praksa je
ta da se elementima daju klase po onome što rade u css-u npr. napravimo klasu koja će se zvati button i u css-u napišemo sva svojstva koja taj button ima te ga kasnije možemo iskoristiti na više mjesta tako da samo na ciljani element nadodamo klasu-->
<div class="result-1-box-1"></div>
<div class="result-1-box-2"></div>
<div class="result-1-box-3"></div>
<div class="result-1-box-4"></div>
</div>
<div class="result-1-text">
<h3>box-shadow</h3>
<p>Css svojstvo koje dodaje sjenu iza elementa a njenu poziciju možemo kontrolirati vrijednostima koje unosimo.</p>
<ul>
<li>Prva vrijednost nam govori koliko ce sjena biti udaljena u desno od elementa, vrijednost nam može biti i negativna što znaci da ce sjena ici u lijevo od elementa.</li>
<li>Druga nam govori udaljenost prema dolje, ako je vrijednost negativna sjena ce ici gore.</li>
<li>Treca nam govori koliko ce rub oko elementa biti zamagljen (vrijednosti se izražavaju u pixelima)</li>
</ul>
</div>
</div>
<!-- primjer 2-->
<div class="content-wrapper-2">
<div class="result-wrapper-2">
<div class="result-2-box-1"></div>
<div class="result-2-box-2"></div>
<div class="result-2-box-3"></div>
<div class="result-2-box-4"></div>
<div class="result-2-box-5"></div>
<div class="result-2-box-6"></div>
<div class="result-2-box-7"></div>
<div class="result-2-box-8"></div>
</div>
<div class="result-2-text">
<h3>border</h3>
<p>Css svojstvo koje dodaje liniju oko bloka s kojim manipuliramo. Liniju možemo manipulirati pomoću tri vrijednosti.</p>
<ul>
<li>Prva nam govori debljinu linije</li>
<li>Druga nam govori stil linije, primjere možemo vidjeti desno gdje sam primjenio neke od stilova.</li>
<li>Treča nam govori koje boje će biti linija (rub). Boju možemo unjeti na više načina npr. Hex kod, rgb, rgba...</li>
</ul>
</div>
</div>
<!--Primjer 3-->
<div class="content-wrapper-3">
<div class="result-wrapper-3">
<div class="result-3-box-1">inline</div>
<div class="result-3-box-2">inline</div>
<!--korisitili smo 2 načina vertikalnog pozicioniranja prvi način je bio u prva dva result-box-a tako što smo element prikazali kao teble cell što znaći kao da smo napisali <td> element pa smo modli poravnati vertikalno pomoću naredbe vertical-align, a druga sva result-wrappera smo pozicionirali pomoću svojstva absolute pa smo zbog njega napravili jedan span element koji ćemo moći upravljati pomoću svojstva top, left, right i bottom-->
<div class="result-3-box-3"><span>block</span></div>
<div class="result-3-box-4"><span>block</span></div>
</div>
<div class="result-3-text">
<h3>Display</h3>
<p>Css svojstvo kojim definiramo tip prikazivanja našeg elementa, tipova ima puno pa ću ja spomenuti samo one koji se najčešće koriste: </p>
<ul>
<li>Inline - elementi se slažu jedan pored drugoga ako u redu ima mjesta za njih</li>
<li>Block - svaki element koji ima svojstvo block kreće od novog reda i možemo mu postaviti visinu i širinu</li>
<li>Table - ovim svojstvom kažemo da nam se element ponaša kao tablica</li>
<li>Flex - kreiramo flexbox što smo već koristili u prvom i drugom primjeru. Tim svojstvom napravimo dužinu elementa relativnu drugim elementima</li>
</ul>
</div>
</div>
<!--Primjer 4-->
<div class="content-wrapper-4">
<div class="result-wrapper-4">
<div class="result-4-box-1"></div>
</div>
<div class="result-4-text">
<h3>Position</h3>
<p>Css svojstvo određuje tip metode pozicioniranja elemenata. Postoje 4 metode pozicioniranja. Nakon što smo odredili tip/metodu element možemo pozicionirati svojstvima top,bottom,left i right, ali ta svojstva različito djeluju s obzirom na tip poziciniranja.</p>
<ul>
<li>static - početna vrijednost svakog elementa</li>
<li>relative - normalna pozicija elementa</li>
<li>fixed - relativno pozicioniran na početni prikaz (viewport) što znaći da uvijek ostaje na istom mjestu kada se stranica pomiće (scroll)</li>
<li>absolute - relativno pozicioniran na najbližeg pozicioniranog prethodnika</li>
</ul>
</div>
</div>
// Za editiranje boja, pozicija i izgleda našeg
//html file-a koristimo css. U ovom pjektu
//koristim SCSS što je preprocessor za css
//te mi on omogučuje par korisnih stvaru
//koje mi olakšavaju razvoj web stranica
// Kako mi na faxu radimo CSS dovoljno je
//na vrhu CSS boxa, s desne strane stisnuti
//view Compiled kako bi vidjeti obični CSS
//koji mi koristimo na faxu.
body{
// Po default-u body ima marginu od 5px
//pa je sljedečom naredbom uklonimo kako nam
//nebi stvarala nedoumice i probleme
margin:0;
background-color: coral;
font-family: "Lucida Console", Monaco, monospace;
}
// Okvir oko cijelog primjera
.content-wrapper-1{
width: 100%;
height: 400px;
margin: 10px;
// Ovdje možemo vidjeti prvu prednost SCSS-a
//nakon što smo kreirali content-wrapper
//koristim udnježđivanje kako bi mi elementi
//bili bolje raspoređeni a sintaksa lakša za čitati
// primjer 1
// sjena ispod nekog elementa
//-------------------------------------
//border: width style color
.result-wrapper-1{
float: left;
height: 150px;
width: 300px;
//Koristim flexbox za lakše
// kontroliranje bloka te za upravljanje
// dijece našeg glavnog bloka, ako nekoga
// zanima više o flex naredbi može pogledati
// na internetu, tamo je sve temeljito objasnjeno
//Kako bi flexbox radio na svim
// browserima moramo koristiti
// prefikse: -o-,-moz-,-webkit-,-ms-
display:flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
.result-1-box-1{
width: 50px;
height: 50px;
background-color: #0080FF;
//box-shadow prima tri vrijednosti
// (left)(right)(blur)
box-shadow: 5px 5px 5px;
}
.result-1-box-2{
width: 50px;
height: 50px;
background-color: #A0A0A0;
box-shadow: 10px 0 10px;
}
.result-1-box-3{
width: 50px;
height: 50px;
background-color: #A6FF69;
box-shadow: 0 15px 30px;
}
.result-1-box-4{
width: 50px;
height: 50px;
background-color: #FFFF66;
box-shadow: 25px 25px 65px;
//overflow koristimo kako bih
// kontrolirali višak izvan
// granica glavnog box-a
overflow: hidden;
//koristimo pseudo klasu "after"
// kako bih stavili još jednu boju
// unutar "result-box"
&::after{
content: "";
//element prikažemo kao block
// kako bi mu mogli odrediti
// širinu i visinu
display: block;
//odredimo dovoljne vrijednosti
// kako bi sadržaj prekrio
// glavni box
width: 90px;
height: 37px;
transform: rotate(45deg);
background-color: #1485CC;
}
}
}
//pozicioniranje teksta
.result-1-text{
padding: 25px;
float: right;
width:400px;
//rgba svojstvo za unošenje boje nam
// omogučava unošenje četvrte vrijednosti
// kojom određujemo prozirnost (alpha/opacity)
background-color: rgba(255,255,255,0.3);
}
}
.content-wrapper-2{
width: 100%;
height: 400px;
margin: 10px;
// primjer 2
// okvir oko elementa (stilovi okvira)
//-------------------------------------
.result-wrapper-2{
//margine možemo dodavati posebno
// margin-top, margin-left..., ali
// možemo ih dodati sve od jednom
// margin: (top)(right)(bottom)(left)
height: 250px;
width: 450px;
float: left;
display:flex;
flex-direction: row;
align-items: center;
justify-content: space-around;
//flex-wrap nam govori kako će elementi
// biti raspoređeni unutar result-wrappera
flex-wrap: wrap;
.result-2-box-1{
//točno odeređivanje širine i visine elementa u praksi
// nije najbolje rješenje jer danas postoji jako puno
// različitih dimenzija ekrana na kojima se prikazuju
// web stranice pa je dobra praksa koristiti %, em i
// rem kako bi stranica bila prilagodljiva kako se
// dimenzije ekrana smanjuju.
width: 75px;
height: 75px;
background-color: #0C40E8;
//border: (debljina) (stil) (boja);
border: 10px solid #0DFFF8;
}
.result-2-box-2{
width: 75px;
height: 75px;
background-color: #0C40E8;
border: 10px dashed #0DFFF8;
}
.result-2-box-3{
width: 75px;
height: 75px;
background-color: #0C40E8;
border: 10px dotted #0DFFF8;
}
.result-2-box-4{
width: 75px;
height: 75px;
background-color: #0C40E8;
border: 10px groove #0DFFF8;
}
.result-2-box-5{
width: 75px;
height: 75px;
background-color: #0C40E8;
border: 10px ridge #0DFFF8;
}
.result-2-box-6{
width: 75px;
height: 75px;
background-color: #0C40E8;
border: 10px inset #0DFFF8;
}
.result-2-box-7{
width: 75px;
height: 75px;
background-color: #0C40E8;
border: 10px outset #0DFFF8;
}
.result-2-box-8{
width: 75px;
height: 75px;
background-color: #0C40E8;
border: 10px double #0DFFF8;
}
}
//pozicioniranje teksta
.result-2-text{
padding:25px;
width:400px;
float: right;
background-color: rgba(255,255,255,0.3);
}
}
//Primjer 3 - Display svojstvo
.content-wrapper-3{
width: 100%;
height: 400px;
margin: 10px;
.result-wrapper-3{
height: 250px;
width: 450px;
float: left;
//border-spaceing koristimo za razmak izmedju
// table cell-ova jer na njih ne utjece margin
// zbog toga jer je inline element pa na njega
// ne možemo postaviti širinu i visinu
border-spacing: 10px;
.result-3-box-1{
width: 75px;
height: 75px;
background-color: #008B8B;
text-align: center;
display:table-cell;
vertical-align: middle;
}
.result-3-box-2{
width: 75px;
height: 75px;
background-color: #008B8B;
text-align: center;
display:table-cell;
vertical-align: middle;
}
.result-3-box-3{
//ovaj element moramo pozicionirati relativno
// kako bi dijete element došlo u početak
// elementa svoga roditelja kada ga pozicioniramo
// apsolutno position: absolute;
position: relative;
width: 75px;
height: 75px;
text-align: center;
background-color: #008B8B;
display: block;
margin: 10px;
span{
//početak mu gleda iz top:0 & left:0; jer
// smo element roditelj pozicionirali
// relativno
position: absolute;
top:40%;
left: 16%;
}
}
.result-3-box-4{
position: relative;
width: 75px;
height: 75px;
text-align: center;
background-color: #008B8B;
display: block;
margin: 10px;
span{
//Pozicionirali smo apsolutno kako bi mogli
// iskoristiti svojstva top i left
position: absolute;
//Ovdje nismo stavili 50% jer se točka od koje se gleda
// poravnanje ne nalazi u sredini elementa nego u
// gornjem lijevom kutu
top:40%;
left: 16%;
}
}
}
.result-3-text{
padding:25px;
width:400px;
float: right;
background-color: rgba(255,255,255,0.3);
}
}
//primjer 4. Pozicioniranje
.content-wrapper-4{
width: 100%;
height: 400px;
margin: 10px;
.result-wrapper-4{
height: 250px;
width: 450px;
float: left;
}
.result-4-text{
padding:25px;
width:400px;
float: right;
background-color: rgba(255,255,255,0.3);
}
}
Also see: Tab Triggers