为什么< textarea>和< textfield>不从字体系列和字体大小从身体? [英] Why <textarea> and <textfield> not taking font-family and font-size from body?
问题描述
为什么 Textarea
和 textfield
不使用 font-family
.com / ucano4rel =nofollow noreferrer> http://jsbin.com/ucano4
代码
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // EN
http://www.w3.org /TR/xhtml1/DTD/xhtml1-transitional.dtd\">
< html xmlns =http://www.w3.org/1999/xhtml>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
< title> texearea字体< / title>
< style type =text / css>
body {
font-family:Verdana,Geneva,sans-serif;
font-size:16px
}
< / style>
< / head>
< body>
< form action =method =get>
< textarea name =cols =20rows =4>< / textarea>
< input name =type =text/>
< / form>
< p>一些文字在这里< / p>
< / body>
< / html>
如果这是一个通常的行为,那么我应该这样写在CSS。我需要相同的风格所有
body,textarea,input {
font-family:Verdana,Geneva,sans-衬线
font-size:16px
}
。
默认情况下,浏览器使用操作系统控件或浏览器控件渲染大多数表单元素(文本框,文本框,按钮等)。因此,大多数字体属性取自操作系统当前使用的主题。
如果您要更改其字体/
据我所知,只有表单元素会受到影响。离开我的头顶:输入
,按钮
, textarea
, select
。
Why Textarea
and textfield
not taking font-family
and font-size
from body?
See live example here http://jsbin.com/ucano4
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>texearea font</title>
<style type="text/css">
body {
font-family: Verdana, Geneva, sans-serif;
font-size:16px
}
</style>
</head>
<body>
<form action="" method="get">
<textarea name="" cols="20" rows="4"></textarea>
<input name="" type="text" />
</form>
<p>some text here</p>
</body>
</html>
If it's a usual behavior then should i write in css like this. i need same style in all
body,textarea,input {
font-family: Verdana, Geneva, sans-serif;
font-size:16px
}
And how many other elements in XHTML which will not take font styling from body {....}
?
By default, browsers render most form elements (textareas, text boxes, buttons, etc) using OS controls or browser controls. So most of the font properties are taken from the theme the OS is currently using.
You'll have to target the form elements themselves if you want to change their font/text styles - should be easy enough by selecting them though, as you've just done.
As far as I know, only form elements are affected. Off the top of my head: input
, button
, textarea
, select
.
这篇关于为什么< textarea>和< textfield>不从字体系列和字体大小从身体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!