Quantcast
Channel: Kursus Website Terbaik
Viewing all articles
Browse latest Browse all 2170

Cara Menggunakan Pseudo Element Selector first-letter

$
0
0

Masih ingatkah teman-teman tentang element selector pseudo yang kemarin, kemarin kita baru saja membuat salah satu pseudo element selector first line ya teman-teman tapi disini kita akan coba belajar cara menggunakan pseudo element selector first-letter, pengertian tentang Pseudo element teman-teman bisa lihat langsung pada artikel saya yang kemarin ya teman-teman, jika teman-teman baru saja bergabung bisa klik disini untuk melihat artikel saya yang sebelumnnya, oke jika sudah kita lanjutkan bagaimana cara membuatnnya simak terus ya teman-teman.

Langsung saja cara menggunakan pseudo element selector first-letter Apabila selector ::first-line digunakan untuk mengakses baris pertama sebuah element, maka selector ::first-letter dgunakan untuk meangakses huruf/karakter pertama dari sebuah element. Wah jika kita lihat dari kata-kata ini sudah ada bayangan ya teman-teman, seperti huruf pertama yang ada pada sebuah surat kabar seperti koran ya teman-teman, bagaimana teman-teman sudah ada bayangan belum jika belum, kita lanjutkan.

Dengan menggunakan ::first-letter, kita bisa dengan mudah membuat efek ‘drop cap’, dimana huruf pertama dibuat besar, seperti contoh berikut:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Belajar CSS</title>
<style>
p::first-letter{
color:red;
font-size: 2em;
}
</style>
</head>
<body>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
<p>
Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32.
</p>
</body>
</html>

cara menggunakan pseudo element selector first-letter

Dalam contoh diatas saya membuat huruf pertama setiap tag <p> agar berukuran besar dan berwarna merah. Tanpa menggunakan selector ::first-letter, hal ini cukup sulit dilakukan, karena untuk mendapatkan efek yang sama kita harus menambahkan tag <span> pada setiap huruf pertama (ditambahkan secara manual). sampai disini dulu belajar kita tentang cara menggunakan pseudo element selector first-letter, semoga bermanfaat dan sampai jumpa.

The post Cara Menggunakan Pseudo Element Selector first-letter appeared first on Kursus Website Terbaik.


Viewing all articles
Browse latest Browse all 2170

Trending Articles