<html lang="en"> <head> <meta charset="UTF-8"> <title>自適應頁面</title> <style type="text/css"> .div1{ position: relative;} .div2{ position: absolute; tex ...
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>