css边距的接触

一、鼠标悬停 :鼠标选停到上时,设置样式 名:hover{ 样式:样式值 } 例如:
css 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        span{
            color:red;
        }
        span:hover{
            color:blue;
            text-decoration: underline;
        }
        a{
            padding-right:20px;
            color:blue;    
        }
        a:hover{
            color:green;
            text-decoration: none;
        }

    </style>
二、内边距: padding
css 复制代码
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div {
            width: 500px;
            height: 500px;
        }

        div {
            border: 1px solid red;

4个边 padding: 0px; 上下 左右 padding: 0px 20px; 上 左右 下 padding: 0px 20px 30px; 上 右 下 左 padding: 0px 20px 30px 40px;

三、外边距: margin
css 复制代码
注意:元素的下边距和另一个元素的上边距会合并       外边距 margin
 可以让元素左右居中 例如:margin:0px auto;    (auto 自动)
margin-top:10px;   margin-bottom:10px;   margin-left:10px;    margin-right:10px;

平移这个元素位置的一半 :transform: translate(-50%,0px); 左右 上下居中

相关推荐
liangshanbo12151 天前
写好 React useEffect 的终极指南
前端·javascript·react.js
哆啦A梦15881 天前
搜索页面布局
前端·vue.js·node.js
_院长大人_1 天前
el-table-column show-overflow-tooltip 只能显示纯文本,无法渲染 <p> 标签
前端·javascript·vue.js
哆啦A梦15881 天前
axios 的二次封装
前端·vue.js·node.js
阿珊和她的猫1 天前
深入理解与手写发布订阅模式
开发语言·前端·javascript·vue.js·ecmascript·状态模式
yinuo1 天前
一行 CSS 就能搞定!用 writing-mode 轻松实现文字竖排
前端
snow@li1 天前
html5:拖放 / demo / 拖放事件(Drag Events)/ DataTransfer 对象方法
前端·html·拖放
浪裡遊1 天前
Nivo图表库全面指南:配置与用法详解
前端·javascript·react.js·node.js·php
漂流瓶jz1 天前
快速定位源码问题:SourceMap的生成/使用/文件格式与历史
前端·javascript·前端工程化
samroom1 天前
iframe实战:跨域通信与安全隔离
前端·安全