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

วิธีสร้าง VM Instance ใน google developers console

VM Instance เป็นบริการของ google ที่ให้เราสร้างเครื่อง Server(Virtual machine) โดยเราสามารถกําหนดได้ตั้งแต่ Hardware ของเครื่อง ไปจนถึง OS ที่เราต้องการ ทําให้เราสามารถมีเครื่อง Server เป็นของตัวเองได้ง่ายๆภายในไม่กี่คลิ๊ก เริ่มแรกให้เราเข้าไปที่ console.developers.google.com/project จะขึ้นหน้าจอสําหรับจัดการ project ให้เราคลิ๊ก Create Project

วิธีใช้ PL2303 USB to serial TTL

PL2303 USB to serial TTL เป็น อุปกรณ์ที่ใช้แปลงจาก USB เป็น serial TTL ส่วนใหญ่จะนําไปใช้เชื่อมต่อ Computer เข้ากับ Raspberry pi

Touchscreen calibration raspberry pi

วิธี calibration จอ touchscreen raspberry piในบทความนี้ จะอธิบายเกี่ยวกับการ calibration จอ touchscreen ของ raspberry pi โดยจอ touchscreen ที่ใช้คือ Raspberry Pi 7" Touchscreen Display มาเริ่มกันเลยครับ


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

Build with ❤️ and Astro.

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