CSS中怎么给文字添加边框或字体加粗效果,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。 css给文字加添边框或字体
CSS中怎么给文字添加边框或字体加粗效果,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
css给文字加添边框或字体放大的方法
文字边框
p{ border:2px solid blue;}
文字边框代码示例
<meta charset="utf-8">
<title>文字边框</title>
<style>
p{ border:2px solid blue;}
</style>
</head>
<body>
<p>中文网1</p>
<p>中文网2</p>
<p>中文网3</p>
</body>
</html>
代码效果图
字体放大
通过元素的名称p选中所有的<p>
元素
p{}
p指定样式规则
p {font-size:200%;} 将字体放大1倍
字体放大代码示例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文字边框</title>
<style>
p{font-size: 200%;}
p.one
{
border-style:dashed;
border-width:5px;
}
p.two
{
border-style:solid;
border-width:medium;
}
p.three
{
border-style:solid;
border-width:1px;
}
p.four
{border-style:dashed;
border-width:2px;
border-color:red
</style>
</head>
<body>
<p class="one">编程网</p>
<p class="two">编程网</p>
<p class="three">编程网</p>
<p class="four">编程网</p>
</body>
</html>
字体放大代码效果图
如果想让所有的段落拥有灰色背景,使用元素选择器<p>
来定义
p{background:lightgray;} 选中所有的<p>设置背景色:亮灰色。
代码示例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文字边框</title>
<style>
p{background:lightgray; font-size: 200%;}
p.one
{
border-style:dashed;
border-width:5px;
}
p.two
{
border-style:solid;
border-width:medium;
}
p.three
{
border-style:solid;
border-width:1px;
}
p.four
{border-style:dashed;
border-width:2px;
border-color:red
</style>
</head>
<body>
<p class="one">编程网</p>
<p class="two">编程网</p>
<p class="three">编程网</p>
<p class="four">编程网</p>
</body>
</html>
代码效果图
看完上述内容,你们掌握css中怎么给文字添加边框或字体加粗效果的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注编程网JavaScript频道,感谢各位的阅读!
--结束END--
本文标题: css中怎么给文字添加边框或字体加粗效果
本文链接: https://www.lsjlt.com/news/76932.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0