1.Díl: Úvodem
Úvodem
Co by jste měli umět, než se pustíte do CSS?
- Základy HTML (bez toho se CSS ani nepokoušejte naučit), zde vám pomůže seriál o základech HTML, který v této knihovně naleznete.
- Základy práce se soubory
Jaké vybavení potřebujete pro kurz?
- Jednoduchý textový editor, stačí poznámkový blok nebo PSPad.
- Správce souborů, postačí průzkumník Windows nebo Total Commander.
- Hodně trpělivosti :o)
K čemu to tedy je?
Odpověď je snadná. CSS slouží k vylepšenému formátování stránek a každý, kdo chce vytvářet kvalitní webové stránky by měl zvládnou alespoň jeho základy.
Teď ale od teorie k praxi. Zkusíme metodu hození do ledové vody a plavání. Zkuste použít na stránce HTML tento kratičký kód:
<span style="color: red">Tenhle text formátuje CSS!</span>
Co se nestalo? Text v tagu span je červený. Nadefinovali jsme to přes parametr style="" . Aha, teď si asi tak říkáte, k čemu to je, když bych to mohl udělat po „HTMlovsku" jen pomocí tagu font:
<font color="red">Tento text formátuje pouze HTML</font>
Efekt je stejný. Co kdybychom ale chtěli udělat text ještě kurzívou. V HTML by to vypadalo asi nějak takhle:
<font color="red"><i>Tento text formátuje pouze jenom HTML</i></font>
K formátování jsme použili dva tagy. Sami uznáte, že v tom někdy bývá docela nepořádek. Pomocí CSS to samé formátování můžete provést mnohem elegantněji:
<span style="color: red; font-style: italic">Tento text formátuje opět CSS</span>
V CSS se dají nastavovat ale i vlastnosti elementů, které pomocí HTML normálně ani nastavit nejdou. Třeba barvu pozadí nějakého textu:
<span style="background-color: blue">Mám modré pozadí díky CSS</span>
Tak to je jenom drobná ukázka toho co CSS dovede.
Kaskádovitost
Hlavní kouzlo CSS je ale v jeho kaskádovitosti. Pokud formátuji HTML dokument pomocí CSS, nepřiděluji většinou každému tagu CSS styl pomocí parametru Style="" ale definuji vlastnosti tagů globálně pro celý dokument.
Například: Určím, že tag <h1> (první nadpis) bude zarovnaný na střed, modrou barvou, písmo Arial velikost 16 a text bude potržený. Potom pokaždé, když použiji tag <h1>, zformátuje se jeho obsah automaticky podle předem určených hodnot.
Zní to moc hezky, ale jak to udělat prakticky? Takhle:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Příklad HTML a CSS</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<style>
h1 {text-align: center; font-family: Arial; font-size: 16; color: blue; text-decoration: underline}
</style>
</head>
<body>
<h1>Tadá! CSS se projevilo</h1>
Ten nadpis vypadá ale pěkně.
</body>
</html>
A výsledek:
Vlastní definice CSS jsou zde uvedeny v hlavičce, v obsahu tagu <style>. Je tam jenom jeden řádek:
h1 {text-align: center; font-family: Arial; font-size: 16; color: blue; text-decoration: underline}
Jako první se do definice stylu uvádí název tagu. V tomto případě h1. Za tím následují složené závorky. Ve složených závorkách se uvádějí samotné formátovací vlastnosti a to v tomto formátu:
"{vlastnost1: hodnota1; vlastnost2: hodnota2;}".
Schválně jsem tam zvýraznil dvojtečky a středníky, protože bez jejich správného zápisu vám prohlížeč nebude CSS interpretovat správně!
Takto můžete nadefinovat vzhled skoro každého tagu a přidělit mu formát, jaký si jen přejete.
Externí stylopis
Jsou tři možnosti zápisu CSS. Dvě z nich jsme si už předvedli. První je pomocí parametru style u tagu, na který chcete styl aplikovat. Druhá je umístěním tagu style do hlavičky a vypsání všech CSS stylů do tagu <style>. A třetí způsob, ten který jsme si ještě neukazovali, se provádí pomocí tagu link.
Zápis je stejný jako u druhého způsobu, ale obsah tagu style se umísťuje do externího souboru s příponou .css . Na tento externí stylopis se pak dokumentu HTML odkazuje pomocí tagu link: <link rel="stylesheet" type="text/css" href="stylopis.css">. Do parametru href se zapisuje cesta k stylopisu.
Tag link se umísťuje do hlavičky HTML dokumentu. Toto řešení stylů se v praxi používá nejčastěji, protože jednu definici stylů můžeme použít u více stránek, jelikož je umístěna externě. Snadno tak můžeme formátovat třeba styly všech stránek na jednom webu pomocí jednoho externího stylopisu.
Teď zkusíme převést naposledy předváděný příklad, aby vyhovoval provedení třetího způsobu zápisu CSS:
Obsah souboru priklad2.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Příklad HTML a CSS 2</title>
<link rel="stylesheet" type="text/css" href="styly.css">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
</head>
<body>
<h1>Tadá! CSS se projevilo</h1>
Ten nadpis vypadá ale pěkně.
</body>
</html>
Obsah souboru styly.css:
h1 {text-align: center; font-family: Arial; font-size: 16; color: blue; text-decoration: underline}
Efekt je úplně stejný jako u předcházejícího příkladu. Tento příklad bude samozřejmě fungovat jen, když máte vytvořený soubor styly.css umístěn ve stejném adresáři jako stránku HTML samotnou.
Identifikátory a třídy
Zřejmě nebudete chtít definovat styl jenom tagů samotných, to by vám styly asi brzy došly. Pro další možnosti přiřazování stylů jsou zde třídy a indetifikátory. Těchto záhadných názvů se není třeba vůbec bát, je to úplně jednoduché.
Identifikátory a třídy mají aplikačně stejný efekt. Jediný rozdíl je v zápisu. Správně by se ID (zkratka identifikátoru) mělo používat pouze jedenkrát v celém HTML dokumentu, ale nikomu nebude vadit, i když to omylem použijete vícekrát.
ID se zapisuje s mřížkou (#) před názvem identifikátoru. Třída s obyčejnou tečkou před názvem. A jak se třídy a identifikátory používají v praxi?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Ukázka tříd & identifikatorů</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<style>
span {font-family: Arial, Helvetica, sans-serif; color: lime;}
#uvod {color: blue; background-color: black;}
.zaver {font-size: 36px; font-style: italic; text-decoration: underline;}
</style>
</head>
<body>
<span id="uvod">Víejte na této úžasné stránce formátované pomocí CSS</span><br>
<span>Je fakt supr-čupr! :-)</span>
<span class="zaver">Co říkáte?</span>
</body>
</html>
Pro větší přehlednost používám v příkadech interní stylopis v hlavičce, ale dá se to samozřejmě všechno udělat i externě.
V tomto příkladu je použit jeden identifikátor, jedna třída a jedna definice stylu tagu span. Vidíte, že tagům se definice tříd a indetifikátorů přiřazují pomocí parametrů class a id. Do parametru se názvy tříd a IDček samozřejmě zapisují bez uvozovacího znaku
(# a .).
Zároveň je tu ukázka efektu kaskádovitosti. U tagu span je definována barva color: lime, ale u ID uvod je použitá barva color: blue Jakou barvu bude mít tedy text v tagu span s ID úvod?
Modrou! A proč?
Toto je právě efekt kaskádovitosti. Definice tagu span je ve formátovací hierarchii vzdálenější než definice ID úvod. Proto se na text aplikuje barva modrá. Samozřejmě všechny formátovací vlastnosti, které v ID uvod neurčíte, převezme obsah tagu span přímo zjeho definice.
Na závěr prvního dílu ještě krátká ukázka jednoduché stránky formátované přes CSS. Berte to jako opakování:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Opakování probrané látky o CSS</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
<style>
body {background-color: black;}
h1 {text-align: center; color: #CCCCCC;}
#zacatek {font-style: italic; color: #00FF66;}
p {color: #FFFFFF;}
.zvyrazneni {font-weight: bolder; background-color: #666666;}
#zaver {color: #0099FF; text-decoration: underline;}
</style>
</head>
<body>
<h1>Příkady úžasného CSS</h1>
<p id="zacatek" class="zvyrazneni">CSS je super věc pro formátování webových HTML stránek a měli by ho ovládat všichni zkušení webdesingeři.</p>
<p>Není moc složité a dají se s ním dělat opravdu velké věci!</p>
<p class="zvyrazneni">Jeden stylopis můžete použít u více HTML stránek, když bude umístěn externě.</p>
<p id="zaver">Tak co říkáte, líbí se vám CSS?</p>
</body>
</html>
Komentáře
Přehled komentářů
Have you ever considered about adding a little bit more than just your articles? I mean, what you say is important and everything. But imagine if you added some great graphics or videos to give your posts more, "pop"! Your content is excellent but with pics and videos, this website could certainly be one of the best in its field. Awesome blog! förhandla ränta bolån jobte.teswomango.com/map20.php
vart kan man köpa dr denim jeans
(vart kan man köpa dr denim jeans, 8. 8. 2021 17:32)
Fantastic site you have here but I was wondering if you knew of any discussion boards that cover the same topics discussed here? I'd really like to be a part of community where I can get opinions from other knowledgeable individuals that share the same interest. If you have any suggestions, please let me know. Kudos! vart kan man köpa dr denim jeans liici.teswomango.com/map1.php
bylder i skridtet
(bylder i skridtet, 8. 8. 2021 9:00)
whoah this weblog is excellent i love studying your posts. Keep up the great work! You already know, many people are looking around for this information, you can help them greatly. bylder i skridtet stapv.teswomango.com/map12.php
ole lynggaard ringar online
(ole lynggaard ringar online, 8. 8. 2021 1:25)
Hello just wanted to give you a quick heads up. The text in your content seem to be running off the screen in Safari. I'm not sure if this is a format issue or something to do with browser compatibility but I figured I'd post to let you know. The design and style look great though! Hope you get the problem solved soon. Cheers ole lynggaard ringar online lipan.sewomabest.com/map3.php
köpa larm utan månadskostnad
(köpa larm utan månadskostnad, 7. 8. 2021 15:49)
You're so awesome! I don't suppose I've read a single thing like this before. So good to find someone with a few genuine thoughts on this subject matter. Seriously.. many thanks for starting this up. This site is something that's needed on the web, someone with some originality! köpa larm utan månadskostnad letzre.teswomango.com/map5.php
trött sover hela tiden
(trött sover hela tiden, 7. 8. 2021 6:47)
My brother suggested I may like this blog. He was totally right. This submit truly made my day. You cann't consider simply how a lot time I had spent for this information! Thank you! trött sover hela tiden riaru.sewomabest.com/map24.php
mekonomen däck kampanj
(mekonomen däck kampanj, 6. 8. 2021 22:01)
What's up to every single one, it's in fact a fastidious for me to pay a quick visit this web page, it consists of precious Information. mekonomen däck kampanj etslid.teswomango.com/map9.php
jocke jonna porrfilm
(jocke jonna porrfilm, 6. 8. 2021 10:53)
Hey there! I know this is kind of off topic but I was wondering if you knew where I could find a captcha plugin for my comment form? I'm using the same blog platform as yours and I'm having problems finding one? Thanks a lot! jocke jonna porrfilm obgov.prizsewoman.com/map1.php
affärer i arvika
(affärer i arvika, 6. 8. 2021 2:32)
It's a shame you don't have a donate button! I'd without a doubt donate to this superb blog! I suppose for now i'll settle for book-marking and adding your RSS feed to my Google account. I look forward to new updates and will talk about this blog with my Facebook group. Chat soon! affärer i arvika boisi.teswomango.com/map12.php
klør over hele kroppen om natten
(klør over hele kroppen om natten, 5. 8. 2021 16:25)
Thanks for finally writing about > < Liked it! klør over hele kroppen om natten breezi.teswomango.com/map20.php
the one parfym dam
(the one parfym dam, 5. 8. 2021 7:49)
Hey! I'm at work surfing around your blog from my new apple iphone! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the great work! the one parfym dam loppa.prizsewoman.com/map21.php
Almost all goods from China are of poor quality: truth or fiction?
(KantBoype, 4. 8. 2021 22:30)
Many people have a stereotype in their heads about the low quality of Chinese goods and their short service life. But despite this, all the store shelves are filled with goods from this country, whether it is clothing, appliances or even cars. Let's see what category of quality Chinese goods actually belong to.
Is it true that China produces everything?
According to statistics, every item number five is produced in the "Middle Kingdom". It is not surprising, because there are many factories and industries in the country. The question is, what is China not yet engaged in the production of?
Production of goods in China
Now even operating systems and nuclear reactors, Beijing has put on production. Of course, something is still being purchased from other countries, but the active growth in production is visible to the naked eye.
What has China succeeded most in?
It is obvious that in clothing, shoes and other consumer goods.
Automated shoe sewing lines
Further, the figures are really striking in their scale - 70% of smartphones, 60% of construction materials, 90% of computers and components, and so on, are produced in China. The following areas are also developing - metallurgy, mechanical engineering and shipbuilding, well, it has been known for a long time about Beijing's actively developing program for space exploration. Even the robots beloved by Japan and Korea, China has recently been doing more.
Which companies from the West produce their goods in China?
It is easier to list those who do not produce their goods in this country, because companies such as Apple, Microsoft, Sony, Adidas, Nike, Gucci, Colgate, Nivea and many others have long found in China the main manufacturer of their goods.
Assembly conveyor line at a Chinese factory
There are explanations for this, one of them is the opportunity to open and launch your production according to a ready-made scheme in a very short time and with low costs.
What about cars?
The time when cars from China were like test cars has passed. Now this industry is growing very rapidly, and with it the quality of cars. Now the Chinese car industry is in no way inferior to other manufacturers in comparable classes.
Chinese cars HAVAL
On the roads of any Russian city, you can find a lot of Chinese-made cars, and such popularity indicates the availability and reliability of these cars.
To sum up: is China about quality or not?
Of course, it is impossible to say unequivocally what the quality of the purchased thing will be, because China produces almost all types of goods and does it in huge volumes, but who and under what conditions produces this or that product is another question.
Tag on clothing made in China
A popular myth in our country about low-quality goods with the inscription "Made in China" appeared in the 1990s, it was then that cheap Chinese consumer goods began to appear on the markets of Russia and Europe. Now, serious and high quality control has been established at the factories of China. Any doubts of the quality control department about the product, send the products for reworking. And the success of Chinese companies in the field of mobile development suggests that a lot of attention is paid to the quality of products.
On the website https://china-bazar.com you can order any product from China at an affordable price.
yale doorman prisjakt
(yale doorman prisjakt, 3. 8. 2021 12:51)
This is a topic which is near to my heart... Cheers! Exactly where are your contact details though? yale doorman prisjakt labco.teswomango.com/map15.php
svart röd hårfärg
(svart röd hårfärg, 3. 8. 2021 6:46)
Hey There. I found your blog using msn. This is a really well written article. I will make sure to bookmark it and come back to read more of your useful information. Thanks for the post. I will definitely return. svart röd hårfärg spywir.sewomabest.com/map16.php
bleka håret naturligt
(bleka håret naturligt, 3. 8. 2021 1:13)
This is very interesting, You are a very skilled blogger. I've joined your rss feed and look forward to seeking more of your magnificent post. Also, I have shared your website in my social networks! bleka håret naturligt teauty.teswomango.com/map5.php
Bitcoin NEO to the Moon - BNEO - New era of Crypto!
(bneoshFus, 1. 8. 2021 14:53)
Bitcoin NEO uses peer-to-peer technology to operate with no central authority or banks; managing transactions and the issuing of bitcoins is carried out collectively by the network.
Emission 21 000 000 coins (max supply).
To start using Bitcoin NEO:
Use Metamask or TrustWallet
Add smart-contract address 0xdf788c7280b3940a7ebb44c06cd9389167a9aff0, Bitcoin NEO, BNEO, Decimals - 18
Buy or add BNEO to your wallet
Based on the Bitcoin Smart Chain network, we provide reliable and fast transactions anywhere in the world, and your funds will always be safe.
Site - https://bitcoin-neo.com/?from=x
Buy tokens - https://bitcoin-neo.com/private-sale?from=x
Airdrop - https://bitcoin-neo.com/airdrop?from=x
Distribution BNEO
Team - 10%
Partners - 5%
Reserve - 14%
Promotions - 7%
Airdrop - 2%
Private Sale - 17%
Pre-Sale - 24%
Main Sale - 21%
Resources:
https://t.me/bneo_channel
https://t.me/bneo_chat
https://twitter.com/bneo_crypto
https://bneo.medium.com/
Quality products and drugs only here https://bit.ly/3oZOKnO
(Cax, 31. 7. 2021 11:14)
Quality products and drugs only here
https://bit.ly/3oZOKnO
Cosmetics
(Joshuaseefs, 31. 7. 2021 6:15)
Online shop for womens clothing and accessories based in the UK strives to provide high quality products from the most reliable companies in the world.
We are opening a marketplace for shoppers to find the latest and greatest in-demand products at incredibly low prices.
https://fas.st/d1mskF
Discover Just How The Foods You're Eating On A Daily Basis Are Making Your Fat Cells SICK
(JessesIbre, 29. 7. 2021 21:52)
https://bit.ly/3y8bt5A One of your body's major fat-burning hormonal agents LOWERS when you go on a diet plan?
Research has revealed that this crucial hormonal agent come by as long as 50% after just 7 days of dieting!
The worst component is, the longer you try to diet, the worse it obtains, which is why several "serial dieters" frequently struggle to keep the weight off (if they shed it whatsoever ...).
The bright side is we're mosting likely to share the nourishment methods to INCREASE your body's all-natural fat-burning hormones safely as well as normally! https://bit.ly/3y8bt5A
friends, movies, fashion, actors, trends, social
(JasonSer, 29. 7. 2021 11:30)30 year old Motor Technician (General ) Leo Gottwald from Woodstock, loves telescopes, and bird keeping. Is motivated how huge the earth is after going to Ilulissat Icefjord
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71
förhandla ränta bolån
(förhandla ränta bolån, 9. 8. 2021 3:10)