html、css学习笔记(四)

2019-07-07  本文已影响0人  dev_winner

文字排版

<style type="text/css">
    body{
        font-family:"宋体";
     }
 </style>
body{
      font-size:12px;
      color:#666
}
a{
    font-weight:bold;
}
p {
    font-style:italic;
}
span {
    text-decoration:underline;
}
.oldPrice{
    text-decoration:line-through;
}

段落排版

p{
    text-indent:2em;
}
p {
    line-height:2em;
}
h1{
    word-spacing:50px; /*单词之间的间距*/
    letter-spacing:50px; /*字母之间的间距*/
}
div {
    text-align:center; /*left、right*/
}
a{
    display:block;
}
<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        a{
            display:inline-block;/*设置内联块元素*/
            width:20px;/*在默认情况下宽度不起作用*/
            height:20px;/*在默认情况下高度不起作用*/
            background:pink;/*设置背景颜色为粉色*/
            text-align:center; /*设置文本居中显示*/
        }
    </style>
</head>
<body>
    <a>1</a>
    <a>2</a>
    <a>3</a>
    <a>4</a>
</body>
</html>
添加前 添加后

盒子模型

div{
    border:2px  solid  red;
}
/*等价于*/
div{
    border-width:2px;
    border-style:solid;
    border-color:red;
}
border-top:1px solid red;
border-right:1px solid red; 
border-left:1px solid red;
盒模型的宽度和高度 盒子模型
div{
    padding:20px 10px 15px 30px;
}
div{
    margin:20px 10px 15px 30px;
}
/*等价于*/
div{
   margin-top:20px;
   margin-right:10px;
   margin-bottom:15px;
   margin-left:30px;
}
上一篇 下一篇

猜你喜欢

热点阅读