CSS Box-Shadow not working with Textarea in Webkit

This simple code does not work in Chrome or Safari ...

<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Untitled Document</title> </head> <style> :required {box-shadow:0 0 5px red;} </style> <body> <form> <textarea required></textarea> </form> </body> </html> 

It works great in Firefox and Opera. In addition, border:1px solid red works fine in webkit browsers. What a deal? I even tried textarea {display:block;} to think that this might be a built-in problem.

+6
source share
4 answers

You need to add

 -webkit-appearance: none; 

to make awesome webkit render textarea like a regular block and apply all the CSS you write.

See jsfiddle

+13
source

If you give textarea a background declaration of none (or a declaration of the background color for any reason other than white), the shadow will work.

 <style> :required { background: none; box-shadow:0 0 5px red; } </style> 
+2
source

try it

 textarea:required { box-shadow: 0 0 5px red; -webkit-box-shadow: 0 0 5px red; -moz-box-shadow: 0 0 5px red; border: solid 0px transparent; // or border: none; }​ 

Demo. and read it .

+2
source

try selecting Textarea via class or id instead of selector :required

0
source

Source: https://habr.com/ru/post/921350/


All Articles