Agar baris kode yang saya masukkan di artikel Blogger terlihat berbeda, saya menerapkan CSS Pre Code warna-warni.
Kadang-kadang saya merasa perlu memasukkan baris-baris kode dalam artikel. Agar baris kode yang saya masukkan di artikel Blogger terlihat berbeda, saya menerapkan CSS Pre Code. Ini adalah contoh dengan latar belakang hitam dalam tulisan warna-warni yang saya ambil dari Codepen.
Bagaimana Menerapkan CSS Pre Code untuk Blogger?
CSS yang digunakan:
/* CSS Simple Pre Code */
pre {
background: #333;
white-space: pre;
word-wrap: break-word;
overflow: auto;
}
pre.code {
margin: 20px 25px;
border-radius: 4px;
border: 1px solid #292929;
position: relative;
}
pre.code label {
font-family: sans-serif;
font-weight: bold;
font-size: 13px;
color: #ddd;
position: absolute;
left: 1px;
top: 15px;
text-align: center;
width: 60px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
pointer-events: none;
}
pre.code code {
font-family: Courier,monospace;
display: block;
margin: 0 0 0 60px;
padding: 15px 16px 14px;
border-left: 1px solid #555;
overflow-x: auto;
font-size: 13px;
line-height: 19px;
color: #ddd;
}
pre::after {
content: "double click to selection";
padding: 0;
width: auto;
height: auto;
position: absolute;
right: 18px;
top: 14px;
font-size: 12px;
color: #ddd;
line-height: 20px;
overflow: hidden;
-webkit-backface-visibility: hidden;
transition: all 0.3s ease;
}
pre:hover::after {
opacity: 0;
visibility: visible;
}
pre.code-css code {
color: #91a7ff;
}
pre.code-html code {
color: #aed581;
}
pre.code-javascript code {
color: #ffa726;
}
pre.code-jquery code {
color: #4dd0e1;
}
Bagaimana cara menulisnya di artikel?
Untuk HTML
<pre class='code code-html'><label>HTML</label><code>
Letakkan kode HTML di sini
</code></pre>
atau untuk CSS
<pre class='code code-css'><label>CSS</label><code>
Letakkan kode CSS di sini
</code></pre>
atau untuk JavaScript
<pre class='code code-javascript'><label>JS</label><code>
Letakkan kode JavaScript di sini
</code></pre>
atau untuk jQuery
<pre class='code code-jquery'><label>JQuery</label><code>
Letakkan kode JQuery di sini
</code></pre>
Selamat mencoba menerapkan CSS Pre Code untuk Blogger.
Catatan: Agar klik ganda berfungsi untuk memilih semua kode ("double click to selection"), mau tidak mau Anda harus menambahkan JavaScript.
Dan tidak bisa juga akhirnya mengelak javascript😁
ReplyDeleteIf you're attempting to lose weight then you absolutely need to start using this brand new tailor-made keto diet.
ReplyDeleteTo create this service, certified nutritionists, personal trainers, and chefs united to provide keto meal plans that are effective, suitable, economically-efficient, and delicious.
From their launch in early 2019, 1000's of people have already transformed their body and health with the benefits a great keto diet can give.
Speaking of benefits; in this link, you'll discover eight scientifically-proven ones offered by the keto diet.