分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 教程案例

CSS3-3

发布时间:2023-09-06 01:56责任编辑:熊小新关键词:CSS

关于背景

一. 渐变&径向渐变(background-image: -webkit-linear-gradient() && background-image: -webkit-radial-gradient())

<!DOCTYPE html> ?<html lang="en"> ?<head> ?????<meta charset="UTF-8"> ?????<title></title> ?????<style type="text/css"> ?????????.box { ???????????????margin: 200px 0 0 200px; ???????????????width: 200px; ???????????????height: 200px; ???????????????background-color: orange; ?????????????????????????/* 不用浏览器前缀 ?????????????????????????chrome : -webkit- ?????????????????????????Firefox : ?-moz-; ?????????????????????????IE ?: ?-ms-; ?????????????????????????opera : -o-; ?????????????????????*/ ?????????????????????????/* 1 基本用法*/ /*旋转角度,竖直开始;加前缀,水平开始*/ ???????????????/*background-image: -webkit-linear-gradient(rgba(255,0,0,.2), yellow, blue 30%, green 100%); ???????????background-image: -o-linear-gradient(rgba(255,0,0,.2), yellow, blue, green); ???????????background-image: linear-gradient(rgba(255,0,0,.2), yellow , blue 30%, green 30%);*/ ?????????????/*控制颜色渐变的方向 ???????????????????????????????to right -- 从左向右 ???????????????????to top -- 从下到上 ???????????????????to left -- 从右到左 ???????????????????to bottom --- 从上到下(默认值) ???????????????????????????*/ ???????????????????????????????????/*0deg = to top -- 从下到上*/ ?????????????????/*基于0度顺时针旋转45deg*/ ?????????????????/*基于0度逆时针旋转45deg*/ ????????????????????????????/*设置过渡颜色的起始位置*/ ???????????????/*从过渡起始位置50px开始让红色和黄色之间产生颜色渐变效果*/ ??????????????/* 2 径向渐变 : 由圆点向外延伸*/ ?????????????background-image: -webkit-radial-gradient(100px 100px,blue,white,red,black,purple,navy,green,yellow); ?????????} ?????</style> ?</head> ?<body> ???<div class="box"></div> ???<script type="text/javascript"> ?</script> ?</body> ?</html> ???????????

二. 渐变&径向渐变()

<!DOCTYPE html><html lang="en"><head> ???<meta charset="UTF-8"> ???<title>Document</title> ???<style type="text/css"> ???????div{ ???????????width: 508px; ???????????height: 300px; ???????????border: 10px solid #000; ???????????padding: 100px; ???????????background: url("C:\\Users\\Public\\Pictures\\Sample Pictures\\jjy.jpg") ; ???????????/* 默认:background-clip: padding-box; */ ???????????/* ???????????????background-clip: content-box; ???????????????border-box ???背景被裁剪到边框盒。 ???测试 ???????????????padding-box ???背景被裁剪到内边距框。 ???测试 ???????????????content-box ???背景被裁剪到内容框。 ???????????*/ ???????????background-clip: content-box; ???????????/* ???background-origin: padding-box|border-box|content-box; ???????????????padding-box ???背景图像相对于内边距框来定位。(默认) ???????????????border-box ???背景图像相对于边框盒来定位。 ???????????????content-box ???背景图像相对于内容框来定位。 ???????????*/ ???????????background-origin: content-box; ???????????/* ???????????????background-size: length|percentage|cover|contain; ???????????????length ???????设置背景图像的高度和宽度。 ???????????????????????????第一个值设置宽度,第二个值设置高度。 ???????????????????????????如果只设置一个值,则第二个值会被设置为 "auto"。 ???????????????percentage ???以父元素的百分比来设置背景图像的宽度和高度。 ???????????????????????????第一个值设置宽度,第二个值设置高度。 ???????????????????????????如果只设置一个值,则第二个值会被设置为 "auto"。 ???????????????cover ???????把背景图像扩展至足够大,以使背景图像完全覆盖背景区域。 ???????????????????????????背景图像的某些部分也许无法显示在背景定位区域中。(原图) ???????????????contain ???????把图像图像扩展至最大尺寸,以使其宽度和高度完全适应内容区域(保证不变形) ???????????*/ ???????????/*background-size: 100px;*/ ???????????/*background-size: 600px auto; */ ???????????/*background-size: 100%;*/ ???????????background-size: cover; ???????????/*background-size: contain;*//*这个等价于background-size: 100%;*/ ???????????/* ???????????????多背景:一个盒子可以携带多个背景。 ???????????*/ ???????????/* ???????????????background: url() repeat-y, ???????????????????????????url() no-repeat, ???????????????????????????url(); ???????????????background-size: auto auto, ????????????????????????????????600px 600px, ????????????????????????????????auto auto; ???????????*/ ???????} ???</style></head><body> ???<div>文字</div></body></html> ???????????

<!DOCTYPE html>  <html lang="en">  <head>      <meta charset="UTF-8">      <title></title>      <style type="text/css">          .box {                margin: 200px 0 0 200px;                width: 200px;                height: 200px;                background-color: orange;                          /* 不用浏览器前缀          chrome : -webkit-          Firefox :  -moz-;          IE  :  -ms-;          opera : -o-;          */                          /* 1 基本用法*/ /*旋转角度,竖直开始;加前缀,水平开始*/                /*background-image: -webkit-linear-gradient(rgba(255,0,0,.2), yellow, blue 30%, green 100%);            background-image: -o-linear-gradient(rgba(255,0,0,.2), yellow, blue, green);            background-image: linear-gradient(rgba(255,0,0,.2), yellow , blue 30%, green 30%);*/              /*控制颜色渐变的方向                                to right -- 从左向右                    to top -- 从下到上                    to left -- 从右到左                    to bottom --- 从上到下(默认值)                            */                                    /*0deg = to top -- 从下到上*/                  /*基于0度顺时针旋转45deg*/                  /*基于0度逆时针旋转45deg*/                             /*设置过渡颜色的起始位置*/                /*从过渡起始位置50px开始让红色和黄色之间产生颜色渐变效果*/ 
              /* 2 径向渐变 : 由圆点向外延伸*/              background-image: -webkit-radial-gradient(100px 100px,blue,white,red,black,purple,navy,green,yellow);          }      </style>  </head>  <body>    <div class="box"></div>    <script type="text/javascript">  </script>  </body>  </html>

CSS3-3

原文地址:https://www.cnblogs.com/hangege/p/9085748.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved