Import css ใน React

11 Feb 2018,
Share: 

นอกจากที่เราจะ import Component อื่นๆเข้ามาใช้งานใน Component ได้ เรายังสามารถที่จะ Import ไฟล์ css เข้ามาใช้งานใน Component ได้อีกด้วย

มาลอง Import กันเลยครับ สร้างไฟล์ Button.css มีเนื้อหาดังนี้

.Button {
  padding: 20px;
}

แล้ว Import แบบนี้ได้เลยครับ ที่ไฟล์ Button.js

import React, { Component } from 'react';
import './Button.css'; // Tell Webpack that Button.js uses these styles

class Button extends Component {
  render() {
    // You can use them as regular CSS styles
    return <div className="Button" />;
  }
}

Suggestion blogs

แอบเปิดกล้องแอป facebook messenger

สวัสดีครับในบทความนี้ ผมจะบอกว่าแอป facebook messenger สามารถ เปิดกล้อง Video call ได้โดยที่เจ้าของไม่อนุญาติ มันอาจจะเป็น bug ของแอป facebook messenger หรือป่าวผมไม่แน่ใจนะครับ ซึ่งผมเจอมันโดยบังเอิญ มาลองดู Video กันว่ามันทําได้อย่างไร

OR gate

OR gate เป็นวงจร digital ชนิดหนึ่ง โดย input ที่ป้อนให้กับวงจรในแต่ละขา จะเป็นได้สองสถานะคือ High, Low หรือ 0, 1

เขียนเกมส์ pacman ด้วย c/c++

สวัสดีครับ เมื่อไม่กี่วันมานี้มีน้องคนนึงมาให้สอนเขียนเกมส์ pacman ด้วยภาษาซี ผมจึงนํา source code มาแบ่งปัน เผื่อใครสนใจ ตัวเกมส์ก็ไม่มีอะไรมากครับเป็น console application มีตัว pacman และตัว bot โง่ๆ 4 ตัว เขียนบน visual studio 2013 ส่วนวิธีการเล่น คือใช้ w, s, a, d เป็นปุ่มบังคับทิศทาง


Copyright © 2019 - 2025 thiti.dev |  v1.59.0 |  Privacy policy | 

Build with ❤️ and Astro.

Github profile   Linkedin profile   Instagram   X profile   Nostr   Youtube channel   Telegram   Email contact   วงแหวนเว็บ