<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hattagorn Ngamsai on Medium]]></title>
        <description><![CDATA[Stories by Hattagorn Ngamsai on Medium]]></description>
        <link>https://medium.com/@hattagornngamsai?source=rss-4d8b8f4bcd25------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OtvMtb-bzwrPWD--tMTQRg.jpeg</url>
            <title>Stories by Hattagorn Ngamsai on Medium</title>
            <link>https://medium.com/@hattagornngamsai?source=rss-4d8b8f4bcd25------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 02:10:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hattagornngamsai/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[มารู้จัก Local Storage กัน]]></title>
            <link>https://medium.com/@hattagornngamsai/%E0%B8%A1%E0%B8%B2%E0%B8%A3%E0%B8%B9%E0%B9%89%E0%B8%88%E0%B8%B1%E0%B8%81-local-storage-%E0%B8%81%E0%B8%B1%E0%B8%99-bc64755dcc56?source=rss-4d8b8f4bcd25------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc64755dcc56</guid>
            <dc:creator><![CDATA[Hattagorn Ngamsai]]></dc:creator>
            <pubDate>Tue, 26 Mar 2019 10:41:02 GMT</pubDate>
            <atom:updated>2019-03-26T10:41:02.736Z</atom:updated>
            <content:encoded><![CDATA[<p>ในปัจจุบันการเก็บข้อมูลของ users ผ่านเว็บบราวเซอร์นั้นมีหลายวิธี โดยการใช้ Local Storage ก็เป็นวิธีหนึ่งที่น่าสนใจเพราะอะไรมาลองดูกัน</p><p><strong>Web Storage ใน HTML5</strong></p><p>การจัดข้อมูลของ Web Storage จะเก็บข้อมูลไว้ฝั่ง Client side แบบเดียวกันกับ cookie แต่มีข้อดีกว่าคือ Web Storage จะไม่ส่ง HTTP Header เพื่อไปขอฝั่ง Server จึงทำงานได้ไวกว่า cookie อีกทั้ง Web Storage ยังสามารถเก็บข้อมูลได้มากกว่า cookie ถึง 5MB ต่อ 1 โดเมน</p><p><strong>การใช้งาน Web Storage แบ่งออกเป็น 2 ส่วนด้วยกันคือ</strong></p><ol><li>Local Storage คือ การเก็บข้อมูลใส่ Local Storage แบบถาวร ข้อมูลจะหายไปก็ต่อเมื่อ clear Storage หรือกำหนดเวลาวันหมดอายุ</li><li>Session Storage คือ การเก็บข้อมูลใส่ Session Storage ซึ่งเมื่อปิดเว็บบราวเซอร์ข้อมูลก็จะหายไปหรือกำหนดระยะเวลาวันหมดอายุ</li></ol><p><strong>วิธีใช้ Local Storage</strong></p><p>การใช้ Local Storage มีวิธีกำหนดค่าดังนี้</p><ol><li>localStorage.setItem(key, value) คือ การเก็บข้อมูลลงใน Local Storage</li><li>localStorage.getItem(key) คือ การเรียกใช้ข้อมูล key ของ Local Storage</li><li>localStorage.removeItem(key) คือ การลบข้อมูลที่ key เก็บไว้</li><li>localStorage.clear() คือ การลบข้อมูลทั้งหมดในโดเมน</li></ol><p><strong>ลองฝึกใช้ Local Storage ร่วมกับ form html</strong></p><p>เราจะสร้างแบบฟอร์มเพื่อรับข้อมูลชื่อ ราคาของสินค้าใส่ลง Local Storage และเรียกใช้มูลจาก Local Storage มาแสดงหน้า layout</p><ol><li>สร้างไฟล์ localstorage_Form.php ขึ้นมาเพื่อสร้างแบบฟอร์มรับข้อมูลชื่อและราคา มีปุ่ม submit และปุ่ม remove</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/487/1*Wei7TCIdNoMYtwCHnxJcGA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*82Vnc8QEG4iTGRTuqivlBA.png" /></figure><p>2. สร้างฟังก์ชั่นใน javascript saveMy() และ removeMy() เพื่อนำข้อมูลจาก form ไป set ใน local Storage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PKb9DbLQ3wY6gTNWOp9nnQ.png" /></figure><p>2.1 วิธีสร้างฟังก์ชั่น saveMy()</p><p>สร้าง key และ value เพื่อ set ข้อมูล โดยใช้คำสั่ง localStorage.setItem(key,value) ระบุ key ชื่อ ‘productList’ และ ระบุ value ชื่อ getProduct</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*H--hAXbykiHqP72u6gYxuA.png" /></figure><p>กำหนดค่า getProduct[];</p><p>สร้าง object key ชื่อ localproductName และ localPrice เพื่อมารับค่า value ที่ถูกส่งมาจาก input ฟอร์ม</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*YkQwWE0Xdizk_H5xcB-TKA.png" /></figure><p>สังเกตว่า Web Storage จะเก็บข้อมูลเป็น String ดังนั้น getProduct จึงต้องใช้ Json.stringify</p><p>2.2 วิธีสร้างฟังก์ชั่น removeMy()</p><p>กำหนด key ที่ต้องการจะลบซึ่งก็คือ ‘localproductName’ และ ’localPrice’ โดยใช้ localStorage.removeItem</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*u5d63qGt94dsZFJWha0_Vg.png" /></figure><p>2.3 วิธีเคลียโดเมนของ LocalStorage</p><p>ใช้ localStorage.clear() เพื่อเคลียข้อมูลทั้งหมดใน LocalStorage ของโดเมน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/298/1*hnd0MZ6Lp7OPiJnVL53UXQ.png" /></figure><p>3. เมื่อกำหนดค่า key และ value ของ Local Storage เสร็จแล้ว ลองมาตรวจสอบข้อมูลใน localStorage กัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R26nzK-xfPqxxsucwhMGkA.png" /></figure><p>3.1 วิธีการเข้าไปดูข้อมูล Local Storage</p><p>คลิกขวา Inspect -&gt; เข้าเมนู Application -&gt; Local Storage</p><p>3.2 เมื่อใส่ข้อมูลในช่อง product-name และ Original Price แล้วกด save ข้อมูลจะถูกเก็บลง key และ value</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttBvIl0qn3PR2fLtBhACLA.png" /></figure><p>4. สร้างไฟล์ localstorage_Product.php เพื่อรับข้อมูลจาก form มาแสดง layout</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/986/1*1QYaNJNarVCr0JbEmMt3Hw.png" /></figure><p>4.1 วิธีการ get ข้อมูลจาก Local Storage</p><p>เราจะใช้ javascript ในการ get ข้อมูลเนื่องจาก Local Storage เป็นฝั่ง Client side</p><p>ใช้คำสั่ง localStorage.getItem(ตามด้วยระบุ key ซึ่งคือ productList) เพื่อ get ข้อมูล สังเกตว่าเนื่องจากเราใช้ JSON.stringify ในการ set ข้อมูลดังนั้น ต้องใช้ JSON.parse ในการ get ข้อมูลเช่นกัน</p><p>ผลลัพธ์ layout จะแสดงผลดังนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/948/1*ZjUEIoC76a39T7iaou3mkA.png" /></figure><p>จากตัวอย่างก็พอทราบว่า Local Storage สามารถทำอะไรได้บ้าง</p><p><strong>แล้วข้อเสีย Web Storage มันมีข้อเสียบ้างไหม?</strong></p><p>เนื่องจาก Web Storage เก็บข้อมูลเป็น String ดังนั้นมีโอกาสถูกอ่านข้อมูลได้ง่ายไม่ปลอดภัย จึงไม่นิยมใช้ Web Storageในการเก็บข้อมูลที่เป็นความลับ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc64755dcc56" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SESSION ใน PHP คืออะไร?]]></title>
            <link>https://medium.com/@hattagornngamsai/session-%E0%B9%83%E0%B8%99-php-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3-76d2573fce5d?source=rss-4d8b8f4bcd25------2</link>
            <guid isPermaLink="false">https://medium.com/p/76d2573fce5d</guid>
            <dc:creator><![CDATA[Hattagorn Ngamsai]]></dc:creator>
            <pubDate>Mon, 18 Mar 2019 05:04:58 GMT</pubDate>
            <atom:updated>2019-03-18T05:07:49.287Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>SESSION ใน PHP คืออะไร?</strong></p><p>Session หรือ Web Session เป็น value ที่จะถูกสร้างขึ้นมาเมื่อ Client มีการเปิดเว็บบราวเซอร์และติดต่อกับ URL ของเว็บไซต์นั้น เมื่อ Client ปิดตัวลง session จะถูกทำลายหรือปิดลง ข้อมูลจะถูกบันทึกลง session ในฝั่ง server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i2gwkSS1DPpCOprrkIl8hQ.png" /><figcaption>อ้างอิงรูปภาพจาก <a href="https://code.tutsplus.com/tutorials/how-to-use-sessions-and-session-variables-in-php--cms-31839">https://code.tutsplus.com/tutorials/how-to-use-sessions-and-session-variables-in-php--cms-31839</a></figcaption></figure><p>ถ้าหากเราจะสร้างหรือเก็บข้อมูลลง session ต้องทำอย่างไร?</p><ol><li>ใช้สคริปต์ php เพื่อติดต่อกับ session ฝั่ง Server และส่ง html ไปยังฝั่ง Client</li></ol><p>1.1 สร้างไฟล์ session1.php</p><pre><strong>&lt;?php<br></strong>session_start();<br>session_id();<br>$Username = <strong>array</strong>(&#39;bank&#39;,&#39;big&#39;,&#39;nut&#39;);<br>$_SESSION[&#39;username&#39;]= $Username;<br><br><strong>foreach </strong>($_SESSION[&#39;username&#39;] <strong>as </strong>$key){<br>    <strong>echo</strong>(&#39;Session[username]:&#39;.$key.&quot;&lt;br&gt;&quot;);<br><br>}<br><strong>echo </strong>&#39;Session_id:&#39;.session_id();<br><br><strong>?&gt;</strong></pre><ul><li>session_start() คือ ประกาศสร้าง session ต้อง<strong>สร้างเป็นอันดับแรก</strong>เสมอ</li><li>session_id() คือ ค่า id ของ session เมื่อกำหนด session start ตัวแปร session id จะถูกสร้างขึ้นมาทันที เพื่อระบุใช้ยืนยันของแต่ละบุคคลเลข seesion id จึงไม่ซ้ำกัน</li><li>$_SESSION คือ การใช้เรียกงาน session ไม่ว่าจะเป็นการเก็บข้อมูลหรือนำ session ไปใช้งานอย่างอื่น(แต่ในตัวอย่างใช้ array เก็บชื่อใส่ไว้ใน $_SESSION[‘username’] )</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*_dSigLmy0HJ8Yr3Qo2H7bg.png" /><figcaption>session1.php</figcaption></figure><p>2. สร้างไฟล์ session2.php เพื่อเรียกใช้ session1.php</p><pre><strong>&lt;?php<br></strong>session_start();<br><strong>foreach </strong>($_SESSION[&#39;username&#39;] <strong>as </strong>$key){<br>    <strong>echo</strong>(&#39;Session[username]:&#39;.$key.&quot;&lt;br&gt;&quot;);<br>}<br><strong>echo </strong>&#39;Session_id:&#39;.session_id();<br><strong>?&gt;</strong></pre><p>เราสามารถเรียกใช้ค่า $_SESSION[‘username’] ในไฟล์ session1.php ได้เลย</p><p>สังเกตได้ว่าค่า session id ตัวเลขกับไฟล์ session1.php และ session2.php มีค่าตรงกัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*hjAPU_N9pb-LxTTP8hclGA.png" /><figcaption>session2.php</figcaption></figure><p>3. ถ้าหากจะปิดหรือลบ Session ต้องทำอย่างไร?</p><p>ใช้สองฟังก์ชันนี้คือ</p><p>3.1 session_unset();</p><p>ข้อมูล $_SESSION[‘username’] จะโดยลบไปหลังใช้ session_unset();</p><pre><strong>&lt;?php<br></strong>session_start();<br><strong>foreach </strong>($_SESSION[&#39;username&#39;] <strong>as </strong>$key){<br>    <strong>echo</strong>(&#39;Session[username]:&#39;.$key.&quot;&lt;br&gt;&quot;);<br>}<br><strong>echo </strong>&#39;Session_id:&#39;.session_id();<br><br><strong>unset</strong>($_SESSION[&#39;username&#39;]);<br><strong>foreach </strong>($_SESSION[&#39;username&#39;] <strong>as </strong>$key){<br>    <strong>echo</strong>(&#39;Session[username]:&#39;.$key.&quot;&lt;br&gt;&quot;);<br>}<br><strong>echo </strong>&#39;Session_id:&#39;.session_id();<br><strong>?&gt;</strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EEiJxT57HmryWBFgK_v9gg.png" /><figcaption>session_unset();</figcaption></figure><p>3.2 session_destroy();</p><p>ข้อมูล $_SESSION[‘username’] จะถูกทำลายหลังใช้ session_destroy();</p><pre><strong>&lt;?php<br></strong>session_start();<br><strong>foreach </strong>($_SESSION[&#39;username&#39;] <strong>as </strong>$key){<br>    <strong>echo</strong>(&#39;Session[username]:&#39;.$key.&quot;&lt;br&gt;&quot;);<br>}<br><strong>echo </strong>&#39;Session_id:&#39;.session_id();<br>session_destroy($_SESSION[&#39;username&#39;]);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1wQvqLWAKoPbDi4egDqoVw.png" /><figcaption>session_destroy();</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76d2573fce5d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[วิธีอัพโหลดรูปภาพโดยใช้ HTML Form + PHP แสดงรูปหน้าเว็บเพจ]]></title>
            <link>https://medium.com/@hattagornngamsai/%E0%B8%A7%E0%B8%B4%E0%B8%98%E0%B8%B5%E0%B8%AD%E0%B8%B1%E0%B8%9E%E0%B9%82%E0%B8%AB%E0%B8%A5%E0%B8%94%E0%B8%A3%E0%B8%B9%E0%B8%9B%E0%B8%A0%E0%B8%B2%E0%B8%9E%E0%B9%82%E0%B8%94%E0%B8%A2%E0%B9%83%E0%B8%8A%E0%B9%89-html-form-php-%E0%B9%81%E0%B8%AA%E0%B8%94%E0%B8%87%E0%B8%A3%E0%B8%B9%E0%B8%9B%E0%B8%AB%E0%B8%99%E0%B9%89%E0%B8%B2%E0%B9%80%E0%B8%A7%E0%B9%87%E0%B8%9A%E0%B9%80%E0%B8%9E%E0%B8%88-793811c7037f?source=rss-4d8b8f4bcd25------2</link>
            <guid isPermaLink="false">https://medium.com/p/793811c7037f</guid>
            <dc:creator><![CDATA[Hattagorn Ngamsai]]></dc:creator>
            <pubDate>Thu, 14 Mar 2019 11:41:53 GMT</pubDate>
            <atom:updated>2019-03-14T11:41:53.979Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>วิธีอัพโหลดรูปภาพโดยใช้ HTML Form + PHP แสดงรูปหน้าเว็บเพจ</strong></p><p>เมื่อเราสร้าง form ขึ้นมาแต่ไม่รู้จะส่ง data รูปภาพผ่าน method post หรือ get ไปแสดงหน้า layout หน้าเว็บเพจยังไง ในนี้มีคำตอบให้</p><ol><li>สร้างรูปแบบ html form ขึ้นมา โดยกำหนด <strong>enctype=multipart/form-data</strong> ไว้ข้างใน Tag form เพื่อให้ form สามารถส่งไฟล์ได้แบบ multipart นอกเหนือจาก text เช่น ไฟล์รูปภาพ</li></ol><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;title&gt;imgForm&lt;/title&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>&lt;form class=&quot;imgForm&quot; action=&quot;leanform.php&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;<br>    &lt;input type=&quot;file&quot; name=&quot;upload&quot; /&gt;<br>    &lt;input type=&quot;submit&quot;  name=&quot;save&quot;  value=&quot;upload&quot; /&gt;<br>&lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*AIQN8RKgzdMK7kSaVklIzw.png" /><figcaption>layout ที่ได้จาก code form</figcaption></figure><p>2. สร้าง php file เพื่อรับ data method =”post ”จาก form</p><pre><strong>&lt;?php<br>if</strong>($_POST){<br>    <strong>if</strong>(<strong>isset</strong>($_FILES[&#39;upload&#39;])){<br>        $name_file =  $_FILES[&#39;upload&#39;][&#39;name&#39;];<br>        $tmp_name =  $_FILES[&#39;upload&#39;][&#39;tmp_name&#39;];<br>        $locate_img =&quot;pic/&quot;;<br>        move_uploaded_file($tmp_name,$locate_img.$name_file);<br>    }<br>}<br><strong>?&gt;</strong></pre><p>อธิบายขั้นตอนการทำงานจาก code ข้างบน</p><p>2.1 ใช้ if($_POST)เพื่อค้นหา data ของ API method post ถูกส่งจากมาก form</p><p>2.2 ถ้าหากเจอ data ให้ <strong>if</strong>(<strong>isset</strong>($_FILES[‘upload’])) เพื่อตรวจสอบชนิดของ data type โดยถ้า print_r($_FILES[‘upload’]) จะพบข้อมูลดังภาพ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*mJaTvbAeW_x8gDUVUikH6Q.png" /><figcaption>รูป print_r($_FILES[‘upload’])</figcaption></figure><p>2.3 จะสังเกตว่าภายใน array มีค่า key [name],[tmp_name],[error],[size] ดังนั้นเราจะใช้ฟังก์ชั่น move_uploaded_file เพื่อช่วย copy tmp จาก server ที่ได้จาก form upload ย้ายมาเก็บใน folder ใหม่</p><p>2.4 อธิบายรูปแบบการใช้งานฟังก์ชั่น move_uploaded_file</p><p>ฟังก์ชั่น move_uploaded_file จะมีรูปแบบการใช้งานคือกำหนด parameter $filename,$destination ดังนี้</p><p>move_uploaded_file( $filename , $destination )<br>move_uploaded_file( ชื่อไฟล์ , ปลายทางที่จะย้าย )</p><p>ฟังก์ชั่น move_uploaded_file return ค่าเป็น boolean</p><p>2.5 กำหนด value เพื่อใช้ร่วมกับฟังก์ชั่น move_uploaded_file</p><pre>$name_file =  $_FILES[&#39;upload&#39;][&#39;name&#39;];<br>$tmp_name =  $_FILES[&#39;upload&#39;][&#39;tmp_name&#39;];<br>$locate_img =&quot;pic/&quot;;<br>move_uploaded_file($tmp_name,$locate_img.$name_file);</pre><ul><li>$name_file = $_FILES[‘upload’][‘name’]; คือ เก็บค่า name ของภาพที่ form upload ส่งมา</li><li>$tmp_name = $_FILES[‘upload’][‘tmp_name’]; คือการเก็บค่า data ของภาพ ที่อยู่ใน tmp ซึ่งอยู่บน server</li><li>locate_img =”/{path}” คือ เก็บตำแหน่ง path ใน folder ภาพที่ sever ของ form upload ส่งมา</li></ul><p>3. สร้าง layout แสดง display รูปภาพ</p><pre><strong>&lt;?php<br>if</strong>($_POST){<br>    <strong>if</strong>(<strong>isset</strong>($_FILES[&#39;upload&#39;])){<br>        $name_file =  $_FILES[&#39;upload&#39;][&#39;name&#39;];<br>        $tmp_name =  $_FILES[&#39;upload&#39;][&#39;tmp_name&#39;];<br>        $locate_img =&quot;pic/&quot;;<br>        move_uploaded_file($tmp_name,$locate_img.$name_file);<br>    }<br>}<br><strong>?&gt;</strong><br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>    &lt;head&gt;<br>        &lt;title&gt;getForm&lt;/title&gt;<br>    &lt;/head&gt;<br>    &lt;body&gt;<br>            Img:&lt;img style=&quot;width: 200px;height: 200px&quot; <strong>src=&quot;pic/&lt;?php print_r$name_file?&gt;&quot;&gt;</strong><br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><p>ใช้ html tag &lt;img src=”{path img}/”<strong>&lt;?php echo </strong>$name_file<strong>?&gt;”</strong>&gt; เพื่อเรียก path รูปและแสดง layout เป็นภาพออกมา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*f-BGOFTKkpKiWWLr4QDrZw.png" /><figcaption>หลังจากกด upload form</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=793811c7037f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSS คืออะไร?]]></title>
            <link>https://medium.com/@hattagornngamsai/css-%E0%B8%84%E0%B8%B7%E0%B8%AD%E0%B8%AD%E0%B8%B0%E0%B9%84%E0%B8%A3-97c6ff59671d?source=rss-4d8b8f4bcd25------2</link>
            <guid isPermaLink="false">https://medium.com/p/97c6ff59671d</guid>
            <dc:creator><![CDATA[Hattagorn Ngamsai]]></dc:creator>
            <pubDate>Wed, 13 Mar 2019 09:01:36 GMT</pubDate>
            <atom:updated>2019-03-13T09:01:36.930Z</atom:updated>
            <content:encoded><![CDATA[<p>CSS ย่อมาจาก Cascading Style Sheets เป็นตัวช่วยในการตกแต่งเว็บเพจ HTMLให้สวยงามมากขึ้น</p><p>วิธีการเรียกใช้ CSS ในเว็บเพจ HTML มี 3 รูปแบบด้วยกัน</p><ol><li>Inline Style Sheet</li><li>Embed Style Sheet</li><li>External Style Sheet</li></ol><ul><li>วิธีเรียกแบบ<strong> Inline Style Shee<em>t</em></strong> เป็นการเรียกโดยกำหนดใส่ style ใส่ HTML ใน line ลงไป</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/310/1*GUyQjmiL1p2QJhIViYdNew.png" /></figure><pre>&lt;div style=&quot;color:blue;font-size:20px;&quot;&gt;<br>    Inline Style Sheet<br>&lt;/div&gt;</pre><ul><li>วิธีเรียกแบบ<strong><em> </em>Embed Style Sheet<em> </em></strong>เป็นการเรียกใช้ CSS โดยใช้การประกาศ style ลงใน tag ใน header เพื่อนำไปเรียกใช้ในส่วนของ body ในเว็บเพจ</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/254/1*SnyFIifhzJ-YnLaaire-AQ.png" /></figure><pre>&lt;!DOCTYPE html&gt;<br>    &lt;html&gt;<br>    &lt;head&gt;<br>        &lt;title&gt;Embed Style Sheet&lt;/title&gt;<br>        &lt;style type=&quot;text/css&quot;&gt;<br>            .embed-style {<br>                color:blue;<br>                font-size: 20px;<br>               }<br>            &lt;/style&gt;<br>    &lt;/head&gt;<br>    &lt;body&gt;<br>    &lt;div class=&quot;embed-style&quot;&gt;Embed-style<br>    &lt;/div&gt;<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>วิธีเรียกแบบ <strong>External Style Sheet</strong> เป็นการเรียก CSS ที่อยู่คนละ file นำมาใช้ร่วมกับเว็บเพจได้ ซึ่งมี 2 วิธีคือ</li></ul><ol><li><strong>Linking Style Shee</strong>t เป็นการเรียกโดยระบุ link part ของ Css file เช่น</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/210/1*l-c6F1nUlhRgCPeaTMHhJw.png" /></figure><p>หน้า HTML จะเรียก link หน้าเว็บเพจดังนี้</p><p>&lt;link rel =”stylesheet” href=”cssworkout.css” &gt;</p><pre>&lt;!DOCTYPE html&gt;<br>    &lt;html&gt;<br>    &lt;head&gt;<br>        &lt;title&gt;External Style Sheet&lt;/title&gt;<br>        &lt;link rel=&quot;stylesheet&quot; href=&quot;cssworkout.css&quot; &gt;<br><br>    &lt;/head&gt;<br>    &lt;body&gt;<br>    &lt;div class=&quot;external-style&quot;&gt;1.External-Style<br>    &lt;/div&gt;<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><p>หน้า CSS กำหนด Class เพื่อติดต่อกับ HTML เว็บเพจดังนี้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*3nVnWBUOYPCx5wKJokF2FA.png" /></figure><p>2. Import Style Sheet เป็นการเรียกใช้ CSS โดยการ import file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/212/1*kSp1ru8k0p0bIafIp3XIDQ.png" /></figure><p>วิธีการเรียก import file หน้า HTML เว็บเพจ</p><pre>&lt;!DOCTYPE html&gt;<br>    &lt;html&gt;<br>    &lt;head&gt;<br>        &lt;title&gt;External Style Sheet&lt;/title&gt;<br>        &lt;style type=&quot;text/css&quot;&gt;<br>        @import &quot;cssworkout.css&quot; ;<br>        &lt;/style&gt;<br>    &lt;/head&gt;<br>    &lt;body&gt;<br>    &lt;div class=&quot;external-style&quot;&gt;2.External-Style<br>    &lt;/div&gt;<br>    &lt;/body&gt;<br>&lt;/html&gt;</pre><p>จะใช้ คำสั่ง &lt;style type=“text/css”&gt; กำหนดวิธีของ type และ ใช้คำสั่ง @import ตามด้วยชื่อ path CSS file</p><p><strong>รูปแบบ Style CSS เบื้องต้น</strong></p><p><strong><em>padding</em></strong> คือ การเพิ่มขอบเขตของ element ซึ่งสามารถกำหนดคุณสมบัติการขยายขอบเขตได้ 4 แบบ</p><ol><li>padding-top เป็นการขยายโดยเพิ่มขอบเขตด้านบนภายใน element เช่น กำหนดคุณสมบัติ padding-top:20px</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*-aPL6F4XM3p6Ztuu9Fnffg.png" /><figcaption>สีเขียวคือขอบเขตที่ขยาย สีฟ้าคือ element เดิม</figcaption></figure><p>2. padding-right เป็นการขยายขอบขวามือภายใน element เช่น กำหนดคุณสมบัติ padding-right:20px</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*D9TTpXlRYAlDmzhiFxEIfA.png" /><figcaption>สีเขียวคือขอบเขตที่ขยาย สีฟ้าคือ element เดิม</figcaption></figure><p>3. padding-bottom เป็นการขยายขอบด้านล่างภายใน element เช่น กำหนดคุณสมบัติ padding-bottom:20px</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*2nPJCsz1y3w913lYZoRZTQ.png" /><figcaption>สีเขียวคือขอบเขตที่ขยาย สีฟ้าคือ element เดิม</figcaption></figure><p>4. padding-left เป็นการขยายขอบด้านซ้ายภายใน element เช่น กำหนดคุณสมบัติ padding-left:20px</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*-ZLMYedIBOmtRy-ER080jg.png" /><figcaption>สีเขียวคือขอบเขตที่ขยาย สีฟ้าคือ element เดิม</figcaption></figure><p>เรามีวิธีกำหนดค่า padding-top, padding-right, padding-bottom, padding -left ได้หลายวิธีเพื่อลดจำนวน code เช่น padding-top:10px, padding-right:10px, padding-bottom:10px, padding-left:10px สามารถกำหนดเพียง padding:10px;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*M4X0ezwoPhiazX8oaMBMAw.png" /><figcaption>padding:10px; สีเขียวคือขอบเขตที่ขยาย สีฟ้าคือ element เดิม</figcaption></figure><p>ถ้ากำหนด padding: 2px 8px จะได้ผลลัพธ์คือ</p><ul><li>padding-top:2px; padding-bottom:2px;</li><li>padding-right:8px; padding-left:8px;</li></ul><p>ถ้ากำหนด padding: 2px 8px 10px จะได้ผลลัพธ์คือ</p><ul><li>padding-top:2px; padding-bottom:10px;</li><li>padding-right:8px; padding-left:8px;</li></ul><p><strong><em>Margin</em></strong> คือ การดันระหว่าง element กับ element ให้ออกห่างจากกัน โดยมีรูปแบบการดัน 4 รูปแบบคือ</p><ol><li>margin-top คือ การดัน element ขึ้นไปด้านบน เช่น กำหนดคุณสมบัติ margin-top:20px</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*-xGQZXwo83nSSPXz6cFXyA.png" /><figcaption>สีส้มคือ margin สีฟ้าคือ element</figcaption></figure><p>2. margin-right คือ การดัน element ไปทางขวาด้าน เช่น กำหนดคุณสมบัติ margin-right:20px</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*sRKl-KugXTW3qHtad5VXLg.png" /><figcaption>สีส้มคือ margin สีฟ้าคือ element</figcaption></figure><p>3. margin-bottom คือ การดัน element ลงไปข้างล่าง เช่น</p><p>กำหนดคุณสมบัติ margin-bottom:20px</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*OnwBiPD3S7_w3cQ7YRt1Kg.png" /><figcaption>สีส้มคือ margin สีฟ้าคือ element</figcaption></figure><p>4. margin-left คือ การดัน element ลงไปทางซ้าย เช่น</p><p>กำหนดคุณสมบัติ margin-left:20px</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*sfI0daNwCrFvPpMNJyRK-w.png" /><figcaption>สีส้มคือ margin สีฟ้าคือ element</figcaption></figure><p>เรามีวิธีกำหนด margin-top, margin-right, margin-bottom, margin -left แบบลดรูปโดยเพียงกำหนด margin:{top}, {right}, {bottom}, {left} เช่นเดียวกับ padding เลยยกตัวอย่างเช่น</p><p>การกำหนดค่า margin:20px 20px 20px 20px ; หรือ margin:20px มีผลลัพธ์เท่ากัน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*h00jzBmA8XGepYh0OzbLxA.png" /><figcaption>สีส้มคือ margin สีฟ้าคือ element</figcaption></figure><ul><li>margin:auto เป็นการกำหนดคุณสมบัติให้ margin ด้านบน ด้านล่างมีค่าเท่ากับศูนย์ และ กำหนดให้ด้านซ้ายและด้านขวามี weight:50%</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TwJMXq-2LAyd4yrMljvv6w.png" /><figcaption>สีส้มคือ margin สีฟ้าคือ element เมื่อปรับ margin:auto</figcaption></figure><p><strong>วิธีการใช้ Flexbox</strong></p><p>Flexbox เป็น layout mode ชนิดหนึ่งของ CSS 3 ที่ปรับปรุงขึ้นมาเพื่อช่วยในการกำหนดขนาด และจัดตำแหน่งของกล่องต่างๆออกมาให้ใช้งานสะดวกมากขึ้นในเว็บเพจ ซึ่ง flex layout มี property ใหม่เพิ่มขึ้นมา(แต่ไม่สามารถใช้ property float ร่วมกับ flex )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yAD8qGrWiftWzgoIbw4Z1Q.png" /><figcaption>รูปภาพโครงสร้าง Flex box reference: <a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/">https://css-tricks.com/snippets/css/a-guide-to-flexbox/</a></figcaption></figure><p><strong>Flex container</strong></p><p>คือ HTML Element ที่กำหนดค่า CSS 3 property “display” เป็นค่า “flex” หรือ “inline flex”</p><p><strong>Flex item</strong></p><p>คือ element ที่เป็น child ของ container</p><p>ถ้าหากจะใช้ flex-container เราต้องประกาศ property display:flex เพื่อกำหนดค่า container ขึ้นมาก่อน</p><p>จากรูปภาพโครงสร้าง flex box เส้นสีแดงคือ main axis ซึ่งคือ แกน ตามหลักคณิตศาสตร์นั้นเอง ซึ่ง flex จะมองแกนเป็นหลัก โดยใช้ flex-direction เป็นตัวกำหนดทิศทางของ item ต้องการต่อกันเป็นกล่องรูปแบบ row หรือ column</p><p><strong>วิธีการกำหนดคุณสมบัติ flex-direction มี 4 รูปแบบ</strong></p><p>.container {</p><p>flex-direction: row | row-reverse | column | column-reverse;</p><p>}</p><ol><li><strong>อธิบายคุณสมบัติ flex-direction: row</strong></li></ol><p>เป็นการกำหนดค่าทิศทางของกล่อง layout ให้ต่อกันเป็นแนวนอนโดยเริ่มจากฝั่งซ้ายสุดไปขวา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ajKGUx-RjDwXmK9BwMDc4g.png" /><figcaption>flex-direction: row</figcaption></figure><pre>.flex-start {<br>    display: flex;<br>    flex-direction: row;<br>}</pre><p><strong>2. อธิบายคุณสมบัติ flex-direction: row-reverse</strong></p><p>เป็นการกำหนดค่าทิศทางของกล่อง layout ให้ต่อกันเป็นแนวนอนโดยเริ่มจากฝั่งขวาสุดไปซ้าย</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MiJAuCDsdn8YaSlLFKWuMg.png" /><figcaption>flex-direction: row-reverse</figcaption></figure><pre>.flex-start {<br>    display: flex;<br>    flex-direction: row-reverse ;<br>}</pre><p><strong>3. อธิบายคุณสมบัติ flex-direction: column</strong></p><p>เป็นการกำหนดทิศทางของกล่องต่อกันเป็นแกน column โดยเริ่มลำดับเรียงจากกล่องบนสุดต่อเรียงลงมาเรื่อยๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dL_Ot8uh7UjkztjjA3fhQw.png" /><figcaption>flex-direction: column</figcaption></figure><pre>.flex-start {<br>    display: flex;<br>    flex-direction: column ;<br>}</pre><p><strong>4. อธิบายคุณสมบัติ flex-direction: column-reverse</strong></p><p>เป็นการกำหนดทิศทางของกล่องต่อกันเป็นแกน column โดยเริ่มลำดับเรียงจากกล่องล่างสุดและต่อกล่องที่สองขึ้นมาเรื่อยๆ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hxie2T4Jb8EQi0jXsk5o4A.png" /><figcaption>flex-direction: column-reverse</figcaption></figure><pre>.flex-start {<br>    display: flex;<br>    flex-direction: column-reverse ;<br>}</pre><p><strong>วิธีการกำหนดคุณสมบัติ flex-wrap มี 3 รูปแแบบ</strong></p><p>.container {</p><p>flex-wrap: nowrap | wrap | wrap-reverse;</p><p>}</p><ol><li><strong>อธิบายคุณสมบัติ flex-wrap: nowrap</strong></li></ol><p>เป็นการกำหนดให้กล่องอยู่ใน row เดียวกันทั้งหมดแบบ inline ไม่มีการขึ้นบรรทัดใหม่ ซึ่งเริ่มดำลับการสร้างกล่องจากซ้ายไปขวาโดย height แต่ละกล่องจะเท่ากันเสมอ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZyxrxsvImhyO2Zp2G6Pcew.png" /><figcaption><strong>flex-wrap: nowrap</strong></figcaption></figure><pre>.flex-start {<br>    display: flex;<br>    flex-wrap:nowrap;<br>}</pre><p><strong>2. อธิบายคุณสมบัติ flex-wrap: wrap</strong></p><p>เป็นการลำดับกล่องโดยเรียงจากซ้ายไปขวาและเมื่อสุดขอบ weight เริ่มต่อบรรทัดใหม่</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*28b_Zbp-10GYV1McJUe5pQ.png" /><figcaption><strong>flex-wrap: wrap</strong></figcaption></figure><pre>.flex-start {<br>    display: flex;<br>    flex-wrap:wrap;<br>}</pre><p><strong>3. อธิบายคุณสมบัติ flex-wrap: wrap-reverse</strong></p><p>เป็นการลำดับกล่องโดยเรียงจากด้านซ้ายล่างไปขวาและเมื่อสุดขอบ weight จะเริ่มต้นบรรทัดใน row แถวบน</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Avtfb1e34CW3z9nFO89Fg.png" /><figcaption><strong>wrap-reverse</strong></figcaption></figure><pre>.flex-start {<br>    display: flex;<br>    flex-wrap:wrap-reverse;<br>}</pre><p><strong>อธิบายคุณสมบัติ flex-grow</strong></p><p>เป็นการกำหนดคุณสมบัติให้ flex item มีขนาด weight ที่แตกต่างกันออกไปโดยจะกำหนด weight ด้วยตัวเลขเช่น</p><p><strong>flex-grow:</strong>1 ; คือ กำหนดค่า weight เป็น default</p><p><strong>flex-grow:2</strong> ; คือ กำหนดค่า weight เป็น 2 เท่าของ default</p><p><strong>flex-grow:3</strong> ; คือ กำหนดค่า weight เป็น 3 เท่าของ default</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yRN6otiQ0SirdVCJ3w6tMg.png" /><figcaption>flex-grow</figcaption></figure><pre>.space{<br>    height: 100px;<br>    border: 1px solid;<br>    text-align: center;<br>    flex-grow:1;<br><br>}<br>.space2{<br>    height: 100px;<br>    border: 1px solid;<br>    flex-grow:2;<br>    text-align: center;<br>}</pre><p><strong>วิธีจัดเรียง flex item ด้วย justify-content</strong></p><p>การจัดรูปแบบ justify-content เป็นการกำหนดค่า element ภายใน child ของ ที่ช่วยจัด layout ของ container ให้ง่ายขึ้น ซึ่งมี 6 รูปแบบด้วยกัน</p><p>.container { justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly; }</p><ol><li><strong>อธิบายคุณสมบัติ justify-content:flex-start</strong></li></ol><p>เป็นการกำหนดค่า flex item ให้มีการสร้างกล่องโดยเรียงลำดับเริ่มจากซ้ายไปขวาและเมื่อถึงขอบ weight ของ container จะเริ่มสร้างกล่องต่อไปในบรรทัดต่อไปและชิดซ้ายสุดเสมอ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_wheQ_ooSBZUq8ocXm6vg.png" /><figcaption>justify-content:flex-start</figcaption></figure><pre>.flex-start {<br>    display: flex;<br>    flex-direction: row;<br>    justify-content: flex-start;<br>    flex-wrap: wrap;<br> }</pre><p><strong>2. อธิบายคุณสมบัติ justify-content:flex-end</strong></p><p>เป็นการกำหนดค่า flex item ให้มีการสร้างกล่องโดยลำดับเริ่มจากขวาไปซ้ายและเมื่อเริ่มบรรทัดใหม่จะชิดขวาเสมอ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nZuh6pN7znn8MYV_QQFSew.png" /><figcaption>justify-content:flex-end</figcaption></figure><pre>.flex-start {<br>    display: flex;<br>    flex-direction: row;<br>    justify-content: flex-end;<br>    flex-wrap: wrap;<br> }</pre><p><strong>3. อธิบายคุณสมบัติ justify-content:center</strong></p><p>เป็นการกำหนดค่า flex item ให้มีการสร้างกล่องโดยกล่องจะอยู่ตำแหน่ง center เสมอ และมีการลำดับการเรียงกล่อจากซ้ายไปขวา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GXK3Iz-MDAz7kdwKWeYtIA.png" /><figcaption>justify-content:center</figcaption></figure><pre>.flex-container {<br>    display: flex;<br>    flex-direction: row;<br>    justify-content: center;<br>    flex-wrap: wrap;<br>}</pre><p><strong>4. อธิบายคุณสมบัติ justify-content:space-between</strong></p><p>เป็นการกำหนดค่า flex-item ให้มีระยะห่างเท่าๆกัน โดยจะมี flex-item อยู่ตำแหน่งชิดซ้ายและชิดขวาเสมอ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o6gwSIFPS_xTm4FkONPzJA.png" /><figcaption>justify-content:space-between</figcaption></figure><pre>.flex-container {<br>    display: flex;<br>    flex-direction: row;<br>    justify-content: space-between;<br> }</pre><p><strong>5. อธิบายคุณสมบัติ justify-content:space-around</strong></p><p>เป็นการกำหนดค่า flex-item ให้มีระยะห่างเท่าๆกันโดยไม่จำเป็นต้องให้ flex-item ชิดตำแหน่งซ้ายและตำแหน่งขวา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56ydN0-BNZqXQq5hhukB_Q.png" /><figcaption>justify-content:space-around</figcaption></figure><pre>.flex-container {<br>    display: flex;<br>    flex-direction: row;<br>    justify-content: space-around;<br>    flex-wrap: wrap;<br> }</pre><p><strong>6. อธิบายคุณสมบัติ justify-content:space-evenly</strong></p><p>เป็นการกำหนดค่า flex-item ให้มีระยะห่างเท่าๆกันแต่การกระจาย weight จะน้อยกว่ารูปแบบ justify-content:space-aroundโดยไม่จำเป็นต้องให้ flex-item ชิดตำแหน่งซ้ายและตำแหน่งขวา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*56ydN0-BNZqXQq5hhukB_Q.png" /><figcaption>justify-content:space-evenly</figcaption></figure><pre>.flex-container {<br>    display: flex;<br>    flex-direction: row;<br>    justify-content:space-evenly;<br>    flex-wrap: wrap;<br> }</pre><p><strong>อธิบายคุณสมบัติ align-item</strong></p><p>คุณสมบัติ align-item มี 5 แบบด้วยกัน</p><p>.container {</p><p>align-items: stretch | flex-start | flex-end | center | baseline; }</p><ol><li><strong>วิธีการกำหนดคุณสมบัติ align-items: stretch</strong></li></ol><p>เป็นการยืด flex-item ให้ชิดกับ container (ห้ามกำหนด height ให้ element ใน flex-item)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UKrvC7Frkg5a8NHIqXsL6A.png" /></figure><p><strong>2. วิธีการกำหนดคุณสมบัติ align-items: flex-start</strong></p><p>เป็นการกำหนด flex-item เริ่มต้นสร้างกล่องเรียงลำดับจากกล่องด้านซ้ายไปด้านขวาเหมือนกับ align-content: flex-start</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U33m1O46_vQ4iSnvQ-0WAw.png" /></figure><p><strong>3. วิธีการกำหนดคุณสมบัติ align-items: flex-end</strong></p><p>เป็นการกำหนด flex-item เริ่มต้นเรียงลำดับซ้ายจากกล่องด้านล่างสุดของ container ไปทางขวาและเมื่อถึงค่าขอบ weight ของ contianer จะถูกดันขึ้นไปและลำดับกล่องล่างซ้ายเรียงไปทางขวา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pwvzuIPxaVX1dS8_kgizvw.png" /></figure><p><strong>4. วิธีการกำหนดคุณสมบัติ align-items: center</strong></p><p>เป็นการกำหนด flex-item เริ่มต้นลำดับจากกล่องด้านซ้ายไปด้านขวา โดยอยู่ตำแหน่ง center ของ contianer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yr8OLVRQeyaKQ6-Fpjh4CQ.png" /></figure><p><strong>5. วิธีการกำหนดคุณสมบัติ align-items: baseline</strong></p><p>เป็นการกำหนด flex-item เริ่มต้นลำดับจากกล่องด้านซ้ายไปด้านขวา โดย element จะเรียง baseline ให้เท่ากันเสมอ</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qXn67NQ7rjn8vCd88jcRkQ.png" /></figure><p><strong>อธิบายคุณสมบัติ align-content</strong></p><p>คุณสมบัติ align-item มี 6 รูปแบบด้วยกัน</p><p>.container { align-content: flex-start | flex-end | center | space-between | space-around | stretch; }</p><ol><li><strong>อธิบายคุณสมบัติ align-items: flex-start</strong></li></ol><p>เป็นการกำหนด flex-item เริ่มต้นสร้างกล่องเรียงลำดับจากกล่องด้านซ้ายไปด้านขวา</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hYh2ieOenJiLfein6SvOeA.png" /></figure><p><strong>2. อธิบายคุณสมบัติ align-content: flex-end</strong></p><p>เป็นการสร้าง flex-item ลำดับจากซ้ายไปทางขวาโดยเริ่มต้นจากตำแหน่งล่างสุดของ contianer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pK1Hknocc9OgOTUL3hHSBw.png" /></figure><p><strong>3. อธิบายคุณสมบัติ align-content: center</strong></p><p>เป็นการกำหนด flex-item เริ่มต้นลำดับจากกล่องด้านซ้ายไปด้านขวา โดยอยู่ตำแหน่ง center ของ contianer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ewTq7oiUCuH9rQ4FVtSrQ.png" /></figure><p><strong>4. อธิบายคุณสมบัติ align-content: space-between</strong></p><p>เป็นการกำหนดค่า flex-item ให้เรียงการสร้างกล่องซ้ายไปขวา แต่ถ้าหากถึงขอบ weight ของ container ลำดับถัดไปกล่องจะถูกสร้างตำแหน่งซ้ายล่างสุดของ contianer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-WQ0hs1SAW8jrQbFhjgVoQ.png" /></figure><p><strong>5. อธิบายคุณสมบัติ align-content: space-around</strong></p><p>เป็นการกำหนดค่า flex-item โดยเรียงลำดับการสร้างกล่องจากซ้ายไปขวา วิธี space-around จะกระจายพื้นที่ตามเส้นขอบบนและขอบล่างของ container</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MuBGE2cnh7LxunH9wL_-mw.png" /></figure><p><strong>6. อธิบายคุณสมบัติ align-content: stretch</strong></p><p>เป็นการกำหนดค่า flex-item ให้ขนาด height เท่ากับ contianer</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8M7Bxh_5YFzG6GtJfc5eqg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97c6ff59671d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>