html中div设置字体大小有两种 方法 ,下面由我为大家整理了html中的div设置字体大小的相关知识,希望对大家有帮助!
html中div设置字体大小
设置对象DIV字体大小或span字体大小设置有两种方法,一种是使用style直接设置css字体大小,另外一种外部设置指定DIV内字体大小样式。
html中的div设置字体大小方法一
我们设置DIV盒子字体大小为12px,在分别标签内使用style属性设置css font-size设置字体大小样式。
1、对应html源代码片段
<div style="font-size:12px">设置div内字体大小为12px</div>
html中的div设置字体大小方法二
我们通过外部新建CSS选择器对指定div设置文字大小样式。
1、实例css代码
<style>
.div{font-size:14px}
/* css注释:设置使用对象选择器名为“.div”的字体大小为14px */
.span{font-size:16px}
</style>
2、实例对应html代码片段
<div>未设置div字体大小</div>
<div class="div">设置div字体大小为18px</div>
<script type="text/javascript">function changeText(){
document.getElementById('boldStuff').innerHTML = 'Fred Flinstone'
}
</script>
<p>Welcome to the site <b id='boldStuff'>dude</b> </p>
<input type='button' onclick='changeText()' value='Change Text'/>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)