<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: KhanhKitin</title>
    <description>The latest articles on DEV Community by KhanhKitin (@khanhkitin).</description>
    <link>https://dev.to/khanhkitin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F612267%2Fee80b0d9-1673-4405-a2a2-90e3ab54e2c0.jpeg</url>
      <title>DEV Community: KhanhKitin</title>
      <link>https://dev.to/khanhkitin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/khanhkitin"/>
    <language>en</language>
    <item>
      <title>A few CSS tricks that frontend developers should know</title>
      <dc:creator>KhanhKitin</dc:creator>
      <pubDate>Sat, 26 Jun 2021 19:08:29 +0000</pubDate>
      <link>https://dev.to/khanhkitin/a-few-css-tricks-that-frontend-developers-should-know-i6a</link>
      <guid>https://dev.to/khanhkitin/a-few-css-tricks-that-frontend-developers-should-know-i6a</guid>
      <description>&lt;p&gt;Here is a few tricks that I encountered in the process of making CSS and learned how to solve it in a simple way.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Vertical alignment
&lt;/h3&gt;

&lt;p&gt;I offten use this in a CSS Navigation Menu.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44lgx4zzqnybr5axiany.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F44lgx4zzqnybr5axiany.png" alt="vertical-alignment" width="800" height="69"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Remove white space below image
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdawvrgucrahx4n2xux45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdawvrgucrahx4n2xux45.png" alt="remove-white-space-below-image" width="800" height="343"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;&lt;br&gt;
.img-css {&lt;br&gt;
    width: 300px;&lt;br&gt;
    height: 200px;&lt;br&gt;
    display: block;&lt;br&gt;
}&lt;br&gt;
&lt;strong&gt;or&lt;/strong&gt;&lt;br&gt;
.img-css {&lt;br&gt;
    vertical-align: middle&lt;br&gt;
}&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Using display: flex, the icon is distorted when the text is long
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faezv16jmt50yc0vpjv9c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faezv16jmt50yc0vpjv9c.png" alt="using-display-flex-the-icon-is-distorted-when-the-text-is-long" width="800" height="317"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;&lt;br&gt;
.cc {&lt;br&gt;
  width: 50px;&lt;br&gt;
  height: 50px;&lt;br&gt;
  background-color: red;&lt;br&gt;
  border-radius: 50%;&lt;br&gt;
  margin-right: 20px;&lt;br&gt;
  &lt;strong&gt;flex-shrink: 0;&lt;/strong&gt;&lt;br&gt;
}&lt;/p&gt;

&lt;h3&gt;
  
  
  4.  Truncate Text
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt;&lt;br&gt;
{&lt;br&gt;
    white-space: nowrap;&lt;br&gt;
    text-overflow: ellipsis;&lt;br&gt;
    overflow: hidden;&lt;br&gt;
}&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft8df7skeoc5k8cjutk4m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft8df7skeoc5k8cjutk4m.png" alt="truncate-text" width="800" height="348"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Disable Text Selection Highlighting
&lt;/h3&gt;

&lt;p&gt;If we want to disable the highlight effect.&lt;br&gt;
&lt;strong&gt;Solution&lt;/strong&gt;&lt;br&gt;
user-select: none;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fecncyctsdvrqz31crm2p.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fecncyctsdvrqz31crm2p.gif" alt="Disable-Text-Selection-Highlighting" width="600" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Make a Textarea Unable to Resize
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvzlsbu3foxmc3kj1vrp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuvzlsbu3foxmc3kj1vrp.png" alt="Make-a-Textarea-Unable-to-Resize" width="800" height="688"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  7.  Math with Calc
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mnluduilys4poc10rf0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1mnluduilys4poc10rf0.png" alt="Math-with-Calc" width="800" height="213"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Change an HTML5 Input Placeholder Color
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpom55y4ralmdzdhuc71p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpom55y4ralmdzdhuc71p.png" alt="Change-an-HTML-Input-Placeholder-Color" width="800" height="463"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The article will still be updated with more cool things about CSS. Thank you for your support and reading until now. &lt;br&gt;
My blogs &lt;a href="https://www.hoangkhanh.tech" rel="noopener noreferrer"&gt;hoangkhanh.tech&lt;/a&gt;&lt;br&gt;
Thank you!&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>tricks</category>
      <category>tips</category>
    </item>
    <item>
      <title>Tips, Trick And Best Practices JavaScript</title>
      <dc:creator>KhanhKitin</dc:creator>
      <pubDate>Sun, 06 Jun 2021 14:06:01 +0000</pubDate>
      <link>https://dev.to/khanhkitin/tips-trick-and-best-practices-javascript-1cf9</link>
      <guid>https://dev.to/khanhkitin/tips-trick-and-best-practices-javascript-1cf9</guid>
      <description>&lt;p&gt;"Be persistent and never stop learning because life is a challenging race, you will receive countless valuable lessons in return." Hello Developers! Learning, accumulating new things every day helps us to improve our skills better and better. As a software developer, our job is to constantly learn new things, update technology, improve our own programming skills. In this article, I will learn some good tips, tricks, and methods in javascript.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Multiple “if and else”,  Switch...case,  Object Literal.
&lt;/h3&gt;

&lt;p&gt;With the code has many if else, else if, we will feel very stuck. So we will often think of switching to a switch case, which will look clearer and more beautiful. And for me, I also use the switch case.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9w7f36a7qcejgj105tt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9w7f36a7qcejgj105tt.png" alt="Example many if else" width="800" height="503"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78b8c7lenylea2sf68zt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F78b8c7lenylea2sf68zt.png" alt="Example Switch case and Object literal" width="800" height="960"&gt;&lt;/a&gt;&lt;br&gt;
The switch case is good but it also has some problems like having to break to prevent it from continuing. And I find it still quite lengthy, with objects it is flexible, concise and easy to understand. Both methods have different advantages and disadvantages. I usually use switch case =). In some cases, use object.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Destructuring, Spread Syntax and Rest Parameters.
&lt;/h3&gt;

&lt;p&gt;These features help us work with data structures faster, more concise.&lt;/p&gt;

&lt;h5&gt;
  
  
  * Destructuring
&lt;/h5&gt;

&lt;p&gt;Is a syntax that allows you to assign properties of an Object or an Array.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3a378aaaac3hgx5scta.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo3a378aaaac3hgx5scta.png" alt="example object destructuring" width="800" height="699"&gt;&lt;/a&gt;&lt;br&gt;
Above is an example of Object Destructuring, and below is an example of Array Destructuring.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1lrh0sfp8r2cv7jehmh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1lrh0sfp8r2cv7jehmh.png" alt="example array destructuring" width="800" height="310"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  * Spread Syntax
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfcmipfrsz7opoh9vmul.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frfcmipfrsz7opoh9vmul.png" alt="example spread syntax" width="800" height="689"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  * Rest Parameters
&lt;/h5&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faplz9dpdes1hknqsqfs1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faplz9dpdes1hknqsqfs1.png" alt="example rest parameters" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Optional Chaining and Nullish Coalescing
&lt;/h3&gt;

&lt;h5&gt;
  
  
  * Optional Chaining
&lt;/h5&gt;

&lt;p&gt;Check an attribute exists or not? If it does not exist, it will return undefined.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxikdk3hb2uidbvwmp5h0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxikdk3hb2uidbvwmp5h0.png" alt="example optional chaining" width="639" height="456"&gt;&lt;/a&gt;&lt;br&gt;
Optional Chaining makes the code shorter, easier to access the properties of the object.&lt;br&gt;
With array.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhe53ec8ug6szpqs48xy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkhe53ec8ug6szpqs48xy.png" alt="example optional chaining with array" width="639" height="614"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h5&gt;
  
  
  * Nullish Coalescing
&lt;/h5&gt;

&lt;p&gt;I often use the operator || to provide a default value for a variable. And now I still use it, hehe, but I have read the article carefully when using the or operator to provide a default value. It was also correct to read, then I went to MDN to read and know about Nullish Coalescing.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8eyc26x4sf2cpp1hef6w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8eyc26x4sf2cpp1hef6w.png" alt="example nullish coalescing" width="640" height="403"&gt;&lt;/a&gt;&lt;br&gt;
Syntax: leftExpr ?? rightExpr&lt;br&gt;
If leftExpr is nullish ( NULL or UNDEFINED ) the result will be rightExpr. If leftExpr has a value, the result is leftExpr.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftd91w8zgctt815q1fcmm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftd91w8zgctt815q1fcmm.png" alt="example nullish coalescing two" width="640" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Multiple Condition
&lt;/h3&gt;

&lt;p&gt;You may have encountered a situation where there are many conditions that perform the same task. For example, with admin, leader or member rights, they all have the same rights (for example, the right to edit, delete posts, ...).&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feusl0hmgux5sguuxayt7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feusl0hmgux5sguuxayt7.png" alt="Multiple Condition One" width="800" height="136"&gt;&lt;/a&gt;&lt;br&gt;
We have many ways to make the code shorter, and look better.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxdc7sdcuk2xi3ddevq8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffxdc7sdcuk2xi3ddevq8.png" alt="Multiple Condition Two" width="800" height="252"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I prefer to use includes :))&lt;br&gt;
The article will still be updated with more cool things about javascript. Thank you for your support and reading until now. &lt;br&gt;
My blogs &lt;a href="https://www.hoangkhanh.tech" rel="noopener noreferrer"&gt;hoangkhanh.tech&lt;/a&gt;&lt;br&gt;
Thank you!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
