Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> CSS

เขียน Hover Effect ด้วย Inline CSS ยังไง?

บางครั้งบังคับเขียน inline CSS เช่น HTML email templates — ขึ้นกับ email/newsletter provider

แตะเขียน hover effect ด้วย inline CSS ยังไง?

ทำไม่ได้ แต่สร้าง hover effect เดียวกันได้ด้วย JavaScript onMouseOver และ onMouseOut method

เช่น อยากเปลี่ยนสี hyperlink hover (mouseover) จากน้ำเงินเป็นแดง:

<a href="#your-url-path" onMouseOver="this.style.color='red'" onMouseOut="this.style.color='green'">Click here to Subscribe</a>

ผลลัพธ์:

Click here to Subscribe

โดยทั่วไป inline CSS ไมเหมาะสม แต่บางครั้งบังคับใช้ less-than-ideal code เพื่อให้ things done