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>

代码效果图

css中怎么给文字添加边框或字体加粗效果

字体放大

通过元素的名称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>

字体放大代码效果图

css中怎么给文字添加边框或字体加粗效果

如果想让所有的段落拥有灰色背景,使用元素选择器<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中怎么给文字添加边框或字体加粗效果

看完上述内容,你们掌握css中怎么给文字添加边框或字体加粗效果的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注行业资讯频道,感谢各位的阅读!