html部分
<div class="div1">
<div class="div2">
<span class="headLine">这是一个自适应的标题</span>
</div>
</div>
css部分
.div1{
position: relative;
}
.div2{
position: absolute;
text-align: center;
left: 0;
right: 0;
top: 60px;
}
.headLine{
font-size: 45px;
border:2px solid black;
/*border-radius: 20%;*/
padding: 10px 10px;
}
完整模板代码
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>自适应页面</title>
<style type="text/css">
.div1{
position: relative;
}
.div2{
position: absolute;
text-align: center;
left: 0;
right: 0;
top: 60px;
}
.headLine{
font-size: 45px;
border:2px solid black;
/*border-radius: 20%;*/
padding: 10px 10px;
}
</style>
</head>
<body>
<div class="div1">
<div class="div2">
<span class="headLine">这是一个自适应的标题</span>
</div>
</div>
</body>
</html>