博主信息
博文 16
粉丝 0
评论 0
访问量 15420
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
css元素定位
如花似玉的小牛牛的博客
原创
1185人浏览过
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>相对定位/绝对定位</title>
    <link rel="stylesheet" href="dingwei.css">
    <style>
        body {
            background-image: url("http://www.d006.com/style/bg.jpg");
            algin:center;
            height: 1200px;
        }

    </style>
</head>
<body>
<div id="dingwei1">
<form method="get" action="http://www.d006.com">
    <link>账号:</link>
    <input type="username" id="username" required placeholder="请输入账号">
    <link>密码:</link>
    <input type="password" id="password" required placeholder="请输入密码">
    <button type="button">登录</button>
</form>
</div>
<div id="kefu">
</div>
<div id="youxia">
    <p>小葵花妈妈课堂开课了</p>
    <p>孩子不听话怎么办?</p>
    <p>多半是欠打了!</p>
</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

实例

div[id="dingwei1"] {
        width: 239px;
        height: 148px;

        text-align: center;
        border-radius:21px;
        background-color: #ff00a7;
        border: 1px red dashed;
        position: relative;
    top: 300px;
    left: 41%;
}

div[id="dingwei1"] form {

        position: absolute;
        top: 40px;
}
div[id="dingwei1"] form>input {
    height: 20px;
   border: 1px red solid;
}

div[id="dingwei1"] form>button {
    width: 88px;
    height: 38px;
    color: white;

    border: 0px;

    background-color: cyan;
    border-radius: 5px;
    position: relative;
    top: 10px;
}
div[id="dingwei1"] form>button:hover {
    background-color: black;

}
#kefu {

    width: 190px;
    height: 190px;
    background-image: url("https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=1809927334,1828281527&fm=179&app=42&f=JPEG?w=56&h=56");
    background-repeat: no-repeat;
    position: sticky;
    left: 93%;
    top: 50%;
}

#youxia {
    width: 190px;
    height: 145px;
    background-color: #888888;
    text-align: center;
    position: fixed;
    top:76%;
    left: 85%;
}

运行实例 »

点击 "运行实例" 按钮查看在线实例

笔记css定位分为 position:fixed粘性定位,position:relative相对定位,position:absolute绝对定位

批改状态:未批改

老师批语:
本博文版权归博主所有,转载请注明地址!如有侵权、违法,请联系admin@php.cn举报处理!
全部评论 文明上网理性发言,请遵守新闻评论服务协议
0条评论
作者最新博文
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号

  • 登录PHP中文网,和优秀的人一起学习!
    全站2000+教程免费学