django学习入门系列之第三点《CSS基础样式介绍2》

文章目录


文字对齐方式

  • 水平对齐方式
css 复制代码
text-align: center;
  • 垂直对齐方式
css 复制代码
/* 注意,这个只能是一行来居中 */
line-height:/*长度*/ ;
  • 样例
html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>中国移动</title>

    <style>
        .c1{
            height: 100px;
            width: 100px;
            border : 1px solid red;
            text-align: center;
            line-height: 100px;
        }
    </style>
</head>
<body>
    <div class="c1">中国</div>
</body>
</html>

外边距

  • 简单设置外部的距离
    • 我与别人有距离
    • 设置语法margin-内容 像素
html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>中国移动</title>
    <style>
        .c2{
            width: 60px;
            height: 60px;
            border: 1px solid red;
            padding: 20px 10px 30px 40px;
            margin-top: 50px;
        }
    </style>
</head>
<body>
<div class="c2"></div>
<div class="c2"></div>
</body>
</html>

内边距

  • 简单来说就是自己的内部可以设置一点距离(空出多少边距)
    • 我自己内部有距离
    • 设置语法padding-内容 像素

例子:

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>中国移动</title>
    <style>
        .c2{
            width: 60px;
            height: 60px;
            border: 1px solid red;
            padding-top: 50px;
            padding-left: 50px;
            padding-right: 50px;
        }
    </style>
</head>
<body>
<div class="c2">
    <div style="background-color: hotpink">text</div>
</div>
</body>
</html>
  • 如果上下左右都要内边距的话
css 复制代码
padding 像素
css 复制代码
.c2{
            width: 60px;
            height: 60px;
            border: 1px solid red;
            padding: 50px;
        }

或者

css 复制代码
/* 按照上右下左的顺序给你安排 */
.c2{
            width: 60px;
            height: 60px;
            border: 1px solid red;
            padding: 20px 10px 30px 40px;
        }

往期回顾

1.【快速开发网站】
2.【浏览器能识别的标签1】
3.【浏览器能识别的标签2】
4.【浏览器能识别的标签3】
5.【浏览器能识别的标签4】
6.【案例1:用户注册】
7.【案例2:用户注册改进】
8.【快速了解 CSS】
9.【常用选择器概念讲解】
10.【CSS基础样式介绍1】

相关推荐
野槐26 分钟前
Electron开发
前端·javascript·electron
#做一个清醒的人26 分钟前
【Electron】开发两年Electron项目评估报告
前端·electron
lizhongxuan6 小时前
Claude Code 防上下文爆炸:源码级深度解析
前端·后端
紫金修道6 小时前
【DeepAgent】概述
开发语言·数据库·python
书到用时方恨少!7 小时前
Python multiprocessing 使用指南:突破 GIL 束缚的并行计算利器
开发语言·python·并行·多进程
Warson_L7 小时前
Python 常用内置标准库
python
Warson_L7 小时前
Python 函数的艺术 (Functions)
python
Warson_L8 小时前
Python 流程控制与逻辑
后端·python
long_songs8 小时前
手柄键盘映射器【github链接见文末 】
python·游戏·计算机外设·pygame·软件推荐·手柄映射键盘
必然秃头8 小时前
Python 环境安装及项目构建指南
python