2024.4.6-day11-CSS 背景和精灵图

news2024/10/6 4:11:03

个人主页:学习前端的小z
个人专栏:HTML5和CSS3悦读
本专栏旨在分享记录每日学习的前端知识和学习笔记的归纳总结,欢迎大家在评论区交流讨论!


文章目录

  • 作业
  • 2024.4.6学习笔记
    • 1 背景
    • 2 背景图片
    • 3 CSS 精灵图

作业

在这里插入图片描述

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>背景</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        ul {
            list-style: none;
        }
        body {
            font: bolder 25px "Microsoft YaHei","Heiti SC",tahoma,arial,"Hiragino Sans GB","\5B8B\4F53",sans-serif;
            color: white;
        }
        .auto-center {
            width: 1000px;
            margin-left: auto;
            margin-right: auto;
        }
        .full-center {
            min-width: 1000px;
        }
        .text-center {
            text-align: center;
        }
        .clearfix::after {
            content: '';
            display: block;
            clear: both;
        }

        .top {
            background: #000079 url("https://img2.baidu.com/it/u=1403977252,4044276651&fm=253&fmt=auto&app=138&f=JPEG?w=679&h=500")left top /cover no-repeat;
        }
        .top>.auto-center {
            line-height: 100px;
            background-color: rgba(0,0,0,.5);

        }
        .banner {
            background: #003E3E url("https://img0.baidu.com/it/u=1811701003,4165153230&fm=253&fmt=auto&app=120&f=JPEG?w=1280&h=800") center /cover no-repeat;
            line-height: 300px;
        }
        .main {
            margin-top: 20px;
            background: #467500 url("./images/1.png");
        }
        /*基于浮动实现两栏布局,左边200px,右侧自动填充剩余空间*/
        .content-one {
            position: relative;
            height: 500px;
        }
        .content-one>.left {
            width: 200px;
            background-color: #613030;
            line-height: 500px;
            /* float: left; */
            position: absolute;
        }
        .content-one>.right {
            /* 思考,right为绝对定位是否可以实现两栏布局? */
            margin-left: 200px;
            background-color: #336666;
            line-height: 300px;
        }

        /*基于浮动实现栏栅布局*/
        .content-tow {
            margin-top: 10px;
        }
        .content-tow>.list-item {
            float: left;
            width: 250px;
            height: 150px;
            box-sizing: border-box;
            background-color: #CAFFFF;
            background-size: contain;
            background-position: center;
            background-repeat: no-repeat;
            text-align: center;
            line-height: 150px;
            color: black;
            border: 1px dashed #ccc;
        }

        /* 基于浮动实现三栏布局,左固定200px,右固定250px,中间自适应宽度(填充剩余空间) 
        注意:中间一栏必须放到最后
        */
        .content-three {
            margin-top: 20px;
            position: relative;
            height: 300px;
        }
        .content-three>.left {
            position: absolute;
            width: 200px;
            left: 0;
            top: 0;
            /* float: left; */
            line-height: 300px;
            background-color: #F9F900;
        }
        .content-three>.right {
            position: absolute;
            width: 250px;
            right: 0;
            top: 0;
            /* float: right; */
            line-height: 300px;
            background-color: #A5A552;
        }
        .content-three>.middle {
            background-color: #5CADAD;
            margin-left: 200px;
            margin-right: 250px;
        }

        /* 基于浮动实现三栏布局,左固定200px,右固定250px,中间自适应宽度(填充剩余空间) 
        使用父级外边距实现
        */
        .content-four {
            margin-top: 20px;
            padding-left: 200px;
            padding-right: 250px;
        }
        .content-four>.left {
            width: 200px;
            float: left;
            line-height: 300px;
            background-color: #F9F900;
            margin-left: -200px;
        }
        .content-four>.right {
            width: 250px;
            float: right;
            line-height: 300px;
            background-color: #A5A552;
            margin-right: -250px;
        }
        .content-four>.middle {
            background-color: #5CADAD;
        }
        
        .footer {
            margin-top: 20px;
            background-color: #642100;
            line-height: 200px;
        }

        .fixed-ad {
            position: fixed;
            width: 100px;
            height: 300px;
            right: 20px;
            top: 50%;
            margin-top: -150px;
            background: #4D0000 url("https://tpc.googlesyndication.com/simgad/17371016686948028154?sqp=4sqPyQQ7QjkqNxABHQAAtEIgASgBMAk4A0DwkwlYAWBfcAKAAQGIAQGdAQAAgD-oAQGwAYCt4gS4AV_FAS2ynT4&rs=AOga4qnNb_psIDjzxDXDvxySskllK06_2Q") center/cover no-repeat;
            
        }

        .other {
            margin-top: 30px;
            background-color: #FF60AF;
            border: 1px dashed #ccc;
            position: relative;
        }

        .other .bottom {
            position: absolute;
            bottom: -10px;
            left: 20px;
            right: 20px;
            background-color: #B15BFF;
        }
    </style>
</head>
<body>
    <div class="top full-center">
        <div class="auto-center text-center">top</div>
    </div>
    <div class="banner text-center full-center">
        banner
    </div>
    <div class="main auto-center">
        <div class="content-one">
            <div class="left text-center">
                left
            </div>
            <div class="right text-center">
                right
            </div>
        </div>
        <ul class="content-tow clearfix">
            <li class="list-item" style="background-image: url(https://tse4-mm.cn.bing.net/th/id/OIP-C.1MOvhYr7-PNCCFY1w5yIzAHaEo?rs=1&pid=ImgDetMain)">list-item1</li>
            <li class="list-item" style="background-image: url(https://pic4.zhimg.com/v2-5290caf1f5c8c270e6da56b0361c9e1b_r.jpg)">list-item2</li>
            <li class="list-item" style="background-image: url(https://tse3-mm.cn.bing.net/th/id/OIP-C.neU_lyZXZpazGKjZXAlGywHaEK?rs=1&pid=ImgDetMain)">list-item3</li>
            <li class="list-item" style="background-image: url(./images/2.png)">list-item4</li>
            <li class="list-item" style="background-image: url(https://ts1.cn.mm.bing.net/th/id/R-C.31df3a5a2d8462228734f95d459883e2?rik=7EE6TeWDk%2f%2bctQ&riu=http%3a%2f%2fwww.quazero.com%2fuploads%2fallimg%2f140303%2f1-140303214331.jpg&ehk=SpI7mz%2byLqOkT8BL79jcd3iCtQYNFlBHQzbtF1p0vuQ%3d&risl=&pid=ImgRaw&r=0)">list-item5</li>
            <li class="list-item" style="background-image: url(https://img1.pconline.com.cn/piclib/200807/22/batch/1/5836/1216741512734nnouustae4.jpg)">list-item6</li>
            <li class="list-item" style="background-image: url(https://www.euweb.cn/wp-content/uploads/2016/12/302636-106.jpg)">list-item7</li>
            <li class="list-item" style="background-image: url(https://n.sinaimg.cn/sinacn10116/600/w1920h1080/20190326/2c30-hutwezf6832339.jpg)">list-item8</li>
        </ul>
        <div class="content-three clearfix">
            <div class="left text-center">
                left
            </div>
            <div class="right text-center">
                right
            </div>
            <div class="middle text-center">
                middle
            </div>
        </div>
        <div class="content-four clearfix">
            <div class="left text-center">
                left
            </div>
            <div class="right text-center">
                right
            </div>
            <div class="middle text-center">
                middle
            </div>
        </div>
    </div>

    <div class="other auto-center">
        <div>content</div>
        <div>content</div>
        <div>content</div>
        <div>content</div>
        <div>content</div>
        <div class="bottom text-center">title</div>
    </div>

    <div class="footer text-center full-center">
        footer
    </div>

    <div class="fixed-ad text-center">ad</div>

    
    <div style="position: fixed;
    top: 200px;
    left: 50%;
    margin-left: 500px;
    width: 50px;
    height: 150px;
    background-color: #ccc;">版心固定</div>
</body>
</html>

在这里插入图片描述

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="shouye" content="shouye">
        <meta description="shouye" content="shouye">
        <title>首页</title>
        <style>
            * {
                padding: 0;
                margin: 0;
            }
            ol {
                width: 600px;
                font-size: 0;
                margin: 30px auto;
            }

            ol>li {
                width: 300px;
                font-size: 14px;
                padding: 10px 0;
            }
            ol>li,span {
                display: inline-block;
            }
            span,a {
                text-align: center;
            }
            
           
            a {
                color: black;
                text-decoration: none;
            }
            a:hover {
                color: blue;
            }
            .sprites {
                background-image: url("./images/3.png");
                background-repeat: no-repeat;
            }
            .one1,.two2,.three3,.qita {
                width: 20px;
                height: 20px;
            }
            .xin,.re {
                width: 16px;
                height: 16px;
            }
        
            .one1 {
                background-position-x: -10px;
                background-position-y: -10px;
            }
            .qita {
                background-position-x: -50px;
                background-position-y: -50px;
            }
            .xin {
                background-position-x: -90px;
                background-position-y: -46px;
            }
            .three3 {
                background-position-x: -10px;
                background-position-y: -50px;
            }
            .two2 {
                background-position-x: -50px;
                background-position-y: -10px;
            }
            .re {
                background-position-x: -90px;
                background-position-y: -10px;
            }
        </style>
    </head>
    <body>
        <ol>
            <li>
                <span class="sprites one1">1</span>
                <a href="#">高福称北京疫情可能要前推一个月</a>
                <span class="sprites re"></span>
            </li>
            <li>
                <span class="sprites qita">4</span>
                <a href="#">白百何方否认新恋情</a>
                
            </li>
            <li>
                <span class="sprites two2">2</span>
                <a href="#">北京新发地市场商户回浙江后确诊</a>
                <span class="sprites xin"></span>
            </li>
            <li>
                <span class="sprites qita">5</span>
                <a href="#">男童在确诊患者被子上玩感染</a>
            </li>
            <li>
                <span class="sprites three3">3</span>
                <a href="#">涉事教师承认曾掌掴坠楼小学生</a>
            </li>
            <li>
                <span class="sprites qita">6</span>
                <a href="#">110万买奔驰越野车高速熄火5次</a>
            </li>
        </ul>
    </body>
</html>

在这里插入图片描述

2024.4.6学习笔记

1 背景

元素默认颜色是透明色。

2 背景图片

background-image: url(“”)
背景图片只作为背景,不会占用位置:

在这里插入图片描述

行内样式设置背景图片url可以不设置双引号。
有剩余空间时,背景平铺
background-position:x,y
坐标x,y负数让图片让左/上侧移动,正数是让图片 右/下侧移动。

在这里插入图片描述

在这里插入图片描述

cover - 水平或者垂直方向不满足宽高比会被剪裁,比如宽>高,那么宽会被剪裁,高就会完全呈现,反之亦然

contain - 水平或者垂直方向不满足宽高比会被留白,比如宽>高,那么水平方向就被留白,反之亦然,都会完全出来呈现

3 CSS 精灵图

在这里插入图片描述

VScode中可用ctrl+shift+l选中相同部分进行同时编辑

外联设置css样式:

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1574346.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C语言初阶—9函数

函数的声明 &#xff08;main函数前&#xff09;----告诉有一个函数 格式&#xff1a; 类型 函数名&#xff08;参数&#xff09;&#xff1b; 函数的声明 放到头文件add.c 函数的定义 ----创建函数----放到add.c 格式&#xff1a;类型 函数名(参数) { 语句项; } 在文…

【Qt 学习笔记】使用两种方式实现helloworld

博客主页&#xff1a;Duck Bro 博客主页系列专栏&#xff1a;Qt 专栏关注博主&#xff0c;后期持续更新系列文章如果有错误感谢请大家批评指出&#xff0c;及时修改感谢大家点赞&#x1f44d;收藏⭐评论✍ 使用两种方式实现helloworld 文章编号&#xff1a;Qt 学习笔记 / 05 …

Ais client LA8295 camx KMD enqueue dequeue

Ais client 调用qcarcam_s_buffers 设置buffer 进行enqueue buf PUBLIC_API qcarcam_ret_t qcarcam_s_buffers(qcarcam_hndl_t hndl, qcarcam_buffers_t* p_buffers) {return camera_to_qcarcam_result(ais_s_buffers(hndl, p_buffers)); }qcarcam_s_buffers(input_ctxt->q…

卷积神经网络实战

构建卷积神经网络 卷积网络中的输入和层与传统神经网络有些区别&#xff0c;需重新设计&#xff0c;训练模块基本一致 1.首先读取数据 - 分别构建训练集和测试集&#xff08;验证集&#xff09; - DataLoader来迭代取数据 # 定义超参数 input_size 28 #图像的总尺寸28*28…

使用Springfox Swagger实现API自动生成单元测试

目录 第一步&#xff1a;在pom.xml中添加依赖 第二步&#xff1a;加入以下代码&#xff0c;并作出适当修改 第三步&#xff1a;在application.yaml中添加 第四步&#xff1a;添加注解 第五步&#xff1a;运行成功之后&#xff0c;访问相应网址 另外&#xff1a;还可以导出…

JavaScript代码小挑战

题目如下&#xff1a; 朱莉娅和凯特正在做一项关于狗的研究。于是&#xff0c;她们分别询问了 5 位狗主人他们的狗的年龄&#xff0c;并将数据存储到一个数组中&#xff08;每人一个数组&#xff09;。目前&#xff0c;她们只想知道一只狗是成年狗还是小狗。如果狗的年龄至少为…

算力在现实生活中的多方面应用!

算力在现实生活中的应用是多方面的&#xff0c;它已经成为推动现代社会发展的重要力量。 以下是算力在不同领域中的具体应用&#xff1a; 立即免费体验&#xff1a;https://gpumall.com/login?typeregister&sourcecsdn #分布式云服务#算力#GpuMall#GpuMall智算云#训练#…

【AI-3】Transformer

Transformer? Transformer是一个利用注意力机制来提高模型训练速度的模型&#xff0c;因其适用于并行化计算以及本身模型的复杂程度使其在精度和性能上都要高于之前流行的循环神经网络。 标准的Transformer结构如下图所示&#xff08;图来自知乎-慕文&#xff09;&#xff0c…

特征提取算法

特征提取算法 0. 写在前边1. Harris算法1.1 写在前面1.2 Harris算法的本质1.3 Harris算法的简化 2. Harris3D2.1 Harris3D算法问题定义2.2 Harris3D with intensity2.3 Harris3D without intensity 3. ISS特征点的应用 0. 写在前边 本篇将介绍几种特征提取算法&#xff0c;特征…

C++从入门到精通——类对象模型

类对象模型 前言一、如何计算类对象的大小问题 二、类对象的存储方式猜测对象中包含类的各个成员代码只保存一份&#xff0c;在对象中保存存放代码的地址只保存成员变量&#xff0c;成员函数存放在公共的代码段问题总结 三、结构体内存对齐规则四、例题结构体怎么对齐&#xff…

3D桌面端可视化引擎HOOPS Visualize如何实现3D应用快速开发?

HOOPS Visualize是一个开发平台&#xff0c;可实现高性能、跨平台3D工程应用程序的快速开发。一些主要功能包括&#xff1a; 高性能、以工程为中心的可视化&#xff0c;使用高度优化的OpenGL或DirectX驱动程序来充分利用可用的图形硬件线程安全的C和C#接口&#xff0c;内部利用…

mysql索引相关知识点

1. 索引是什么&#xff1f; 索引是一种特殊的文件(InnoDB数据表上的索引是表空间的一个组成部分)&#xff0c;它们包含着对数据表里所有记录的引用指针。 索引是一种数据结构。数据库索引&#xff0c;是数据库管理系统中一个排序的数据结构&#xff0c;以协助快速查询、更新数…

【Java业务需求解决方案】分布式锁应用详情,多种方案选择,轻松解决,手把手操作(非全数字编码依次加一问题)

背景&#xff1a; 现有编码格式为业务常量数字&#xff0c;每新增一条数据在基础上1,比如&#xff1a; 文件类型1 编码为ZS01 文件类型1下文件1 编码为ZS0101 文件类型1下文件2 编码为ZS0102 文件类型2 编码…

Vue - 3( 15000 字 Vue 入门级教程)

一&#xff1a;初识 Vue 1.1 收集表单数据 收集表单数据在Vue.js中是一个常见且重要的任务&#xff0c;它使得前端交互变得更加灵活和直观。 Vue中&#xff0c;我们通常使用v-model指令来实现表单元素与数据之间的双向绑定&#xff0c;从而实现数据的收集和更新。下面总结了…

Springboot引入swagger

讲在前面&#xff1a;在spring引入swagger时&#xff0c;由于使用的JDK、Spring、swagger 的版本不匹配&#xff0c;导致启动报错&#xff0c;一直存在版本依赖问题。所以在此声明清楚使用版本。JDK 1.8、Spring boot 2.6.13、 Swagger 2.9.2。 引入maven依赖 <dependency&…

【Canvas与艺术】绘制金色Brand Award品牌嘉奖奖章

【成果图】 【代码】 <!DOCTYPE html> <html lang"utf-8"> <meta http-equiv"Content-Type" content"text/html; charsetutf-8"/> <head><title>金色Brand Award品牌嘉奖</title><style type"text/…

WebGL异步绘制多点

异步绘制线段 1.先画一个点 2.一秒钟后&#xff0c;在左下角画一个点 3.两秒钟后&#xff0c;我再画一条线段 <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta name"viewport" content"…

Games101-几何(基本表示方法)

几何分类 几何分类&#xff1a;隐式几何和显示几何 隐式几何&#xff1a;不会告诉空间中的点具体在哪&#xff0c;告诉这些点满足的一定关系。 如球的描述 x 2 y 2 z 2 1 x^2 y^2 z^2 1 x2y2z21 缺点&#xff1a;这个面都有哪些点是不容易看出来的&#xff0c;从上述的…

[Apple Vision Pro]开源项目 Beautiful Things App Template

1. 技术框架概述&#xff1a; - Beautiful Things App Template是一个为visionOS设计的免费开源软件&#xff08;FOSS&#xff09;&#xff0c;用于展示3D模型画廊。 2. 定位&#xff1a; - 该模板作为Beautiful Things网站的延伸&#xff0c;旨在为Apple Vision Pro用户…

从300亿分子中筛出6款,结构新且易合成,斯坦福抗生素设计AI模型登Nature子刊

ChatGPT狂飙160天&#xff0c;世界已经不是之前的样子。 新建了免费的人工智能中文站https://ai.weoknow.com 新建了收费的人工智能中文站https://ai.hzytsoft.cn/ 更多资源欢迎关注 全球每年有近 500 万人死于抗生素耐药性&#xff0c;因此迫切需要新的方法来对抗耐药菌株。 …