當前位置:編程學習大全網 - 編程語言 - 網頁文字居中的代碼是什麽?

網頁文字居中的代碼是什麽?

<!DOCTYPE HTML>

<html lang="en">

<head>

<title>html文字居中測試</title>

<meta charset="UTF-8">

<style type="text/css">

body{background: #ddd;}

div{width:300px;height:180px;margin:10px auto;color:#fff;font-size:24px;}

.box1{background: #71a879;text-align: center;}

.box2{background: #6a8bbc;line-height: 200px;}

.box3{background: #dea46b;text-align: center;line-height: 200px;}

</style>

</head>

<body>

<div? class="box1">html文字水平居中</div>

<div? class="box2">html文字垂直居中</div>

<div? class="box3">html文字水平上下居中</div>

</body>

</html>

擴展資料:

html自定義字體樣式

壹般字體的設置包含:字體,字體大小,字體顏色

html設置字體的話有很多標簽去設置

h1,h2,h3,h4,h5,h6 標題

采用css屬性。用font去設置字體。

font-family 規定元素的字體系列。包含:宋體,微軟雅黑等這些字體之類的。font-family:Microsoft yahei 表示設置字體為微軟雅黑

font-weight是設置字體的粗細。包含:lighter(更細),normal(正常),bold(粗體),bolder(更粗)font-weight:bold設置字體為粗體

font-size 是字體的尺寸,可以用使用百分比去設置或者像素去設置。如:font-size:18px

color屬性是設置字體的顏色。可以采用

color:red; (顏色名稱)color:#00ff00; (顏色的十六進制)color:rgb(0,0,255);(顏色的rgb)

例子:

<style type="text/css">

.title{font-family:Microsoft yahei;font-size:16px;font-weight:bold;color:#ccc}

</style>

我是標題

  • 上一篇:stray樂譜都在哪
  • 下一篇:GridView 控件編程的事件
  • copyright 2024編程學習大全網